Ec (2); 1. & nbsp; Overview php tutorial-excelreader & nbsp; Is a read excelxsl & nbsp; a php & nbsp; Class in the file content. Its download URL: & nbsp; sourceforge. netprojectsphpexcelreader this blog: phpexcelreader. z script ec (2); script
I. Overview
Php tutorial-excelreader is a php class that reads the content of an excel xsl file.
Its download URL: http://sourceforge.net/projects/phpexcelreader/
This blog: phpexcelreader.zip
Excel files for testing: Test. xls
File Name: phpexcelreader.zip
Contains two required files: oleread. inc and reader. php. Other files are an application example and a self-report file.
Ii. File Usage
First, include the reader file: require_once "reader. php ";
Create an instance: $ xl_reader = new spreadsheet_excel_reader ();
Set the encoding information: $ xl_reader-> setoutputencoding ('utf-8'); // if this parameter is not set, it may be garbled with the encoding displayed on the webpage.
Read excel File Information: $ xl_reader-> read ("filename.xls ");
It stores all identifiable data in the exported excel file in one object. Data is stored in two arrays. Currently, no methods/functions are provided to access the data. You can use the array name as follows.
The sheets array contains a large amount of data read into the object. It stores all identifiable data in the exported excel file in a two-dimensional array $ xl_reader-> sheets [x] [y]. X is the sequence number of the table in the document, and y is one of the following parameters:
① Numrows -- int -- number of rows in the table
For example: $ rows = $ xl_reader-> sheets [0] ['numrows ']
② Numcols -- int -- number of columns in the table
Example: $ cols = $ xl_reader-> sheets [0] ['numcols']
③ Cells -- array -- actual table content. Is a 2-dimensional array in the format of [row] [column]
For example: $ cell_2_4 = $ xl_reader-> sheets [0] ['cells '] [2] [4] // Row 2, data in column 4
④ Cellsinfo -- array -- information of different data types in the table. Each table contains the original data and type of the table. This array contains two parts: raw -- original table data; type -- data type.
Note: Only non-text data information is displayed.
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