PHPExcel getFormatCode Error

I am using PHPExcel to read data from Excel. This does not give me the correct cell number format, even if I set it as the date format ("YYYY-MM-DD"). The code I use

$reader = new PHPExcel_Reader_Excel5(); $reader->setReadDataOnly(true); $PHPExcel = $reader->load($file ); $format = $PHPExcel->getActiveSheet()->getStyle('A1')->getNumberFormat()->getFormatCode(); var_dump($format); 

I always get a general. I do not know which column will be the date format, so the part should be programmatic.

thanks

+4
source share
1 answer
 reader->setReadDataOnly(true); 

means reading only the source data from the cells: do not read formatting information

If you do

 reader->setReadDataOnly(false); 

then PHPExcel will also read formatting

+2
source

All Articles