I am trying to format the cell widths of a document that I am creating with PHPExcel, yet when I use the getColumnDimension('A')->setWidth(7) method, it is not being produced accurately in the generated xlsx file.
I formatted the document in Excel so that I could find the values of the cells that I want and I get two values, one in Excel Units and the other in Inches.
For example:
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth('7');
will end up giving me a column width of 6.17 instead of 7. I have already tried using both strings and int values for, nothing changes. Any ideas?
Best Answer
This is because MS Excel adjusts the figure itself to its own internal units: there's a whole section in the developer documentation (section 4.6.28, entitled "Setting a column’s width") that explains this.
Quoting from the sidebar in that section:
(my emphasis in bold)