How to make 2 changes to text-data when exporting to excel?

How to make 2 changes to text-data when exporting to excel?

mesqueebmesqueeb Posts: 38Questions: 12Answers: 1

Down below is my script to edit data before exporting to excel.
I tried adding a second change which I commented out. This is the one that bugs.
Is there any way to do both these changes to the data before exporting to excel?

I want to create newlines and then remove all remaining excel tags.

var fixNewLine = {
        exportOptions: {
            format: {
                body: function ( data, column, row ) {
                    // Strip $ from salary column to make it numeric
                    return column === 5 ?
                    data.replace( /<br\s*\/?>/ig, "\n"):
                        data;
//                        data.replace( /<.*?>/ig, ""):
//                        data;
                }
            }
        }
    };

Answers

  • cicjrcicjr Posts: 7Questions: 2Answers: 0

    I am facing same problem ...

  • F12MagicF12Magic Posts: 109Questions: 0Answers: 28

    An older question, but since someone is facing the same problem more recently...

    The javascript function replace allows chaining. So you can do the following:

    return column === 5 ?
        data.replace( /<br\s*\/?>/ig, "\n").replace( /<.*?>/ig, ""):
        data;
    
This discussion has been closed.