PHP read Excel file-reader.php Excel action class using
? One,? Overview
php-excelreader? is a read? Excel xsl? One of the contents of the file? PHP? Class.
It's download URL:? http://sourceforge.net/projects/phpexcelreader/
This blog download address:phpexcelreader.zip
Test with Excel file: Test. xls
Filename:? Phpexcelreader.zip
Contains two required files:? oleread.inc?,? reader.php?. Other files are an example of an application? ,? Readme files, etc.
?
Two,? File usage
First of all? ,? Contains? reader? class file:? require_once "reader.php";
Create a new instance:? $XL _reader= new Spreadsheet_excel_reader ();
Set encoding information: $xl_reader->setoutputencoding (' utf-8 ');// not set may be garbled to be consistent with the page display encoding
Read? Excel? File information:? $xl _reader->read ("Filename.xls");
?
Will it be exported? Excel? All the identifiable data in the file is stored in an object. Data stored in? 2? No method is currently available in the arrays? /? function to access this data? .? You can use the array name as simple as the following.
?
sheets? The array contains a large amount of data that is read into the object. Will it be exported? Excel? All the identifiable data in the file is stored in one? 2? In a dimension array? $XL _reader->sheets[x][y]??? x? Is the number of the table 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
For example:? $cols = $xl _reader->sheets[0][' numcols ')
③??????? cells--array--? The actual contents of the table. Is it a? [Row][column]? Format? 2? Dimension array
?? For example:? $cell _2_4 = $xl _reader->sheets[0][' cells '][2][4]//? Yes? 2,? Column? 4? The data in
④??????? cellsinfo--Array--? Information for different data types in the table. Each contains the original data and type of the table. This array contains? 2? Part:? Raw--? Tabular raw data;? type--? The data type.
Note: Only non-textual 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? Examples of arrays:
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 [2] = http://www.baidu.com [3] = search engine ) [3] = = Array ([1] = Google [2] = = http://www.google.com.hk [3] = search engine ) [4] = = Array ([1] = 400 telephone [2] = HTtp://www.my400800.cn [3] = = Corporate website) [5] = = Array ([1] = Sina [2] = 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 additional information about the object, as the array is pressed. workbook? Index.? The second index is a name:? $xl _reader->boundsheets[i][' name ']? Return to the first? i? Table Name of a table
For example:? $sheetname = $xl _reader->boundsheets[0][' name '];//name of the first sheet
?
$xl _reader-> boundsheets? Examples of arrays:
Array ( [0] = = Array ( [name] = Sheet1 [offset] = 2148 ) [1] = = Array ( [Name] = Sheet2 [offset] = 3484 ) [2] = = Array ([name] = Sheet3 [offset] = 3760 ))
?
Php-excelreader? Only support? BIFF7, BIFF8? format files. Including? Excel95? Excel2003.? But not included? Excel5.0? and previous versions? .? As a matter of fact? Excel XP? And? Excel 2003? Use of? biff8x, huh? BIFF8? An extension of the format? .? All added features may not be. php-excelreader.? Lock support. Otherwise it can only be used? Excel xp/2003? file runs.