Removing of unwanted line returns/breaks in a csv export in openUI5

Viewed 307

I'm learning OpenUI5 as part as my new job/internship and I've hit a snag in the product that I'm working on. The exported csv is correct as far as everything that we want is properly exported but if the string/input of an item contains a new line character or is ended with the enter key it breaks the csv export but the model within the table still displays correctly.

description.replace(/(\r\n|\n|\r)/gm," ");

Is what would work to remove any line returns or enters being found within the string but the way that data is bound within this application is within this type of structure:

    exportType : new sap.ui.core.util.ExportTypeCSV({
                    separatorChar : "," //;
                }),
                models : table.getModel(),
                rows : {
                    path : "/interactions"
                },
                columns : [  {
                    name : "description",
                    template : {
                        content : "{description}"
                    }
                }] // There is more listings after this but it's not important
 // ... more items here
            }); // End of the bounded data to export 

As stated previously, my item 'description' can contain new line characters but when I convert to to csv in the export, it will do something like this:

90000440,Information Protection Policy,Scene1_QuestionDraw01_Slide1_TrueFalse_0_0,The Information Security Officer is responsible for the review and revision of this policy.
(True or False),false,false,1,1

There isn't supposed to be an actual line return within the outputted csv but since there is a new line character or line return within the description, it outputs one in the export.

Any amount of help that leads to me solving this issue would be fantastic.

Thank you, Jordan.

1 Answers
Related