将HTML导出到EXCEL,使用PHP& jQuery [英] Export HTML to EXCEL with PHP & jQuery
问题描述
我想导出一个HTML 表
到MS Excel文档(和PDF理想),因为它显示在HTML / CSS页面。我读了很多页面和主题(在堆栈主要),但每个人似乎都在谈论导出表,而不是格式化最终的excel文件。
I would like to export an HTML table
to a MS Excel document (and PDF ideally) as it is displayed on the HTML/CSS page. I read a lot of pages and topics about it (on stack mainly) but everyone seemed to be talking about exporting the table, and not formatting the final excel file.
我认为它应该工作如下:
I think it should work like this:
- 点击导出按钮:调用jQuery
- 来自
表的HTML / CSS
- 的纯HTML文档jQuery调用PHP函数/类( http://phpexcel.codeplex.com )从HTML代码重新格式化生成EXCEL文件
- 使用PHP发送的标头,浏览器要求用户保存/打开excel生成的文件
- click on export button: call to jQuery
- jQuery creates a pure HTML document from the HTML/CSS of the
table
- jQuery calls a PHP function/class (http://phpexcel.codeplex.com maybe) to generate the EXCEL file from the HTML code reformatted
- With the headers sent by PHP, the browser asks the user to save/open the excel generated file
如果是这样,你知道任何jQuery插件和PHP类/函数这样做吗?如果没有,你的想法是什么?
编辑:感谢马特,我来到使用XLS文件模板的想法,是可能吗?它将避免我所有的格式化,因为它会在模板文件中完成。可能吗?
Would this work? If so do you know any jQuery plugins and PHP classes/functions to do so? If not, what is your ideas about it?
Thanks to Matt, I came to the idea of using an XLS file template, is it possible? It will avoid me all the formatting as it would be done in the template file. Is it possible?
干杯,
Nicolas。
Cheers,
Nicolas.
推荐答案
我最后选择重做所有的格式化与PHPexcel。缺点是如果我改变HTML中渲染的东西,我必须在我创建的PHPexcel帮助中做同样的事情,反之亦然。
I finally choose to redo all the formatting with PHPexcel. The drawback is that if I change something in the HTML rendered I have to do the same in the PHPexcel helper I've created and vice versa.
感谢大家的建议。
Nicolas。
Thank you for your suggestion everyone.
Nicolas.
这篇关于将HTML导出到EXCEL,使用PHP& jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!