我已经使用 html 和 php 生成了 xls 文件,一切都很好。但问题是,当试图打开文件时,会显示以下错误
我的代码在这里:
$filename = "file.xls";
header("Content-Type: application/vnd.ms-excel; charset=utf-8");
header("Content-type: application/x-msexcel; charset=utf-8");
header("Content-Disposition: attachment;filename=".$filename); //tell browser what's the file name
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: max-age=0");
echo '<table>
<tr>
<th>heading1</th>
<th>heading2</th>
<th>heading3</th>
</tr>
<tr>
<td>data1</td>
<td>data2</td>
<td>data3</td>
</tr>
</table>';