4
votes

I am using PHPExcel to read data from Excel. It is not giving me proper cell number format even though I set it as date ('YYYY-MM-DD') format. 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 General. I don't know which column is going to be date format, so that part needs to be programmatically.

Thanks

1

1 Answers

2
votes
reader->setReadDataOnly(true);

means read only the raw data from the cells: don't read any of the formatting information

If you do

reader->setReadDataOnly(false);

then PHPExcel will read the formatting as well