Reputation: 125
I am having trouble finding out how to read a cells format. I need to know if a cell's format is a date or not because when I read it into PHP it becomes a 5 digit number from excel. I know I can take this number and then use PHPExcel to convert it into a PHP date but I first need to know that the cell I am reading is in fact a date cell.
I am wondering if there is a method like getCellFormat or something that I can use.
Thanks for the help
Nick
Upvotes: 3
Views: 8540
Reputation: 212402
if (PHPExcel_Shared_Date::isDateTime($objPHPExcel->getActiveSheet()->getCell('A1')))
echo 'Cell Contains a Date';
Upvotes: 1
Reputation: 1554
You'll want the format code, presumably:
$objPHPExcel->getActiveSheet()->getStyle('A1')->getNumberFormat()->getFormatCode();
You can compare this to the PHPExcel_Style_NumberFormat
constants, or some of your own regexes.
Upvotes: 1