XML : Set Excel (Xml) column width

I'm programmatically creating an Excel file with PHP. I struggling to set column width and row height, ss:Width="55.5" in the columns is just ignored!

This is how the finished file looks like:

  <Workbook>      <x:ExcelWorkbook>          <x:ActiveSheet>0</x:ActiveSheet>      </x:ExcelWorkbook>      <o:DocumentProperties>          <o:Title>Title</o:Title>          <o:Subject>Subject</o:Subject>          <o:Author>Author</o:Author>          <o:Keywords>keywords</o:Keywords>          <o:Category>Excel</o:Category>      </o:DocumentProperties>      <Styles>          <Style ss:ID="Default" ss:Name="Normal">              <ss:Alignment ss:Vertical="Bottom"/>              <ss:Font ss:Color="#000000" ss:FontName="Calibri" ss:Size="11"/>              <ss:NumberFormat/>              <ss:Protection ss:Protected="1" x:HideFormula="0"/>          </Style>          <Style ss:ID="S21">              <ss:Alignment ss:Vertical="Bottom" ss:WrapText="1"/>              <ss:Font ss:Color="#000000" ss:FontName="Calibri" ss:Size="11"/>              <ss:NumberFormat/>              <ss:Protection ss:Protected="1" x:HideFormula="0"/>          </Style>      </Styles>      <Worksheet ss:Name="Certificates">          <ss:Names/>          <ss:Table ss:DefaultRowHeight="17" ss:DefaultColumnWidth="120" ss:ExpandedRowCount="2" ss:ExpandedColumnCount="9">              <Column ss:Index="1" ss:AutoFitWidth="0" ss:Width="67.5"/>              <Column ss:Index="2" ss:AutoFitWidth="0" ss:Width="222.75"/>              <Column ss:Index="3" ss:AutoFitWidth="0" ss:Width="55.5"/>              <Column ss:Index="4" ss:AutoFitWidth="0" ss:Width="80.25"/>              <Column ss:Index="5" ss:AutoFitWidth="0" ss:Width="105"/>              <Column ss:Index="6" ss:AutoFitWidth="0" ss:Width="30.75"/>              <Column ss:Index="7" ss:Span="1" ss:AutoFitWidth="0" ss:Width="73.5"/>              <Column ss:Index="9" ss:AutoFitWidth="0" ss:Width="111"/>              <Row ss:Index="1">                  <Cell>                      <Data ss:Type="String">ID</Data>                  </Cell>                  <Cell>                      <Data ss:Type="String">Type</Data>                  </Cell>                  ...                  ...                  ...    

And the headers are

  header("Content-Type: application/vnd.ms-excel; charset=" . $this->encoding);  header('Content-Disposition: attachment; filename="test.xls"');  header('Expires: 0');  header('Cache-Control: must-revalidate, post-check=0,pre-check=0');  header('Pragma: public');    

I achieved everything I wanted style-wise, except width and less importantly, height

No comments:

Post a Comment