Exception thrown with 'AutoSize method is set to approx'

Topics: Developer Forum, User Forum
Jan 21, 2010 at 11:48 PM

Hi there,

I just upgraded my phpExcel classes from 1.7.0 to 1.7.2 and now get the following exception thrown when writing an Excel5 document.

Fatal error:  Uncaught exception 'Exception' with message 'AutoSize method is set to approx' in \PHPExcel\Shared\Font.php:269

Stack trace:
#0 \PHPExcel\Worksheet.php(636): PHPExcel_Shared_Font::calculateColumnWidth(Object(PHPExcel_Style_Font), 'name', 0, Object(PHPExcel_Style_Font))
#1 \PHPExcel\Writer\Excel5\Worksheet.php(389): PHPExcel_Worksheet->calculateColumnWidths()
#2 \PHPExcel\Writer\Excel5.php(218): PHPExcel_Writer_Excel5_Worksheet->close()
#3 PHPExcel_Writer_Excel5->save('php://output')

Looking at the code indicates a solution, but only the exception is thrown. Reading the forum and bug tracker there seems to be some activity around setAutoSize(true), but nothing specific to my issue.

Each column in my document has the setAutoSize(true) method called, in this fashion;


Can I assume that by not setting setAutoSize would avoid the exception? Is there a better method to set auto sizing on all fields or is there a non-committed fix floating around that would "use approximation" instead of throwing this exception?

Many thanks, awesome product!!!

Stack trace:
#0 W:\www\v300\sonarSaaS\req\libs\phpexcel\PHPExcel\Worksheet.php(636): PHPExcel_Shared_Font::calculateColumnWidth(Object(PHPExcel_Style_Font), 'name', 0, Object(PHPExcel_Style_Font))
#1 W:\www\v300\sonarSaaS\req\libs\phpexcel\PHPExcel\Writer\Excel5\Worksheet.php(389): PHPExcel_Worksheet->calculateColumnWidths()
#2 W:\www\v300\sonarSaaS\req\libs\phpexcel\PHPExcel\Writer\Excel5.php(218): PHPExcel_Writer_Excel5_Worksheet->close()
#3 W:\www\v300\sonarSaaS\public\api.class.php(98): PHPExcel_Writer_Excel5->save('php://output')
#4 W:\www\v300\sonarSaaS\public\index.php(140): api->generate_response()
Jan 22, 2010 at 5:07 AM

There seems to be a bug in eAccelerator where an exception does not get caught under certain circumstances.

Are you using eAccelerator?

Jan 24, 2010 at 9:05 PM

Hi Koyama,

Awesome, I'm using Uniform Server for development and this was running with eAccelerator... I turned it off in php.ini and the updated scripts ran perfectly.

Thanks for all your hard work!!!