Php-excelreader is a PHP-based open source project that parses Excel files.
Php-excelreader's official web-sheet is as follows:
http://phpexcelreader.sourceforge.net/
The structure of the downloaded file is as follows:
Among them, the Excel directory of two files reader.php and oleread.inc is the Excel parsing must contain the files, parsing the required classes and methods are written in these two files. Other, example.php and example2.php two files is a sample program, Jxlwtest.xls file is the sample program needs to parse the file, the remaining two files are the Readme file.
The usage of Php-excelreader is simple, the following four lines of code are necessary:
[Php]require_once (' excel/reader.php '); Referencing the excel/reader.php file, loading the class library $reader = new Spreadsheet_excel_reader (); Instantiation parsing Class spreadsheet_excel_reader$reader->setoutputencoding (CP1251); Set the Encoding method $reader->read (Jxlwtest.xls); Read and parse the file (Jxlwtest.xls is the file name) after the above four lines of code are executed, the Excel file is parsed. Parsed results in array $reader->sheets[0], containing MaxRow, Maxcol, NumRows, numcols, cells, cellsinfo six items, with useful numrows (number of rows), Numcols (Number of columns) , cells (cell contents). To get the specific data information of an Excel file, traverse the $reader->sheets[0]["cells"] array. The array is shaped like $reader->sheets[0]["cells"][< row index >][< column index;] = < value in Cell >
of two-dimensional arrays, row and column indexes are counted starting at 1.
It should be stated that:
1. The excel/reader.php file already contains the Oleread.inc file in require_once, so there is no need to load the oleread.inc at the time of the call.
2. The official Excel file Jxlwtest.xls has been corrupted and cannot be read and parsed.
3. The 31st line of the original excel/reader.php file (below) causes an 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 required files here is Excel/oleread.inc, the require_once after the file name is changed to ' Oleread.inc ' can be.
4. The No. 261 Guild of the original excel/reader.php file causes the following warning:
Deprecated:assigning Thereturn value of new by reference is Deprecated
The reason for this is that the =& symbol for this line has been deprecated in PHP 5.3. Depending on the symbol's role here, change it directly to =.
5. Php-excelreader does not support parsing of Excel 2007 documents, which means that Excel files with the extension xlsx cannot be parsed using this class library, only for Excel files with the extension xls.
6. The Php-excelreader encoding method is based on the Iconv command, and the parameters of the Setoutputencoding method are the names of the character sets that need to be set. For this method to work, you need to install the iconv extension for the local PHP environment, and if the local PHP environment does not have iconv extensions, the Php-excelreader encoding method defaults to Unicode. Refer to the following link for the iconv command:
Www.codesec.net
7. When parsing integers, php-excereader may have errors in accuracy, such as 58 parsing to 57.5, for unknown reasons. What can be done is to check the data after parsing and then round (if necessary).
8. Php-excelreader for blank cells in an Excel file, either skip directly to the result array or save as 0 or "" (an empty string).
Php-excelreader is a PHP-based open source project that parses Excel files.
Php-excelreader's official web-sheet is as follows:
http://phpexcelreader.sourceforge.net/
The structure of the downloaded file is as follows:
Among them, the Excel directory of two files reader.php and oleread.inc is the Excel parsing must contain the files, parsing the required classes and methods are written in these two files. Other, example.php and example2.php two files is a sample program, Jxlwtest.xls file is the sample program needs to parse the file, the remaining two files are the Readme file.
The usage of Php-excelreader is simple, the following four lines of code are necessary:
[Php]require_once (' excel/reader.php '); Referencing the excel/reader.php file, loading the class library $reader = new Spreadsheet_excel_reader (); Instantiation parsing Class spreadsheet_excel_reader$reader->setoutputencoding (CP1251); Set the Encoding method $reader->read (Jxlwtest.xls); Read and parse the file (Jxlwtest.xls is the file name) after the above four lines of code are executed, the Excel file is parsed. Parsed results in array $reader->sheets[0], containing MaxRow, Maxcol, NumRows, numcols, cells, cellsinfo six items, with useful numrows (number of rows), Numcols (Number of columns) , cells (cell contents). To get the specific data information of an Excel file, traverse the $reader->sheets[0]["cells"] array. The array is shaped like $reader->sheets[0]["cells"][< row index >][< column index;] = < value in Cell >
of two-dimensional arrays, row and column indexes are counted starting at 1.
It should be stated that:
1. The excel/reader.php file already contains the Oleread.inc file in require_once, so there is no need to load the oleread.inc at the time of the call.
2. The official Excel file Jxlwtest.xls has been corrupted and cannot be read and parsed.
3. The 31st line of the original excel/reader.php file (below) causes an 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 required files here is Excel/oleread.inc, the require_once after the file name is changed to ' Oleread.inc ' can be.
4. The No. 261 Guild of the original excel/reader.php file causes the following warning:
Deprecated:assigning Thereturn value of new by reference is Deprecated
The reason for this is that the =& symbol for this line has been deprecated in PHP 5.3. Depending on the symbol's role here, change it directly to =.
5. Php-excelreader does not support parsing of Excel 2007 documents, which means that Excel files with the extension xlsx cannot be parsed using this class library, only for Excel files with the extension xls.
6. The Php-excelreader encoding method is based on the Iconv command, and the parameters of the Setoutputencoding method are the names of the character sets that need to be set. For this method to work, you need to install the iconv extension for the local PHP environment, and if the local PHP environment does not have iconv extensions, the Php-excelreader encoding method defaults to Unicode. Refer to the following link for the iconv command:
Www.codesec.net
7. When parsing integers, php-excereader may have errors in accuracy, such as 58 parsing to 57.5, for unknown reasons. What can be done is to check the data after parsing and then round (if necessary).
8. Php-excelreader for blank cells in an Excel file, either skip directly to the result array or save as 0 or "" (an empty string).
A detailed explanation of the PHP garbage collection mechanism