$ Reader-> setOutputEncoding (CP1251); // sets the encoding method $ reader-> read(jxlwtest.xls); // reads and shares the file (jxlwtest.xls is the file name)After the preceding four statements are executed, the excel file is parsed. The parsed result is in the array$ Reader-> sheets [0]Contains maxrow, maxcol, numRows, numCols, cells, and cellsInfo, among which numRows (number of rows), numCols (number of columns), and cells (cell content) are useful ). To obtain the specific data information of an excel file, Traverse$ Reader-> sheets [0] ["cells"]Array. This array is like
$ Reader-> sheets [0] ["cells"] [ <行索引> ] [ <列索引> ] = <单元格中的值>
The two-dimensional array, row index and column index are counted from 1.
Note:
1.The Excel/reader. php file already uses require_once to include the oleread. inc file. Therefore, you do not need to load oleread. inc during the call.
2.The Excel file jxlwtest.xls of the official website is damaged and cannot be read or parsed.
3.The following error occurs when the first line of the original Excel/reader. php file is as follows:
Require_once 'Spreadsheet/Excel/Reader/OLERead. php ';
The reason is that the Spreadsheet/Excel/Reader/OLERead. php file does not exist. In fact, the file needed here is Excel/oleread. inc. change the file name after require_once to 'oleread. Inc.
4.The following warning is reported when the row 261st of the original Excel/reader. php file is returned:
Deprecated: Assigning thereturn value of new by reference is deprecated
The reason is that the = & symbol of this line has been deprecated in PHP 5.3. Based on the role of this symbol, you can directly change it to =.
5.PHP-ExcelReader does not support parsing Excel 2007 documents. that is to say, Excel files with the xlsx extension cannot be parsed using this class library. it only targets Excel files with the xls extension.
6.The PHP-ExcelReader encoding method is based on the iconv command. the parameter of setOutputEncoding is the name of the character set to be set. To make this method take effect, you need to install the iconv extension for the local PHP environment. if the local PHP environment does not have the iconv extension, the PHP-ExcelReader encoding method defaults to Unicode. For the iconv command, see the following link:
Www.Bkjia.com
7.PHP-ExceReader may encounter an error in precision when parsing integers. for example, 58 is resolved to 57.5 for unknown reasons. All you can do is check the data after parsing and rounding it out (if necessary ).
8.For blank cells in an excel file, PHP-ExcelReader directly skips the blank cells that are not stored in the result array, or saves them as 0 or "" (empty string ).
PHP-ExcelReader is an open-source PHP-based project that parses excel files.
The official PHP-ExcelReader website is as follows:
Http://phpexcelreader.sourceforge.net/
Shows the structure of the downloaded file:
The two files reader. php and oleread. inc in the Excel directory are mandatory for excel parsing. the classes and methods required for parsing are written in these two files respectively. Specifically, the two files example.php and example2.php are the example program. The jxlwtest.xls file is the file to be parsed by the sample program, and the remaining two files are the self-report files.
PHP-ExcelReader is easy to use. the following code is required:
[Php]
- Require_once ('Excel/reader. php'); // reference the Excel/reader. php file and load the class library $ reader = new Spreadsheet_Excel_Reader (); // instantiate the parsing class Spreadsheet_Excel_Reader
- $ Reader-> setOutputEncoding (CP1251); // sets the encoding method $ reader-> read(jxlwtest.xls); // reads and shares the file (jxlwtest.xls is the file name)
After the preceding four statements are executed, the excel file is parsed. The parsed result is in the array$ Reader-> sheets [0]Contains maxrow, maxcol, numRows, numCols, cells, and cellsInfo, among which numRows (number of rows), numCols (number of columns), and cells (cell content) are useful ). To obtain the specific data information of an excel file, Traverse$ Reader-> sheets [0] ["cells"]Array. This array is like
$ Reader-> sheets [0] ["cells"] [ <行索引> ] [ <列索引> ] = <单元格中的值>
The two-dimensional array, row index and column index are counted from 1.
Note:
1.The Excel/reader. php file already uses require_once to include the oleread. inc file. Therefore, you do not need to load oleread. inc during the call.
2.The Excel file jxlwtest.xls of the official website is damaged and cannot be read or parsed.
3.The following error occurs when the first line of the original Excel/reader. php file is as follows:
Require_once 'Spreadsheet/Excel/Reader/OLERead. php ';
The reason is that the Spreadsheet/Excel/Reader/OLERead. php file does not exist. In fact, the file needed here is Excel/oleread. inc. change the file name after require_once to 'oleread. Inc.
4.The following warning is reported when the row 261st of the original Excel/reader. php file is returned:
Deprecated: Assigning thereturn value of new by reference is deprecated
The reason is that the = & symbol of this line has been deprecated in PHP 5.3. Based on the role of this symbol, you can directly change it to =.
5.PHP-ExcelReader does not support parsing Excel 2007 documents. that is to say, Excel files with the xlsx extension cannot be parsed using this class library. it only targets Excel files with the xls extension.
6.The PHP-ExcelReader encoding method is based on the iconv command. the parameter of setOutputEncoding is the name of the character set to be set. To make this method take effect, you need to install the iconv extension for the local PHP environment. if the local PHP environment does not have the iconv extension, the PHP-ExcelReader encoding method defaults to Unicode. For the iconv command, see the following link:
Www.Bkjia.com
7.PHP-ExceReader may encounter an error in precision when parsing integers. for example, 58 is resolved to 57.5 for unknown reasons. All you can do is check the data after parsing and rounding it out (if necessary ).
8.For blank cells in an excel file, PHP-ExcelReader directly skips the blank cells that are not stored in the result array, or saves them as 0 or "" (empty string ).