I,
Overview
Php-excelreader
Is a reading Excel XSL
A PHP File
Class.
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
Reader. php
. Another file is an application example,
Self-report files
II,
File Usage
First,
Include Reader
Class file: require_once "Reader. php ";
Create an instance: $ xl_reader = new spreadsheet_excel_reader ();
Set the encoding information: $ xl_reader
-> Setoutputencoding ('utf-8'); // It may be garbled if it is not set.
Must be consistent with the webpage display code
Read Excel
File Information: $ xl_reader-> Read ("filename.xls ");
It will export Excel
All identifiable data in the file is stored in an object. Data is stored in 2
Array, no method is provided currently/
The function accesses the data.
You can use the array name as follows.
Sheets
The array contains a large amount of data read into the object. It will export Excel
All identifiable data in the file is stored in a 2
$ Xl_reader-> sheets [x] [Y] In the Dimension Array
. X
Is the table number in the document, 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 --
The actual content of the table. Is a [row] [column]
Format 2
Dimension Array
Example: $ cell_2_4 = $ xl_reader-> sheets [0] ['cells '] [2] [4] //
Row 2,
Column 4
Data in
④
Cellsinfo -- array --
Information of different data types in the table. Each table contains the original data and type of the table. This array contains 2
Part: 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
Array example:
Array
(
[0] => Array
(
[Maxrow] => 0
[Maxcol] => 0
[Numrows] => 5
[Numcols] => 3
[Cells] => Array
(
[1] => Array
(
[1] => website name
[2] => URL
[3] => type
)
[2] => Array
(
[1] => Baidu
Http://www.baidu.com
[3] => Search Engine
)
[3] => Array
(
[1] => Google
Http://www.google.com.hk
[3] => Search Engine
)
[4] => Array
(
[1] => 400 phone
Http://www.my400800.cn
[3] => enterprise website
)
[5] => Array
(
[1] => Sina
Http://www.sina.com.cn
[3] => Portal
)
)
)
[1] => Array
(
[Maxrow] => 0
[Maxcol] => 0
[Numrows] => 0
[Numcols] => 0
)
[2] => Array
(
[Maxrow] => 0
[Maxcol] => 0
[Numrows] => 0
[Numcols] => 0
)
)
Boundsheets
The array contains other information about the object.
Index. The second index is named $ xl_reader-> boundsheets [I] ['name'].
Returns the I
Table names
Example: $ sheetname = $ xl_reader-> boundsheets [0] ['name']; // name of the first sheet
$ Xl_reader-> boundsheets
Array example:
Array
(
[0] => Array
(
[Name] => sheet1
[Offset] = & gt; 2148
)
[1] => Array
(
[Name] => sheet2
[Offset] = & gt; 3484
)
[2] => Array
(
[Name] => sheet3
[Offset] = & gt; 3760
)
)
Php-excelreader
Only biff7 and biff8 are supported.
Format File. Including excel95
To excel2003.
But does not include excel5.0
And earlier versions.
In fact, Excel XP
And Excel 2003
Biff8x used
Yesbiff8
Format extension.
All added features may not be used by PHP-excelreader.
Lock support. Otherwise, it can only use Excel XP/2003
File run.