Can auto resize font size and keep column widths,row height

Topics: Developer Forum, Project Management Forum, User Forum
Sep 11, 2008 at 9:01 AM

   Can resize font size and keep column widths, row height
Developer
Sep 11, 2008 at 5:16 PM
Not sure exactly what you mean. Can you post some example that shows what you are trying?
Sep 18, 2008 at 7:14 AM
1. usually I set font size at No. 10
2. When there are a lot of characters, I hope it can    automatically adjust to smaller font size
    while keeping the same column width and row height.
Developer
Sep 18, 2008 at 12:21 PM
In MS Office Excel you do this as follows:

Format Cells > Alignment > Shrink to fit (checkbox)

In PHPExcel the corresponding method is:

$worksheet->getStyle('A1')->getAlignment()->setShrinkToFit(true);
Feb 18, 2010 at 4:28 AM

In Reference to Threads:

why setAutoSize(true) does not work ? 
 
setAutoSize not working as intended? 

And this.

I've been trying to get either setShrinkToFit(true) or setAutoSize(true) to work without any success. I am using svn-39887 at the moment.

Most Recent Attempt code sample:

 

	$objPHPExcel->getActiveSheet()->getStyle(GetExcelColumn($colNum). 3)->getAlignment()->setShrinkToFit(true);
Where GetExcelColumn is a function to get the correct 1-indexed column letter.

What am I doing wrong here? 

 

Developer
Feb 18, 2010 at 9:10 PM

Check this post for a full example demonstrating shrink-to-fit:

http://phpexcel.codeplex.com/Thread/View.aspx?ThreadId=29882#Post238294