【发布时间】:2017-06-19 12:26:41
【问题描述】:
您好,我为下载 excel 编写 PHP 标头。
如果我有 1 个表格,我可以通过使用宽度属性成功设置 <td> 的宽度
但如果我有两张桌子,它就不起作用。我该怎么办?因为我的 excel 页面文件中需要多个表
<?php
header("Content-Type: application/vnd.ms-excel; charset=TIS-620");
header('Content-Disposition: attachment; filename="report_schedule_teacher.xls"');#ชื่อไฟล์
?>
<html>
<head>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=TIS-620" />
</head>
<body>
<table width="100%" style="border-collapse: collapse;overflow:wrap; font-size:9pt;">
<thead>
<tr>
<td width="300">Hello1</td>
<td width="400">Hello2</td>
</tr>
</thead>
<tbody>
<tr>
<td>World1</td>
<td>World2</td>
</tr>
</tbody>
</table>
<table width="100%" style="border-collapse: collapse;overflow:wrap; font-size:9pt;">
<thead>
<tr>
<td width="300">Why I cannot set width if I have multiple table</td>
<td width="400">Noooo</td>
</tr>
</thead>
<tbody>
<tr>
<td>kub</td>
<td>pom</td>
</tr>
</tbody>
</table>
</body>
</html>
【问题讨论】:
-
当你使用宽度时,你必须写单位(px、%等)。
-
还是不行..
-
你到底想做什么?
-
我想设置 td 的宽度,但是在 excel 页面中,当我有多个表格时会出现问题。
-
您在寻找
吗?所有表都是独立的。当你改变宽度表改变宽度。
标签: php html css excel http-headers