Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何将多个HTML表格导出到excel文件?_Php_Html_Excel - Fatal编程技术网

Php 如何将多个HTML表格导出到excel文件?

Php 如何将多个HTML表格导出到excel文件?,php,html,excel,Php,Html,Excel,一条记录=一个表。 对于1条记录,格式正确。但是,对于>=2条记录,表列的宽度会增加(不确定增加了多少,我没有看到任何模式)。 预期的结果是,在多条记录的一次下载中,这些表将在一张表中一个接一个地放在下面。这是可以满足的,但是多条记录的列宽被弄乱了。 我没有发现任何错误 PHP: echo”“; foreach($d数据){ 包括('file2.php'); } 回声“; 标题(“内容类型:应用程序/x-msexcel;字符集=UTF-8”); 标题(“内容处置:附件;文件名=”.$filena

一条记录=一个表。 对于1条记录,格式正确。但是,对于>=2条记录,表列的宽度会增加(不确定增加了多少,我没有看到任何模式)。 预期的结果是,在多条记录的一次下载中,这些表将在一张表中一个接一个地放在下面。这是可以满足的,但是多条记录的列宽被弄乱了。 我没有发现任何错误

PHP:

echo”“;
foreach($d数据){
包括('file2.php');
}
回声“;
标题(“内容类型:应用程序/x-msexcel;字符集=UTF-8”);
标题(“内容处置:附件;文件名=”.$filename);
标题(“杂注:无缓存”);
标题(“到期日:0”);
file2.php(请忽略该类,我已经删除了.css样式)


'v:shapes=“Line_x0020_191rectangle_x0020_229;Rectangle_x0020_230rectangle_x0020_231;Picture_x0020_232rectangle_x0020_234rectangle_x0020_235rectangle_x0020_237rectangle_x0020_239text_x0020_0020_241text_x0020_242”>
专栏:
.
这里是示例文本

我不需要使用多个
标记,我只需要在循环中使用
并将它们括在一个父表中。

我不需要使用多个
标记,而只需要在循环中使用
并将它们括在一个父表中。

尝试将所有表都放在父表中
..…
@GermanLashevich谢谢,但当我将它们包含在父表中时,单个记录的列宽也已扩展,尝试将所有表都放在父表中
..…
@GermanLashevich谢谢,但当我将它们包含在父表中时,单个记录的列宽也扩大了
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");
<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'>&nbsp;</td>
  <td class=xl144>&nbsp;</td>
  <td class=xl144>&nbsp;</td>
  <td class=xl144>&nbsp;</td>
  <td class=xl144>&nbsp;</td>
  <td class=xl144>&nbsp;</td>
  <td class=xl144>&nbsp;</td>
  <td class=xl144>&nbsp;</td>
  <td class=xl144>&nbsp;</td>
  <td class=xl144>&nbsp;</td>
  <td class=xl144>&nbsp;</td>
  <td class=xl144>&nbsp;</td>
  <td class=xl144>&nbsp;</td>
  <td class=xl144>&nbsp;</td>
  <td class=xl144>&nbsp;</td>
  <td class=xl144>&nbsp;</td>
  <td class=xl144>&nbsp;</td>
  <td class=xl144>&nbsp;</td>
  <td class=xl144>&nbsp;</td>
  <td class=xl144>&nbsp;</td>
  <td class=xl144>&nbsp;</td>
  <td class=xl144>&nbsp;</td>
  <td class=xl144>&nbsp;</td>
  <td class=xl144>&nbsp;</td>
  <td class=xl144>&nbsp;</td>
  <td class=xl144>&nbsp;</td>
  <td class=xl144>&nbsp;</td>
  <td class=xl144>&nbsp;</td>
  <td class=xl144>&nbsp;</td>
  <td class=xl165>&nbsp;</td>
  <td class=xl144>&nbsp;</td>
  <td class=xl144>&nbsp;</td>
  <td class=xl144>&nbsp;</td>
  <td class=xl144>&nbsp;</td>
  <td class=xl145>&nbsp;</td>
 </tr>
 <tr height=16 style='mso-height-source:userset;height:12.0pt'>
  <td height=16 class=xl146 style='height:12.0pt'>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl166>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl148>&nbsp;</td>
  <td></td>
 </tr>
 <tr height=16 style='mso-height-source:userset;height:12.0pt'>
  <td height=16 class=xl146 style='height:12.0pt'>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl166>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl148>&nbsp;</td>
  <td></td>
 </tr>
 <tr height=4 style='mso-height-source:userset;height:3.0pt'>
  <td height=4 class=xl146 style='height:3.0pt'>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl166>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl148>&nbsp;</td>
  <td></td>
 </tr>
 <tr height=22 style='mso-height-source:userset;height:16.5pt'>
  <td height=22 class=xl149 style='height:16.5pt'>&nbsp;</td>
  <td class=xl150>&nbsp;</td>
  <td class=xl150>&nbsp;</td>
  <td class=xl150>&nbsp;</td>
  <td class=xl150>&nbsp;</td>
  <td class=xl150>&nbsp;</td>
  <td class=xl150>&nbsp;</td>
  <td class=xl150>&nbsp;</td>
  <td class=xl150>&nbsp;</td>
  <td class=xl150>&nbsp;</td>
  <td class=xl150>&nbsp;</td>
  <td class=xl150>&nbsp;</td>
  <td class=xl150>&nbsp;</td>
  <td class=xl150>&nbsp;</td>
  <td class=xl150>&nbsp;</td>
  <td class=xl150>&nbsp;</td>
  <td class=xl150>&nbsp;</td>
  <td class=xl150>&nbsp;</td>
  <td class=xl150>&nbsp;</td>
  <td class=xl150>&nbsp;</td>
  <td class=xl150>&nbsp;</td>
  <td class=xl150>&nbsp;</td>
  <td class=xl150>&nbsp;</td>
  <td class=xl150>&nbsp;</td>
  <td class=xl150>&nbsp;</td>
  <td class=xl150>&nbsp;</td>
  <td class=xl150>&nbsp;</td>
  <td class=xl150>&nbsp;</td>
  <td class=xl150>&nbsp;</td>
  <td class=xl167>&nbsp;</td>
  <td class=xl150>&nbsp;</td>
  <td class=xl150><span></span></td>
  <td class=xl150>&nbsp;</td>
  <td class=xl150>&nbsp;</td>
  <td class=xl148>&nbsp;.</td>
  <!-- <td class=xl150>&nbsp;</td>
  <td class=xl151>&nbsp;</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>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl166>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl147>&nbsp;</td>
  <td class=xl260>&nbsp;</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>