export-csv icon indicating copy to clipboard operation
export-csv copied to clipboard

Exporting to Excel gives an error when opening the file

Open oyvindwh opened this issue 8 years ago • 6 comments

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

oyvindwh avatar Jan 25 '17 15:01 oyvindwh

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.

TorsteinHonsi avatar Jan 26 '17 10:01 TorsteinHonsi

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.

BonsaiCode avatar May 11 '17 01:05 BonsaiCode

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.

TorsteinHonsi avatar May 12 '17 09:05 TorsteinHonsi

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.

BonsaiCode avatar May 12 '17 15:05 BonsaiCode

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/

TorsteinHonsi avatar May 15 '17 08:05 TorsteinHonsi

Great, xlsx works for me now! Thank you!

BonsaiCode avatar May 15 '17 11:05 BonsaiCode