简体   繁体   English

有没有办法使用 jquery 将 append 数据转换为本地 excel 文件?

[英]Is there any way to append data into local excel file using jquery?

I have a web page that calculate data about specific thing, this page does not have a database to store data so i want to make an excel file on the server to store data in it when user click 'submit', the problem is that i want to create only one excel file and i want to append new data into this file, can i do that with javascript or jquery?我有一个 web 页面计算有关特定事物的数据,该页面没有存储数据的数据库,所以我想在服务器上创建一个 excel 文件以在用户单击“提交”时将数据存储在其中,问题是我只想创建一个 excel 文件,我想将 append 新数据放入此文件,我可以使用 javascript 或 ZD2283E143914865E 执行此操作吗?

EDIT: i prefer making an offline project.编辑:我更喜欢做一个离线项目。

The question is too broad, but for the scope of answering,这个问题太宽泛了,但是对于回答的 scope,

1) You could use Google Sheets API to store the value to a sheet in the google cloud. 1)您可以使用谷歌表格 API 将值存储到谷歌云中的表格中。 (Yes, you can use javascript for this) (是的,您可以为此使用 javascript)

2) You could create a node.js server and use javascript to write to csv or an excel file(research for npm modules based on your requirement) and expose it using a REST API for your application 2) You could create a node.js server and use javascript to write to csv or an excel file(research for npm modules based on your requirement) and expose it using a REST API for your application

Yes this is possible.是的,这是可能的。

Steps: 1. You can keep one excel sheet on the server, (example- test.csv).步骤: 1. 您可以在服务器上保留一张 excel 表,(example-test.csv)。 2. Every time you want to append some data to this excel sheet, you may copy data from test.csv into json format, append the new data into the json (array). 2. Every time you want to append some data to this excel sheet, you may copy data from test.csv into json format, append the new data into the json (array). 3. delete the test.csv from server. 3.从服务器中删除test.csv。 4. Use FILE APIs, to create a new csv file by the name test.csv with the data that was generated in json format in step 2. 4. 使用 FILE API,创建一个名为 test.csv 的新 csv 文件,其中包含在步骤 2 中以 json 格式生成的数据。

(This is independent of node/google sheets, can be used with just html, js, and also if your project is in php); (这与节点/谷歌表格无关,仅可与 html、js 以及如果您的项目在 php 中使用);

I have a working code for this somewhere in my backup, would try to provide a link here to it.我的备份中有一个工作代码,会尝试在此处提供一个链接。

Ps - This is probably my first answer here, please excuse for any issues. Ps - 这可能是我在这里的第一个答案,请原谅任何问题。

You will need to install node.js into your machine to do this locally.您需要将 node.js 安装到您的机器中才能在本地执行此操作。 ( https://nodejs.org/en/download/ ). https://nodejs.org/en/download/ )。 It would need a lot of security disables to allow file manipulation on the browser.它需要大量的安全禁用才能允许在浏览器上进行文件操作。

After, if your purpose is to only store data, than a CSV file would be easier and lighter (and you can open them with Excel).之后,如果您的目的是只存储数据,那么 CSV 文件会更容易和更轻(您可以使用 Excel 打开它们)。 Run npm search csv to check a lot of packages that you can use to work with CSV运行npm search csv以检查许多可用于 CSV 的包

If you really need and Excel file, you can install this package npm install exceljs .如果你真的需要 Excel 文件,你可以安装这个 package npm install exceljs And here is the docs for it https://github.com/exceljs/exceljs这是它的文档https://github.com/exceljs/exceljs

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM