$reader->setoutputencoding (CP1251); Set the Encoding method $reader->read (Jxlwtest.xls); Read and parse the file (Jxlwtest.xls is the filename)After the above four sentences are executed, the Excel file is parsed. The results of the parsing are in the array $reader->sheets[0] , including MaxRow, Maxcol, NumRows, numcols, cells, cellsinfo six items, which are useful numrows (number of rows), Numcols (number of columns), cells (cell contents). To get specific data about an Excel file, traverse $reader->sheets[0]["cells"] array. The array is shaped like
$reader->sheets[0]["Cells" [ <行索引> <列索引> ] [] <单元格中的值> =
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 are 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.Bkjia.com
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 filename)
After the above four sentences are executed, the Excel file is parsed. The results of the parsing are in the array $reader->sheets[0] , including MaxRow, Maxcol, NumRows, numcols, cells, cellsinfo six items, which are useful numrows (number of rows), Numcols (number of columns), cells (cell contents). To get specific data about an Excel file, traverse $reader->sheets[0]["cells"] array. The array is shaped like
$reader->sheets[0]["Cells" [ <行索引> <列索引> ] [] <单元格中的值> =
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 are 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.Bkjia.com
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).