Auto-sizing columns widths with minimum and maximum values

Topics: User Forum
Mar 13, 2010 at 5:42 PM
Edited Mar 13, 2010 at 6:30 PM

Hello,

I want achieve auto-sizing column widths but I want a minimum or a maximum value as column widths.
I tried this:

$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setAutoSize(true);
$width = $objPHPExcel->getActiveSheet()->getColumnDimension('A')->getWidth();
if($width>55)
   $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(55);
elseif($width<11)
   $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(11);

However it does not work. 

 

Developer
Mar 16, 2010 at 4:05 AM

I see what you mean. It will be a bit tricky to implement, but will copy to a work item so we can implement it in the future.

http://phpexcel.codeplex.com/WorkItem/View.aspx?WorkItemId=12085