: This article mainly introduces PHPExcel reading. if you are interested in PHP tutorials, refer to it.
Require_ Once './library/excel/PHPExcel. php ';
// File to be read
$ FilePath = 'test.xlsx ';
$ PHPExcel = new PHPExcel ();
/** Excel is read using excel2007 by default. if the format is incorrect, it will be read using the previous version */
$ PHPReader = new PHPExcel_Reader_Excel2007 ();
If (! $ PHPReader-> canRead ($ filePath ))
{
$ PHPReader = new PHPExcel_Reader_Excel5 ();
If (! $ PHPReader-> canRead ($ filePath ))
{
Echo 'no Excel ';
Return;
}
}
$ PHPExcel = $ PHPReader-> load ($ filePath );
/** Read the first worksheet in an excel file */
$ CurrentSheet = $ PHPExcel-> getSheet (0 );
/** Obtain the largest column number */
$ AllColumn = $ currentSheet-> getHighestColumn ();
/** Obtain the total number of rows */
$ AllRow = $ currentSheet-> getHighestRow ();
/** Output from the second row because the first row column name in the excel table */
For ($ currentRow = 1; $ currentRow <= $ allRow; $ currentRow ++)
{
/** Output from column */
For ($ currentColumn = 'a'; $ currentColumn <= $ allColumn; $ currentColumn ++)
{
$ Val = $ currentSheet-> getCellByColumnAndRow (ord ($ currentColumn)-65, $ currentRow)-> getValue ();/** ord () convert characters into decimal numbers */
Echo $ val. "\ t ";
}
Echo"
";
}
?>
The above introduces PHPExcel reading, including some content, and hope to be helpful to friends who are interested in PHP tutorials.