PHP-ExcelReader is an open source project based on PHP, its function is to parse excel files.
The official website of PHP-ExcelReader is as follows:
http://phpexcelreader.sourceforge.net/
The downloaded file structure is as shown below:
Among them, the two files reader.php and oleread.inc in the Excel directory are files that must be included in excel parsing. The classes and methods required for parsing are written in these two files respectively. Among others, the two files example.php and example2.php are sample programs, the jxlwtest.xls file is the file that the sample program needs to parse, and the remaining two files are readme files.
The usage of PHP-ExcelReader is relatively simple, the following four lines of code are necessary:
[php]After the above four lines of code are executed, the excel file will be parsed. The parsed result is in the array $reader->sheets[0], which contains six items: maxrow, maxcol, numRows, numCols, cells, and cellsInfo. The useful ones are numRows (number of rows) and numCols (column). number), cells (cell content). To get the specific data information of the excel file, just traverse the $reader->sheets[0]["cells"] array. The array is of the form
$reader->sheets[0]["cells"][
has row and column indexes starting from 1.
What needs to be explained is:
1. The Excel/reader.php file has already included the oleread.inc file with require_once, so there is no need to load oleread.inc when calling.
2. The official excel file jxlwtest.xls has been damaged and cannot be read and parsed.
3. Line 31 of the original Excel/reader.php file (below) causes the error:
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 required here is Excel/oleread.inc. Just change the file name after require_once to 'oleread.inc'.
4. Line 261 of the original Excel/reader.php file will result in the following warning:
Deprecated: Assigning thereturn value of new by reference is deprecated
The reason is that the =& symbol in this line has been deprecated in PHP 5.3. According to the role of this symbol here, just change it to =.
5. PHP-ExcelReader does not support the parsing of Excel 2007 documents, which means that Excel files with the extension xlsx cannot be parsed using this class library; it only targets Excel files with the extension xls .
6. The setting encoding method of PHP-ExcelReader is based on the iconv command. The parameter of the setOutputEncoding method is the name of the character set that needs to be set. To make this method effective, you need to install the iconv extension to the local PHP environment; if the local PHP environment does not have the iconv extension, the encoding method of PHP-ExcelReader defaults to Unicode. For information about the iconv command, please refer to the following link:
www.Bkjia.com
7. PHP-ExceReader may have precision errors when parsing integers. For example, 58 is parsed as 57.5 for unknown reasons. All you can do is check the data after parsing it, and then round it (if necessary).
8. PHP-ExcelReader will either directly skip the blank cells in the excel file and not store them in the result array, or save them as 0 or "" (empty string).
PHP-ExcelReader is an open source project based on PHP, its function is to parse excel files.
The official website of PHP-ExcelReader is as follows:
http://phpexcelreader.sourceforge.net/
The downloaded file structure is as shown below:
Among them, the two files reader.php and oleread.inc in the Excel directory are files that must be included in excel parsing. The classes and methods required for parsing are written in these two files respectively. Among others, the two files example.php and example2.php are sample programs, the jxlwtest.xls file is the file that the sample program needs to parse, and the remaining two files are readme files.
The usage of PHP-ExcelReader is relatively simple, the following four lines of code are necessary:
[php]After the above four lines of code are executed, the excel file will be parsed. The parsed result is in the array $reader->sheets[0], which contains six items: maxrow, maxcol, numRows, numCols, cells, and cellsInfo. The useful ones are numRows (number of rows) and numCols (column). number), cells (cell content). To get the specific data information of the excel file, just traverse the $reader->sheets[0]["cells"] array. The array is of the form
$reader->sheets[0]["cells"][
has row and column indexes starting from 1.
What needs to be explained is:
1. The Excel/reader.php file has already included the oleread.inc file with require_once, so there is no need to load oleread.inc when calling.
2. The official excel file jxlwtest.xls has been damaged and cannot be read and parsed.
3. Line 31 of the original Excel/reader.php file (below) causes the error:
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 required here is Excel/oleread.inc. Just change the file name after require_once to 'oleread.inc'.
4. Line 261 of the original Excel/reader.php file will result in the following warning:
Deprecated: Assigning thereturn value of new by reference is deprecated
The reason is that the =& symbol in this line has been deprecated in PHP 5.3. According to the role of this symbol here, just change it to =.
5. PHP-ExcelReader does not support the parsing of Excel 2007 documents, which means that Excel files with the extension xlsx cannot be parsed using this class library; it only targets Excel files with the extension xls .
6. The setting encoding method of PHP-ExcelReader is based on the iconv command. The parameter of the setOutputEncoding method is the name of the character set that needs to be set. To make this method effective, you need to install the iconv extension to the local PHP environment; if the local PHP environment does not have the iconv extension, the encoding method of PHP-ExcelReader defaults to Unicode. For information about the iconv command, please refer to the following link:
www.Bkjia.com
7. PHP-ExceReader may have precision errors when parsing integers. For example, 58 is parsed as 57.5 for unknown reasons. All you can do is check the data after parsing it, and then round it (if necessary).
8. PHP-ExcelReader will either directly skip the blank cells in the excel file and not store them in the result array, or save them as 0 or "" (empty string).