开发者

PHPExcel reading a cell's format

开发者 https://www.devze.com 2023-03-18 05:12 出处:网络
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

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开发者_如何学JAVA.

I am wondering if there is a method like getCellFormat or something that I can use.

Thanks for the help

Nick


if (PHPExcel_Shared_Date::isDateTime($objPHPExcel->getActiveSheet()->getCell('A1')))
   echo 'Cell Contains a Date';


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号