开发者

HTML table to excel - PHP

I am creating a report in Table format. This report is displayed on the browser. I want to provide a download report in excel format link so that the report can be available in excel file also. How can I开发者_开发技巧 do this


Either you can use CSV functions or PHPExcel Or there is even a better and a simple solution. Just put the Table HTML in a file and save it as XLS file but that might give variety of problems.


<?php
$file="test.xls";
$test="<table border=1><tr><td>Cell 1</td><td>Cell 2</td></tr></table>";
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=$file");
echo $test;
?>


I've used a service called DocRaptor which does awesome html to excel conversion. It also does html to pdf conversion.

If there are better solutions out there as far as retaining the look of your original html and css in Excel, I haven't seen them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜