Search code examples
excelangular-ui-grid

export data with chinese to CSV


I am trying to export data containing chinese(some non-english characters for that matter) from ui-grid to pdf or CSV. However the exported text is all garbled. Here is the plnkr link

http://plnkr.co/edit/ZR34lhm3LUNmUrj7Vg23?p=preview

I understand for the pdf export to work I need to have the correct cmap for the font and characterset in use but why is CSV export not working? I have even tried exporterOlderExcelCompatibility: false but that didn't help either.

enter image description here


Solution

  • The issue you are facing with the CSV is most likely due to opening this in Excel. I do not face the issue with OpenOffice.

    For Excel 2013, these steps should work:

    1. Launch Excel, and go to the Data tab.
    2. Click the From Text button.
    3. Navigate to the exported file, and click open.
    4. Set the encoding to UTF-8 if it wasn't auto-selected.
    5. Click Next.
    6. Change the delimeter to comma.
    7. Click Finish.
    8. Choose where you want the input, or just click OK.

    At this point, you should have the CSV displaying correctly.

    With the CSV exporter, CSV-JS, I do not see any options to set the encoding before hand.