简体   繁体   English

尝试不使用jQuery将数据导出到Excel文件

[英]Trying to export data to excel file without jquery

Im trying to export the data i have into an excel file without jquery. 我正在尝试将没有jQuery的数据导出到Excel文件中。 I've read you can use javascript but most example have jquery. 我读过您可以使用javascript,但大多数示例都使用jquery。 The reason i don't want to use jquery is that the project is build with react. 我不想使用jquery的原因是该项目是用react构建的。

I already have the data from the database, so i don't need to bring it again. 我已经从数据库中获取了数据,因此无需再次携带。 I want to take that data and make it into an excel file. 我想将这些数据放入Excel文件中。 little bit of the code below. 下面的代码一点。

<li className='col-md-3 col-height col-middle'>
<span>{fromTime}</span> //contains data
</li>

Some example use table, is it possible to export from 一些示例使用表,是否可以从中导出

<div>
<li>
<span>

Would appreciate any tips, example or anything 将不胜感激任何提示,示例或任何内容

The most common way to export data into excel would be to covert it into a csv (comma seperated values) file which can then be opened in excel. 将数据导出到excel的最常见方法是将其隐藏到一个csv(逗号分隔值)文件中,然后可以在excel中打开该文件。 There are plenty of tutorials on how to do this, there are many different ways with a simple google. 有很多关于如何执行此操作的教程,一个简单的google有很多不同的方法。 In your case doing this in php will likely be best because your getting it from a database. 在您的情况下,最好在php中执行此操作,因为您是从数据库中获取的。

SheetJS seems perfect for this. SheetJS似乎很完美。

To export your table as an excel file use the code in this link(along with SheetJS) 要将表格导出为ex​​cel文件,请使用此链接中的代码(以及SheetJS)

Just plug in your table element's id into export_table_to_excel 只需将表元素的ID插入export_table_to_excel

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

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