There are two problems with Excel at work,
1.excel table in the column value is too large, due to no special treatment, the program can not run properly;
2. The column value contains the date format text, cannot read correctly;
So through the network search, and solve the problem, record, for later use:
Workaround:
/**** Summary of Knowledge points * * * *
1. Column values are too large to get the maximum number of columns by phpexcel_cell::columnindexfromstring ($column)
2. For dates in the table, it can be formatted by phpexcel_shared_date::exceltophp ($value),
If you get a date value, you can get it as in the following statement:
$date = Gmdate ("y-m-d h:i:s", phpexcel_shared_date::exceltophp ($sheet->getcell ($column. $row)->getvalue ()));
*******************/
<?PHP//Phpexcel class Get address https://github.com/PHPOffice/PHPExcel//introduce Phpexcel class fileinclude_once'./phpexcel.php ';//read the Excel file$excelFile= './test.xlsx ';/** Instantiate read Excel file class, according to Excel version of different get, below is different way*//** *//excel5 mode $objReader = new Phpexcel_reader_excel5 (); $objReader = Phpexcel_iofactory::createwriter (' Excel5 '); Excel2007 mode $objReader = new phpexcel_reader_excel2007 (); $objReader = Phpexcel_iofactory::createwriter (' Excel2007 '); * **///since my file is version 07, use the Excel2007 method$objReader= Phpexcel_iofactory::createreader (' Excel2007 ');//Loading Excel Files$objPHPExcel=$objReader->load ($excelFile);//read the first worksheet in Excel$sheet=$objPHPExcel->getsheet (0);//total number of rows obtained$highestRow=$sheet-Gethighestrow ();//total number of columns obtained$highestColumm=$sheet-Gethighestcolumn ();//gets the value of the maximum column value letter$highestColummNum= Phpexcel_cell::columnindexfromstring ($highestColumm);if(!$highestRow|| !$highestColumm) { Exit(' No data in table ');}//get table values for storage$dataExcel=Array();$i= 0;//If the column values are too large to be calculated,if($highestColummNum> 26) { //iterate through the data for each cell for($row= 2;$row<=$highestRow;$row++) {//The number of rows starts at line 2nd for($column= ' A '; Phpexcel_cell::columnindexfromstring ($column) <=$highestColummNum;$column++) {//the number of columns starts with column a if($column= = ' E ') {//Suppose that column E is the date $dataExcel[$i][] =gmdate("Y-m-d h:i:s", phpexcel_shared_date::exceltophp ($sheet->getcell ($column.$row),GetValue ())); } Else { $dataExcel[$i][] =$sheet->getcell ($column.$row),GetValue (); } } $i++; }} Else { //iterate through the data for each cell for($row= 2;$row<=$highestRow;$row++) {//The number of rows starts at line 2nd for($column= ' A ';$column<=$highestColumm;$column++) {//the number of columns starts with column a if($column= = ' E ') {//Suppose that column E is the date $dataExcel[$i][] =gmdate("Y-m-d h:i:s", phpexcel_shared_date::exceltophp ($sheet->getcell ($column.$row),GetValue ())); } Else { $dataExcel[$i][] =$sheet->getcell ($column.$row),GetValue (); } } $i++; }}if(!$dataExcel) { Exit(' No data acquired ');}Print_r($dataExcel);Exit;/** * * Knowledge points summary *****1. column values are too large to get the value of the maximum column by phpexcel_cell::columnindexfromstring ($column) 2. For dates in a table, you can use the Phpexcel_ Shared_date::exceltophp ($value) is formatted, such as getting a date value, which can be obtained as follows: $date = Gmdate ("y-m-d h:i:s", Phpexcel_shared_date:: exceltophp ($sheet->getcell ($column. $row)->getvalue ()); *******************/?>
A summary of the knowledge points of the problems encountered by Phpexcel