Use php to read excel files-reader. phpexcel operations

Source: Internet
Author: User
Tags array example php excel
How to use php to read excel files-reader. phpexcel operations? I ,? Overview PHP-ExcelReader? Is it a read? Excelxsl? File content? PHP? Class. Its Download URL :? Http://sourceforge.net/projects/ph php Read excel file-reader. php excel operation class use

? I ,? Overview

PHP-ExcelReader? Is it a read? Excel xsl? File content? PHP? 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'); // 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 ");

?

Will it be exported? Excel? All identifiable data in the file is stored in an object. Data is stored in? 2? Which of the following arrays are available? /? How does a function access this data ?.? You can use the array name as follows.

?

Sheets? The array contains a large amount of data read into the object. Will it be exported? Excel? All identifiable data in the file is stored in one? 2? In the dimension array? $ Xl_reader-> sheets [x] [y]?.? X? Is the sequence number of the table in the document ,? Y? Is one of the following parameters? :

① ??????? NumRows -- int --? Number of rows in the table

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. Yes? [Row] [column]? Format? 2? Dimension array

?? Example :? $ Cell_2_4 = $ xl_reader-> sheets [0] ['cells '] [2] [4] //? OK? 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] => website [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 Tel. [2] => http://www.my400800.cn [3] => Enterprise 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 other information about the object? Workbook? Index .? The second index is named :? $ Xl_reader-> boundsheets [I] ['name']? Return number? 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] => 2148        )    [1] => Array        (            [name] => Sheet2            [offset] => 3484        )    [2] => Array        (            [name] => Sheet3            [offset] => 3760        ))

?

PHP-ExcelReader? Only supported? BIFF7, BIFF8? Format file. Including? Excel95? To? Excel2003 .? But does not contain? Excel5.0? And earlier versions ?.? Actually? Excel XP? And? Excel 2003? Used? BIFF8X? Yes? BIFF8? An extension of the format ?.? All added features may not be? 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.