highcharts / export-csv

Highcharts plugin to export chart data to CSV
http://www.highcharts.com/plugin-registry/single/7/Export-CSV
MIT License
76 stars 95 forks source link

Exporting to Excel gives an error when opening the file #117

Open oyvindwh opened 7 years ago

oyvindwh commented 7 years ago

When downloading to excel from the module, I get an error when opening the file. If I choose to accept the content of the file is correct. Can I change/update the script to remove the error message?

2017-01-25_16-13-26

TorsteinHonsi commented 7 years ago

If I remember correctly we haven't found a way to work around this issue. The contents of the file is a HTML table, but Excel interprets it correctly nonetheless.

BonsaiCode commented 7 years ago

Its quite involved to generate real Excel data. It would probably be best to integrate with a 3rd party javascript lib, e.g. https://www.travismclarke.com/tableexport/ (that's just one I found from google) Not sure how difficult it would be to integrate.

TorsteinHonsi commented 7 years ago

Here's a proof of concept of using TableExport: http://jsfiddle.net/highcharts/hr7jLwda/

Does the produced Excel file look good to you?

If this is working, we can consider providing a hook for it in the export-csv plugin (which will soon become an integrated Highcharts module). We can plug it into our own file download functionality so we won't depend on FileSaver.js.

BonsaiCode commented 7 years ago

I'm still getting the error, BUT I am using a newer version of Excel which is looking for xlsx type. it should work for older versions of Excel that are expecting xls.

I have updated the example here for xlsx: http://jsfiddle.net/ahdavis/hr7jLwda/3/ I added the xlsx.core.js include at the top and changed the format to xlsx on line 9. However, highcharts is still sending an extension of xls instead of xlsx. I think if this could be changed, then it would work for xlsx, and then you would need an additional Download XLSX option.

TorsteinHonsi commented 7 years ago

Thanks for contributing - the path to core.xlsx.js was wrong, but once fixing that, the extension also became correct. I added a separate menu item for XLSX: http://jsfiddle.net/highcharts/hr7jLwda/

BonsaiCode commented 7 years ago

Great, xlsx works for me now! Thank you!