Set Widths of Columns

$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);

$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(12);

Example:

//Can't use column index
$column_codes = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H');
foreach($column_codes as $value){
	$worksheet->getColumnDimension($value)->setAutoSize(true);
}

 

One thought on “Set Widths of Columns

Comments are closed.