javascript 在javascript中将数组导出到excel xlsx

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32099119/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 14:51:12  来源:igfitidea点击:

Export array to excel xlsx in javascript

javascriptjqueryarraysexport-to-excelxlsx

提问by Atiq Shaikh

There is one requirement in javascript to export the data (array or array of objects) to excel xlsx. I already exported the data to csv but unable to do same for xlsx. I tried many api from github so that I can used the libraries and export it to xslx but there are little help for it. I tried using stephen-hardy/xlsx.js, SheetJS/js-xlsx etc.

javascript 中有一项要求将数据(数组或对象数组)导出到 excel xlsx。我已经将数据导出到 csv,但无法为 xlsx 做同样的事情。我尝试了来自 github 的许多 api,以便我可以使用这些库并将其导出到 xslx,但对此几乎没有帮助。我尝试使用 stephen-hardy/xlsx.js、SheetJS/js-xlsx 等。

For exporting to csv I used this Click here! but the same cant be done for xlsx.

为了导出到 csv,我使用了这个点击这里!但是对于 xlsx 则不能做同样的事情。

I tried xlsxwriter also to convert and write javascript array or array of object to xlsx but no result.

我也尝试过 xlsxwriter 将 javascript 数组或对象数组转换和写入 xlsx 但没有结果。

Now I m badly stuck because of the requirement. I also found out the similar post as of mine requirement Click here!

现在我因为要求而陷入困境。我还发现了与我的要求类似的帖子点击这里

Please guys give me solution if any

请大家给我解决方案,如果有的话

回答by Mike Gledhill

A while ago, I wrote the following article, which described how to export data from a jqGridto a "real" .xlsx file:

不久前,我写了以下文章,其中描述了如何将数据从 a 导出jqGrid到“真实的”.xlsx 文件:

Export jqGrid to Excel

将 jqGrid 导出到 Excel

This basically cached the jqGrid's data into a JavaScript variable, posted it back to a server, to save into Excel. The Excel file is created using the OpenXML libraries.

这基本上将 jqGrid 的数据缓存到一个 JavaScript 变量中,将其发送回服务器,以保存到 Excel 中。Excel 文件是使用 OpenXML 库创建的。

This should point you in the right direction.

这应该为您指明正确的方向。

Alternatively, you might like to try this library:

或者,您可能想尝试这个库:

AlaSQL

阿拉SQL

(I haven't tried this though.)

(不过这个我没试过。)

回答by user3902443

Try excelbuilderjs, I have done the same of downloading a Json Object with array of items into an excel sheet using this library.If you can please share the code on Jsfiddle, i can take a look at it and help you out

试试 excelbuilderjs,我已经做了同样的事情,使用这个库将一个带有项目数组的 Json 对象下载到一个 excel 表中。如果你可以请在 Jsfiddle 上分享代码,我可以看看它并帮助你

http://excelbuilderjs.com/

http://excelbuilderjs.com/