Despite the COVID-19 outbreak, our team continues operating at full speed. We are always here to support and answer all your questions.

Feel free to reach out by filling this quick form.

Fill the form
Get Free Trial

CSV export, newlines

Answered
Patrick Berens asked on August 25, 2020

Hi ya Support,
 
We have been using csv export from within the tool and it has been working fine. However, if a field contains newlines the csv exports one row as two rows. It seems they aren’t being properly escaped? We manually created the csv’s and it appears to work fine with our csv writer.
 
This is affecting our new client’s reports quite a bit as they need to export fields with large amounts of text.
We are currently using Flexmonster 2.8.11 and we are returning data to Flexmonster in JSON format with an explicit header with types.
 
Thanks,
Patrick

6 answers

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster August 26, 2020

Hello,
 
Thank you for reporting the problem.
 
The fix for the issue is going to be provided with a minor release ETA Sep 21. Members containing the newline symbol are going to be enclosed with quotes after the mentioned release.
Our team will notify you as soon as the version with a fix is available to download.
 
As a temporary workaround, we suggest using the alwaysEnclose parameter of the exportTo API call. It indicates whether to enclose all CSV fields in quotes. When set to true, the fields are always enclosed in quotes. It is likely to resolve the problem until the fix is provided.
 
Please let us know whether the workaround works for you.
We are looking forward to hearing from you.
 
Kind regards,
Illia

Public
Patrick Berens August 26, 2020

Thank you. Is it possible to set the alwaysEnclose parameter in the Flexmonster options so that the export csv button will always be true?
 
Thanks,
Patrick

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster August 26, 2020

Hello, Patrick,
 
Thank you for your question.
 
The desired result can be achieved by customizing the Toolbar.
Please see the following code snippet for the reference:

function customizeToolbar(toolbar) {
  var tabs = toolbar.getTabs();
  console.log(tabs);
  toolbar.getTabs = function() {
    tabs[3]["menu"][2].handler = () => {
      flexmonster.exportTo("csv", {
        alwaysEnclose: true
      });
    }
    return tabs;
  }
}

It shows the way to override the handler of the corresponding “Export to CSV” button.
 
Also, we have prepared an example demonstrating such functionality.
 
Please let us know if it works for your case.
Our team is looking forward to hearing from you.
 
Best regards,
Illia

Public
Zachary Falkner August 26, 2020

Hi Illia,
This worked perfectly for us, thank you!
Zac

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster September 22, 2020

Hello,
 
We are glad to inform you that the issue with the newline character and CSV export was fixed.
 
This is provided in the 2.8.16 version of Flexmonster.
 
You are welcome to update the component.
Here is our updating to the latest version tutorial for guidance.
 
Please let us know if it works for you.
 
Best regards,
Illia

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster September 29, 2020

Hello,
 
Our team is wondering whether the fix of the CSV export works for you.
 
We are looking forward to hearing your feedback.
 
Best regards,
Illia

Please login or Register to Submit Answer