一条记录= 1张桌子。 对于1条记录,格式正确。但是,对于> = 2条记录,表格列的宽度会增加(不确定多少,我没有看到任何模式)。 预期的输出是,在一次下载多个记录时,表格将放在另一个表格的下方。这符合,但是列宽对于多个记录来说是混乱的。 我没有任何错误。
PHP:
echo "<body>";
foreach( $data as $d ){
include('file2.php');
}
echo "</body>";
header("Content-type: application/x-msexcel;charset=UTF-8");
header("Content-Disposition: attachment; filename=" . $filename);
header("Pragma: no-cache");
header("Expires: 0");
file2.php (请忽略该课程,我已删除了.css样式)
<table border=0 cellpadding=0 cellspacing=0 width=718 style='border-collapse:
collapse; table-layout:fixed; width:553pt'>
<col width=18 style='mso-width-source:userset;width:14pt'>
<col width=20 style='mso-width-source:userset;width:15pt'>
<col width=18 span=17 style='mso-width-source:userset;
width:14pt'>
<col width=22 style='mso-width-source:userset;width:17pt'>
<col width=18 span=4 style='mso-width-source:userset;
width:14pt'>
<col width=22 style='mso-width-source:userset;width:17pt'>
<col width=18 span=2 style='mso-width-source:userset;
width:14pt'>
<col width=8 style='mso-width-source:userset;width:6pt'>
<col width=20 style='mso-width-source:userset;width:15pt'>
<!-- <col class=xl223 width=10 style='mso-width-source:userset;mso-width-alt:658;width-alt:20pt'> -->
<col class=xl170 width=18 style='mso-width-source:userset;
width:14pt'>
<col width=17 style='mso-width-source:userset;width:13pt'>
<col width=12 style='mso-width-source:userset;width:9pt'>
<col width=82 style='mso-width-source:userset;width:62pt'>
<col width=64 style='width:48pt'>
<!-- <col width=1 style='mso-width-source:userset;mso-width-alt:36;width:1pt'> -->
<tr height=12 style='mso-height-source:userset;height:9.0pt'>
<td height=12 width=18 style='height:9.0pt;width:14pt' align=left valign=top>
<![if !vml]><span style='mso-ignore:vglayout;
position:absolute;z-index:47;margin-left:5px;margin-top:0px;width:702px;
height:90px'><img width=702 height=90 src='<?php echo $hdr_image; ?>' v:shapes="Line_x0020_191 Rectangle_x0020_229 Rectangle_x0020_230 Rectangle_x0020_231 Picture_x0020_232 Rectangle_x0020_234 Rectangle_x0020_235 Rectangle_x0020_237 Rectangle_x0020_239 Text_x0020_Box_x0020_241 Text_x0020_Box_x0020_242"></span><![endif]>
<span
style='mso-ignore:vglayout2'>
<table cellpadding=0 cellspacing=0>
<tr>
<td height=12 class=xl69 width=18 style='height:9.0pt;width:14pt'></td>
</tr>
</table>
</span>
</td>
<td class=xl162 colspan=2 width=38 style='mso-ignore:colspan;width:29pt'>Column:</td>
<td class=xl70 width=18 style='width:14pt'></td>
<td class=xl70 width=18 style='width:14pt'></td>
<td class=xl70 width=18 style='width:14pt'></td>
<td class=xl70 width=18 style='width:14pt'></td>
<td class=xl70 width=18 style='width:14pt'></td>
<td class=xl70 width=18 style='width:14pt'></td>
<td class=xl70 width=18 style='width:14pt'></td>
<td class=xl70 width=18 style='width:14pt'></td>
<td class=xl70 width=18 style='width:14pt'></td>
<td class=xl70 width=18 style='width:14pt'></td>
<td class=xl70 width=18 style='width:14pt'></td>
<td class=xl70 width=18 style='width:14pt'></td>
<td class=xl70 width=18 style='width:14pt'></td>
<td class=xl71 width=18 style='width:14pt'></td>
<td class=xl70 width=18 style='width:14pt'></td>
<td class=xl70 width=18 style='width:14pt'></td>
<td class=xl70 width=22 style='width:17pt'></td>
<td class=xl70 width=18 style='width:14pt'></td>
<td class=xl70 width=18 style='width:14pt'></td>
<td class=xl70 width=18 style='width:14pt'></td>
<td class=xl70 width=18 style='width:14pt'></td>
<td class=xl70 width=22 style='width:17pt'></td>
<td class=xl70 width=18 style='width:14pt'></td>
<td class=xl70 width=18 style='width:14pt'></td>
<td class=xl70 width=8 style='width:6pt'></td>
<td class=xl70 width=20 style='width:15pt'></td>
<td class=xl164 width=18 style='width:14pt'></td>
<td class=xl70 width=17 style='width:13pt'></td>
<td class=xl70 width=12 style='width:9pt'></td>
<td class=xl70 width=82 style='width:62pt'></td>
<td class=xl70 width=64 style='width:48pt'></td>
<td class=xl70 width=64 style='width:48pt'></td>
<td width=1 style='width:1pt'></td>
</tr>
<tr height=17 style='height:12.75pt'>
<td height=17 class=xl143 style='height:12.75pt'> </td>
<td class=xl144> </td>
<td class=xl144> </td>
<td class=xl144> </td>
<td class=xl144> </td>
<td class=xl144> </td>
<td class=xl144> </td>
<td class=xl144> </td>
<td class=xl144> </td>
<td class=xl144> </td>
<td class=xl144> </td>
<td class=xl144> </td>
<td class=xl144> </td>
<td class=xl144> </td>
<td class=xl144> </td>
<td class=xl144> </td>
<td class=xl144> </td>
<td class=xl144> </td>
<td class=xl144> </td>
<td class=xl144> </td>
<td class=xl144> </td>
<td class=xl144> </td>
<td class=xl144> </td>
<td class=xl144> </td>
<td class=xl144> </td>
<td class=xl144> </td>
<td class=xl144> </td>
<td class=xl144> </td>
<td class=xl144> </td>
<td class=xl165> </td>
<td class=xl144> </td>
<td class=xl144> </td>
<td class=xl144> </td>
<td class=xl144> </td>
<td class=xl145> </td>
</tr>
<tr height=16 style='mso-height-source:userset;height:12.0pt'>
<td height=16 class=xl146 style='height:12.0pt'> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl166> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl148> </td>
<td></td>
</tr>
<tr height=16 style='mso-height-source:userset;height:12.0pt'>
<td height=16 class=xl146 style='height:12.0pt'> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl166> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl148> </td>
<td></td>
</tr>
<tr height=4 style='mso-height-source:userset;height:3.0pt'>
<td height=4 class=xl146 style='height:3.0pt'> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl166> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl148> </td>
<td></td>
</tr>
<tr height=22 style='mso-height-source:userset;height:16.5pt'>
<td height=22 class=xl149 style='height:16.5pt'> </td>
<td class=xl150> </td>
<td class=xl150> </td>
<td class=xl150> </td>
<td class=xl150> </td>
<td class=xl150> </td>
<td class=xl150> </td>
<td class=xl150> </td>
<td class=xl150> </td>
<td class=xl150> </td>
<td class=xl150> </td>
<td class=xl150> </td>
<td class=xl150> </td>
<td class=xl150> </td>
<td class=xl150> </td>
<td class=xl150> </td>
<td class=xl150> </td>
<td class=xl150> </td>
<td class=xl150> </td>
<td class=xl150> </td>
<td class=xl150> </td>
<td class=xl150> </td>
<td class=xl150> </td>
<td class=xl150> </td>
<td class=xl150> </td>
<td class=xl150> </td>
<td class=xl150> </td>
<td class=xl150> </td>
<td class=xl150> </td>
<td class=xl167> </td>
<td class=xl150> </td>
<td class=xl150><span></span></td>
<td class=xl150> </td>
<td class=xl150> </td>
<td class=xl148> .</td>
<!-- <td class=xl150> </td>
<td class=xl151> </td> -->
<td></td>
</tr>
<tr height=12 style='mso-height-source:userset;height:9.0pt'>
<td height=12 class=xl161 colspan=20 style='height:9.0pt;mso-ignore:colspan'>Sample text here</td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl166> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl147> </td>
<td class=xl260> </td>
<td></td>
</tr>
<tr class=xl101 height=11 style='mso-height-source:userset;height:3.0pt'>
<td class=xl258></td>
<td class=xl257></td>
<td class=xl257></td>
<td class=xl257></td>
<td class=xl257></td>
<td class=xl257></td>
<td class=xl257></td>
<td class=xl257></td>
<td class=xl257></td>
<td class=xl257></td>
<td class=xl257></td>
<td class=xl257></td>
<td class=xl257></td>
<td class=xl257></td>
<td class=xl257></td>
<td class=xl257></td>
<td class=xl257></td>
<td class=xl257></td>
<td class=xl257></td>
<td class=xl257></td>
<td class=xl257></td>
<td class=xl257></td>
<td class=xl257></td>
<td class=xl257></td>
<td class=xl257></td>
<td class=xl257></td>
<td class=xl257></td>
<td class=xl257></td>
<td class=xl257></td>
<td class=xl257></td>
<td class=xl257></td>
<td class=xl257></td>
<td class=xl257></td>
<td class=xl257></td>
<td class=xl259></td>
</tr>
<tr class=xl101 height=11 style='mso-height-source:userset;height:2.0pt'>
<td class=xl230></td>
<td class=xl235></td>
<td class=xl235></td>
<td class=xl235></td>
<td class=xl235></td>
<td class=xl235></td>
<td class=xl235></td>
<td class=xl235></td>
<td class=xl235></td>
<td class=xl235></td>
<td class=xl235></td>
<td class=xl235></td>
<td class=xl235></td>
<td class=xl235></td>
<td class=xl235></td>
<td class=xl235></td>
<td class=xl235></td>
<td class=xl235></td>
<td class=xl235></td>
<td class=xl237></td>
<td class=xl235></td>
<td class=xl235></td>
<td class=xl235></td>
<td class=xl235></td>
<td class=xl235></td>
<td class=xl235></td>
<td class=xl235></td>
<td class=xl235></td>
<td class=xl235></td>
<td class=xl235></td>
<td class=xl235></td>
<td class=xl235></td>
<td class=xl235></td>
<td class=xl235></td>
<td class=xl237></td>
</tr>
<![endif]>
</table>
答案 0 :(得分:0)
我不必使用多个<table></table>
标记,而只需在循环中使用<tbody></tbody>
并将它们包含在单个父表中。