Reputation: 268
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
Upvotes: 10
Views: 45853
Reputation: 22349
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.
Upvotes: 16
Reputation: 832
<?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;
?>
Upvotes: 14