html表用PHP优秀

gen*_*cay 2 php export-to-excel

我已经找到了其他类似问题的答案,但看不到有用的..

我有一个用mysql db生成的html表.我在我的php文件中使用这个片段保存为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;
  1. 直到这个时候一切都好.但是当我保存这个我得到字符问题并试图将 charset ='utf-8'添加到我的标题中时,我不知道但它不起作用.
  2. 我的表格有HTML风格但是当涉及到excel时,它失去了用css实现的风格.

如何解决字符集和样式问题?我看过phpexcel但看不到直接包含表的方法.

Ant*_*eco 6

我个人会使用PHP Excel生成类来制作Excel文件.你可以在这里找到一个名为PHPExcel的好文章:http://phpexcel.codeplex.com/

  • 这就是我的意思.获取数据并根据需要将其重新写入Excel表.你将拥有最多的控制权 (2认同)