The example in this paper describes how Thinkphp+phpexcel implements the Read file date. Share to everyone for your reference, as follows:
When we read the Excel file using Phpexcel, we found that the time is similar to the number: 41890.620138889, then how to handle it as we want 2014-09-08 14:53:00 This format date, see 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 (); Total number of rows $highestcolumn = $sheet->gethighestcolumn (); Total number of columns obtained $temparray = array (); for ($j =2; $j <= $highestRow; $j + +) {for ($k = ' A '; $k <= $highestColumn; $k + +) { if ($k = = ' h ') {//Specifies the column of H for the time $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 ""; Print_r ($tempArray); Unset ($tempArray); echo "
"; }}
The exceltophp function in the Phpexcel_shared_date class is a key part!
More interested in thinkphp related content readers can view this site topic: "thinkphp Introductory Tutorial", "thinkphp Common Method Summary", "PHP operation Office Document Skills Summary (including word,excel,access,ppt)", " Summary of cookie Usage in PHP, basic tutorial on Smarty Templates and PHP template technology summary.
It is hoped that this article is helpful to the PHP program design based on thinkphp framework.
The above describes the Thinkphp+phpexcel implementation of the method to read the file date time and seconds, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.