How to export an HTML table as a .xlsx file

后端 未结 4 903
慢半拍i
慢半拍i 2020-12-03 15:37

I have a question about exporting an HTML table as an xlsx file. I did some work and now I can export it as an xls, but I

4条回答
  •  旧巷少年郎
    2020-12-03 16:10

    You won't be able to export it as XLSX without going back to the server. A XLSX file is a collection of XML files, zipped together. This means you do need to create multiple files. This is impossible to do with JS, client-side.

    Instead, you should create a function retrieving the data from your HTML table and send that to you server. The server can then create the XLSX file for you (there are a bunch of libs available for that!) and send it back to the client for download.

    If you expect to have a huge dataset, the XLSX creation on the server should be done as an async process, where you notify the user when it's done (instead of having the user waiting for the file to be created).

    Let us know which language you use on your server, and we'll be able to recommend you some good libraries.

提交回复
热议问题