problem with setWidth for more than one column

Topics: Developer Forum, Project Management Forum, User Forum
Nov 25, 2009 at 11:22 AM
Edited Nov 25, 2009 at 1:53 PM

Hello, I`m trying to change column`s width, but in output document width  changing only  for  last column.. So, if I execute the code below, width will change only for column 'D', and another move to default width,even if in original document('order_org_3.xls') they had different width.

 

$objReader = new PHPExcel_Reader_Excel5();

$objPHPExcel = $objReader->load(ROOT.DS.'app'.DS.'webroot'.DS.'files'.DS.'invoices_templates'.DS.'order_org_3.xls');
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(5);
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(5);
/*$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(5);
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(5);
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(5);
$objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(5);
$objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(5);
$objPHPExcel->getActiveSheet()->getColumnDimension('H')->setWidth(5);
$objPHPExcel->getActiveSheet()->getColumnDimension('I')->setWidth(5);
$objPHPExcel->getActiveSheet()->getColumnDimension('J')->setWidth(5);*/
/*$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getColumnDimension('F')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getColumnDimension('G')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getColumnDimension('H')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getColumnDimension('I')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getColumnDimension('J')->setAutoSize(true);*/
//$objPHPExcel->getActiveSheet()->getColumnDimension('U')->setWidth(5);
//$objPHPExcel->getActiveSheet()->getColumnDimension('R')->setAutoSize(false);
//$objPHPExcel->getActiveSheet()->getColumnDimension('S')->setAutoSize(false);
//$objPHPExcel->getActiveSheet()->mergeCells('R1:S1');
//$objPHPExcel->getActiveSheet()->mergeCells('U1:V1');
//$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(25);
//$objPHPExcel->getActiveSheet()->getColumnDimension('H')->setWidth(15);
//$objPHPExcel->getActiveSheet()->getColumnDimension('L')->setWidth(20);
$objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);
print_r($objWriter);
$objWriter->setTempDir(ROOT.DS.'app'.DS.'webroot'.DS.'files'.DS.'invoices_xls'.DS.'temp');
$file_name='123412341341.xls';
//print_r(ROOT.DS.'app'.DS.'webroot'.DS.'files'.DS.'invoices_xls'.DS.$file_name);
$objWriter->save(ROOT.DS.'app'.DS.'webroot'.DS.'files'.DS.'invoices_xls'.DS.$file_name);

$objPHPExcel = $objReader->load('order_org_3.xls');

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

$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(5);

$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(5);

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

 

$objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);

$file_name='new.xls';

$objWriter->save($file_name);

 

 

Version PHPExcel - 1.6.3

Could you tell me wath`s wrong..

Thanks

Developer
Nov 27, 2009 at 3:31 AM

Can you try to upgrade PHPExcel to latest version?