Detecting Formatting

Topics: User Forum
Apr 18, 2011 at 6:55 PM

Can PhpExcel detect if there is any formatting in a submitted excel file?

I gotta make sure that all cells are submitted in Text format (not date, number, etc)


Apr 18, 2011 at 8:30 PM

If you run from last version tests (1.7.3) you'll get a file saved, then

you can run 

$objPHPExcel = PHPExcel_IOFactory::load("05featuredemo.xlsx");$formt = $objPHPExcel->getActiveSheet()->getStyle('D1')->getNumberFormat();

echo 'Currency format:',$formt->getFormatCode(),'<br/>';

$formt = $objPHPExcel->getActiveSheet()->getStyle('B2')->getNumberFormat()->getFormatCode();

echo 'Currency format:',$formt;


The last line will print 'General'. Then you can use this to test whether is any formatting or not.

Apr 20, 2011 at 2:56 PM

Most cool, will try it out, many thanks :) :)