Reputation: 609
I have looked for answer to other similar questions but couldn't see useful..
I have an html table generated with php from mysql db. I use this fragment in my php file to save as excel
$file="program.xls"; header('Content-Type: text/html'); $table = $_POST['tablehidden'];//i get this from another php file.It is HTML table header("Content-type: application/x-msexcel"); //tried adding charset='utf-8' into header header("Content-Disposition: attachment; filename=$file"); echo $table;
How can I solve the charset and styling problems? I have looked at phpexcel but couldn't see a method to include a table directly.
Upvotes: 2
Views: 11995
Reputation: 2935
I personally would use a PHP Excel generating class to make the Excel file. You can find a good one called PHPExcel here: http://phpexcel.codeplex.com/
Upvotes: 6