I. Overview
php tutorial -excelreader is a php class that reads the contents of an excel xsl file.
Its download URL: http://sourceforge.net/projects/phpexcelreader/
This blog download address: phpexcelreader.zip
Test excel files: test .xls
File name: phpexcelreader.zip
Contains two required files: oleread.inc, reader.php. Other documents are an application example, readme files and more
Second, the use of documents
First, include the reader class file: require_once "reader.php";
Create a new instance: $ xl_reader = new spreadsheet_excel_reader ();
Set the encoding information: $ xl_reader -> setoutputencoding ('utf-8'); / / Not set may be garbled and page display code consistent
Read excel file information: $ xl_reader-> read ("filename.xls");
It exports all the identifiable data in the excel file stored in an object. Data is stored in 2 arrays and there is currently no method / function to access this data. You can simply use an array name like this.
The sheets array contains a large amount of data that is read into the object. It stores all identifiable data in the exported excel file in a 2-dimensional array $ xl_reader-> sheets [x] [y]. x is the table number in the document, y is one of the following parameters:
Numrows - int - the number of rows in the table
For example: $ rows = $ xl_reader-> sheets [0] ['numrows']
② numcols - int - the number of columns in the table
For example: $ cols = $ xl_reader-> sheets [0] ['numcols']
③ cells - array - the actual contents of the table. Is a two-dimensional array of [row] [column] format
For example: $ cell_2_4 = $ xl_reader-> sheets [0] ['cells'] [2] [4] // Line 2, the data in column 4
④ cellsinfo - array - information of different data types in the table. Each contains the form's original data and type. This array contains two parts: raw - the table raw data; type - the data type.
Note: Only non-text data information is displayed.
For example: $ cell_info = $ xl_reader [0] ['cellsinfo'] [2] [4]
$ cell_info ['raw'] is the raw data from the cell
$ cell_info ['type'] is the data type
$ xl_reader-> sheets