Un registro = 1 mesa. Para 1 registro, el formato es correcto. Sin embargo, para> = 2 registros, el ancho de la columna de la tabla aumenta (no estoy seguro de cuántos, no vi ningún patrón). El resultado esperado es que en una sola descarga para varios registros, las tablas se colocarán debajo de la otra en una sola hoja. Esto se cumple, pero los anchos de columna están desordenados para varios registros. No obtengo ningún error.

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 (ignore la clase, he eliminado el estilo .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'>&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>
1
herondale 12 ene. 2017 a las 10:43
Intente colocar todas las tablas en la tabla principal. <table id="parent_table"><tr><td><table id="table1">...</table></td></tr><tr><td><table id="table2">...</table></td></tr></table>
 – 
German Lashevich
12 ene. 2017 a las 12:28
Gracias, pero cuando los incluí en una tabla principal, el ancho de columna para un solo registro también se expandió
 – 
herondale
13 ene. 2017 a las 03:29

1 respuesta

La mejor respuesta

En lugar de usar varias etiquetas <table></table>, solo tuve que usar <tbody></tbody> dentro del ciclo y encerrarlas en una sola tabla principal.

0
herondale 13 ene. 2017 a las 05:18