将HTML导出到EXCEL,使用PHP& jQuery [英] Export HTML to EXCEL with PHP & jQuery

查看:501
本文介绍了将HTML导出到EXCEL,使用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:


  1. 点击导出按钮:调用jQuery

  2. 来自表的HTML / CSS

  3. 的纯HTML文档jQuery调用PHP函数/类( http://phpexcel.codeplex.com )从HTML代码重新格式化生成EXCEL文件

  4. 使用PHP发送的标头,浏览器要求用户保存/打开excel生成的文件

  1. click on export button: call to jQuery
  2. jQuery creates a pure HTML document from the HTML/CSS of the table
  3. jQuery calls a PHP function/class (http://phpexcel.codeplex.com maybe) to generate the EXCEL file from the HTML code reformatted
  4. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆