Use PHP to read Excel files-reader. php Excel operations

Source: Internet
Author: User
Tags array example php excel

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.