The example in this article describes the method of reading file date using thinkPHP+PHPExcel. Share it with everyone for your reference, the details are as follows:
We used PHPExcel to read the excel file and found that the time is similar to this number: 41890.620138889, so how to process it into what we want 2014-09-08 14: For a date in the format of 53:00, look at the code:
Vendor('PHPExcel.PHPExcel.IOFactory'); $inputFileName = 'Public/demo/demo.xls'; $objReader = new PHPExcel_Reader_Excel5(); $objPHPExcel = $objReader->load($inputFileName); $sheet = $objPHPExcel->getSheet(0); $highestRow = $sheet->getHighestRow(); // 取得总行数 $highestColumn = $sheet->getHighestColumn(); // 取得总列数 $tempArray = array(); for($j=2;$j<=$highestRow;$j++){ for($k='A';$k<=$highestColumn;$k++){ if($k=='H'){//指定H列为时间所在列 $tempArray[] = gmdate("Y-m-d H:i:s", PHPExcel_Shared_Date::ExcelToPHP($objPHPExcel->getActiveSheet()->getCell("$k$j")->getValue())); }else{ $tempArray[] = $objPHPExcel->getActiveSheet()->getCell("$k$j")->getValue(); } echo "<pre class="brush:php;toolbar:false">"; print_r($tempArray); unset($tempArray); echo ""; } }
PHP The ExcelToPHP function in the Excel_Shared_Date class is the key part!
Readers who are interested in more thinkPHP related content can check out the special topics of this site: "ThinkPHP introductory tutorial", "Summary of common methods of ThinkPHP", "Summary of PHP office document operation skills (including word, excel, access, ppt)" , "Summary of Cookie Usage in PHP", "Basic Tutorial for Getting Started with Smarty Templates" and "Summary of PHP Template Technology".
I hope this article will be helpful to everyone’s PHP programming based on the ThinkPHP framework.
The above introduces the thinkPHP+PHPExcel method of reading file date, including hours, minutes and seconds, including aspects. I hope it will be helpful to friends who are interested in PHP tutorials.