Php 在Excel中查看多个HTML表时无法设置TD宽度
您好,我为下载excel编写PHP标题 如果我有一个表,我可以使用宽度属性成功设置Php 在Excel中查看多个HTML表时无法设置TD宽度,php,html,css,excel,http-headers,Php,Html,Css,Excel,Http Headers,您好,我为下载excel编写PHP标题 如果我有一个表,我可以使用宽度属性成功设置的宽度 但是如果我有两张桌子,它就不工作了。我怎么办?因为我的excel页面文件中需要多个表 <?php header("Content-Type: application/vnd.ms-excel; charset=TIS-620"); header('Content-Disposition: attachment; filename="report_schedule_teacher.xls"');#ชื่
的宽度
但是如果我有两张桌子,它就不工作了。我怎么办?因为我的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>
当读取HTML文件时,Excel实际上只有一个HTML表。如果您查看Excel窗口,您将看到它实际上只是一个表。如果坚持分离数据(这与Excel没有区别),则可以使用多个表体:
<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>
<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>
你好
你好
世界1
世界2
如果有多个表,为什么不能设置宽度
不
库布
聚甲醛
输出:
顺便说一下,你在这里滥用MIME类型太多了!本文档不是
application/vnd.ms excel
或application/xhtml+xml
,而是text/html
,不应使用XLS扩展名保存。Excel可以读取HTML文件,但不能使HTML文件成为Excel文件 当您使用宽度时,您必须写入单位(px,%等)。仍然不工作。您到底想做什么?我想设置td的宽度,但在excel页面中,当我有多个表时,它会出现问题。您正在查找吗?所有表格都是独立的。更改宽度时,表格将更改宽度。