PHPExcel sets column width

I set the column width for a CSV file using

  $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(50);

But I do not see changes in the width of column A, what am I doing wrong?

+5
source share
2 answers

Assuming you are using CSV Writer.

CSV files do not support any formatting , just data, so the column width (which is formatting) cannot be applied when writing a CSV file

+8
source

Disable autoizeize first:

$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setAutoSize(false);

Now you can install:

$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth("50");
+6
source

All Articles