The example in this article describes the Thinkphp+phpexcel implementation method for reading file dates. Share to everyone for your reference, specific 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 treat it as we want 2014-09-08 14:53:00 in the format of the date, 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 (); Get the total number of rows
$highestColumn = $sheet->gethighestcolumn ();//Get the overall number of columns
$tempArray = Array ();
For ($j =2 $j <= $highestRow $j + +) {for
($k = ' A '; $k <= $highestColumn; $k + +) {
if ($k = = ' h ') {//Specify H as column of 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 "<pre>";
Print_r ($tempArray);
Unset ($tempArray);
echo "</pre>";
}
}
The exceltophp function in the Phpexcel_shared_date class is a key part!
More interested in thinkphp related content readers can view the site topics: "thinkphp Introductory Course", "thinkphp Common Methods Summary", "PHP operation Office Document Skills Summary (including word,excel,access,ppt)", " A summary of cookie usage in PHP, the basics of Smarty Templates tutorial and the PHP template technology summary.
I hope this article will help you with the PHP program design based on thinkphp framework.