php excel read excel file

Source: Internet
Author: User
Keywords Network programming PHP tutorial
Tags .net .url address array blog class data data type

I. Overview

php tutorial -excelreader is a php class that reads the contents of an excel xsl file.

Its download URL: http://sourceforge.net/projects/phpexcelreader/

This blog download address: phpexcelreader.zip

Test excel files: test .xls

File name: phpexcelreader.zip

Contains two required files: oleread.inc, reader.php. Other documents are an application example, readme files and more

Second, the use of documents

First, include the reader class file: require_once "reader.php";

Create a new instance: $ xl_reader = new spreadsheet_excel_reader ();

Set the encoding information: $ xl_reader -> setoutputencoding ('utf-8'); / / Not set may be garbled and page display code consistent

Read excel file information: $ xl_reader-> read ("filename.xls");

It exports all the identifiable data in the excel file stored in an object. Data is stored in 2 arrays and there is currently no method / function to access this data. You can simply use an array name like this.

The sheets array contains a large amount of data that is read into the object. It stores all identifiable data in the exported excel file in a 2-dimensional array $ xl_reader-> sheets [x] [y]. x is the table number in the document, y is one of the following parameters:

Numrows - int - the number of rows in the table

For example: $ rows = $ xl_reader-> sheets [0] ['numrows']

② numcols - int - the number of columns in the table

For example: $ cols = $ xl_reader-> sheets [0] ['numcols']

③ cells - array - the actual contents of the table. Is a two-dimensional array of [row] [column] format

For example: $ cell_2_4 = $ xl_reader-> sheets [0] ['cells'] [2] [4] // Line 2, the data in column 4

④ cellsinfo - array - information of different data types in the table. Each contains the form's original data and type. This array contains two parts: raw - the table raw data; type - the data type.

Note: Only non-text 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

Related Article

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.