Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate office open XML excel file from javascript

Is there a way to generate an .xslx file from javascript and allow the user to download it by javascript? This page is geared towards being run offline in html 5 with no internet connectivity.

like image 453
Shawn Mclean Avatar asked Apr 30 '10 05:04

Shawn Mclean


People also ask

How do I create an XML file from Xlsx?

Click File > Save As, and select the location where you want to save the file. , point to the arrow next to Save As, and then click Other Formats. In the File name box, type a name for the XML data file. In the Save as type list, click XML Data, and click Save.

How do you get data from Excel using Javascript?

Javascript Excel - Import Data From ExcelThe Excel file is read into Uint8Array object, which is then passed to the load method exposed by the Excel library. Once the worksheet is loaded into the Excel library object, we can read each cell value and build a JSON array that will be used as the igGrid data source.


2 Answers

You could generate a data URI, and let the user save the link. However, IE8 has very limited support for data URIs. There is a 32 KB limit, and it's not allowed to be used with a href.

Also, you still need to find a actual XLSX JS library... But it is possible.

like image 183
Matthew Flaschen Avatar answered Oct 25 '22 02:10

Matthew Flaschen


It has been done successfully by Ed Spencer. This project is using an EXT DataGrid as the source of the data, but I'm sure you could adapt it pretty easily.

like image 39
Daniel Beardsley Avatar answered Oct 25 '22 01:10

Daniel Beardsley