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.
是否有一种方法可以从javascript生成.xslx文件并允许用户通过javascript下载?这个页面的目标是在没有internet连接的html 5中离线运行。
4 个解决方案
#1
1
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
.
您可以生成一个数据URI,并让用户保存链接。然而,IE8对数据uri的支持非常有限。有一个32 KB的限制,它不允许与href一起使用。
Also, you still need to find a actual XLSX JS library... But it is possible.
另外,您还需要找到一个实际的XLSX JS库…但这是可能的。
#2
1
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.
艾德·斯宾塞已经成功地做到了。这个项目使用EXT DataGrid作为数据的来源,但是我相信您可以很容易地适应它。
#3
0
As Javascript has no file I/O, it's not going to be easy for your users to download. However, this kind of work is perfectly suited for a simple PHP script, which could generate your XSLX and save to your server dynamically.
由于Javascript没有文件I/O,用户下载起来并不容易。但是,这种工作非常适合简单的PHP脚本,它可以生成XSLX并动态保存到服务器。
#4
0
You can generate any Office document with OpenXML SDK for Javascript http://openxmlsdkjs.codeplex.com/
您可以使用OpenXML SDK为Javascript http://openxmlsdkjs.codeplex.com/生成任何办公文档
As for allowing the user to save a file from JS I recommend FileSaver.js https://github.com/eligrey/FileSaver.js/
至于允许用户从JS中保存文件,我推荐文件共享。js https://github.com/eligrey/FileSaver.js/
#1
1
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
.
您可以生成一个数据URI,并让用户保存链接。然而,IE8对数据uri的支持非常有限。有一个32 KB的限制,它不允许与href一起使用。
Also, you still need to find a actual XLSX JS library... But it is possible.
另外,您还需要找到一个实际的XLSX JS库…但这是可能的。
#2
1
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.
艾德·斯宾塞已经成功地做到了。这个项目使用EXT DataGrid作为数据的来源,但是我相信您可以很容易地适应它。
#3
0
As Javascript has no file I/O, it's not going to be easy for your users to download. However, this kind of work is perfectly suited for a simple PHP script, which could generate your XSLX and save to your server dynamically.
由于Javascript没有文件I/O,用户下载起来并不容易。但是,这种工作非常适合简单的PHP脚本,它可以生成XSLX并动态保存到服务器。
#4
0
You can generate any Office document with OpenXML SDK for Javascript http://openxmlsdkjs.codeplex.com/
您可以使用OpenXML SDK为Javascript http://openxmlsdkjs.codeplex.com/生成任何办公文档
As for allowing the user to save a file from JS I recommend FileSaver.js https://github.com/eligrey/FileSaver.js/
至于允许用户从JS中保存文件,我推荐文件共享。js https://github.com/eligrey/FileSaver.js/