We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Csv Export use CRLF instead of LF

Is there a way to get the CSV export in the react grid to use CRLF (\r) instead of just (LF) for new lines


7 Replies

VB Vinitha Balasubramanian Syncfusion Team November 17, 2022 12:16 PM

Hi Jonathan,


Greetings from Syncfusion support


Currently, we are validating your reported problem with your shared information, and we will update you the details shortly. Until then we appreciate your patience.


Regards,

Vinitha Balasubramanian



VB Vinitha Balasubramanian Syncfusion Team November 18, 2022 08:33 AM

From your query, we understood that you want to use “CRLF” (\r) instead of using “LF” () on CSV exporting. We have prepared a sample and achieved your requirement by using excelQueryCellInfo event of Grid. Inside this event you can customize the column values as per your requirement. Please refer the below code and sample for your reference.


[index.js]

excelQueryCellInfo(args) {

 

if (args.column.field === 'ShipCity') {

      var split = args.value.split(' ');

      var newString = '';

      for (var i = 0; i < split.length; i++) {

        newString += '\r' + split[i];

      }

      args.value = newString;

    }

  }


Sample : https://stackblitz.com/edit/react-x9xweb-cfkfmb?file=index.js


API : https://ej2.syncfusion.com/react/documentation/api/grid/#excelquerycellinfo



JD Jonathan De Wet November 20, 2022 07:13 PM

Hi Vinitha,

Thanks for your reply. Unfortunately, I think there was a misunderstanding about what I wanted. 

Currently, when you click CSV export you get something like this

But I want this


I want to change the line endings of each row of the csv not change the newline format of multiline strings inside a csv


Is there a way to do this?





PS Pavithra Subramaniyam Syncfusion Team November 22, 2022 07:13 AM

Hi Jonathan,


To validate further could you please share the below details which will be helpful for us to check the feasibility of your requirement.


  1. Are you using any Localization in your sample?
  2. If yes, please share the code example.




JD Jonathan De Wet November 22, 2022 04:08 PM

Hi Pavithra,


We are not using any localization



JD Jonathan De Wet November 23, 2022 03:53 PM

Any update on this? I got an email today about an ASP.net control bug that sounded similar. But my problem is with the react component. 




VB Vinitha Balasubramanian Syncfusion Team November 25, 2022 07:29 AM

We have confirmed and logged this as a bug in the component. So, we have considered ”Modify to \r as line separators in Grid to CSV export” as a defect and logged a report for the same. We will include the defect fix in our upcoming patch release, which is expected to be rolled out on Dec 07th, 2022,.


You can now track the status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.


Feedback link : https://www.syncfusion.com/feedback/39329/modify-n-to-r-n-as-line-separators-in-grid-to-csv-export


Disclaimer: Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization.


Loader.
Live Chat Icon For mobile
Up arrow icon