PHPExcel simple reading excel file example, _ PHP Tutorial

Source: Internet
Author: User
Tags php excel php programming language
PHPExcel: A simple example of reading an excel file ,. PHPExcel: A simple example of reading an excel file. This document describes how to simply read an excel file in PHPExcel. For your reference, see PHPExcel2007classesPro PHPExcel,

This document describes how to read an excel file in PHPExcel. We will share this with you for your reference. The details are as follows:

PHP Excel 2007 classes
Project providing a set of classes for the PHP programming language, which allow you to write to and read from different file formats, like Excel 2007, PDF, HTML ,... this project is built around und Microsoft's OpenXML standard and PHP.

:
Http://phpexcel.codeplex.com/

Read an excel file to obtain an example of the content in each column of each row:

Set_include_path (get_include_path (). PATH_SEPARATOR. '. /Classes/'); include 'phpexcel/IOFactory. php '; $ reader = PHPExcel_IOFactory: createReader ('excel2007'); // read the excel document $ PHPExcel = $ reader-> load ($ excelfilename ); // document name $ sheet = $ PHPExcel-> getSheet (0); // read the first worksheet (number starts from 0) $ highestRow = $ sheet-> getHighestRow (); // get the total number of rows $ highestColumn = $ sheet-> getHighestColumn (); // get the total number of columns $ arr = array (1 => 'A', 2 =>' B ', 3 => 'C', 4 => 'D', 5 => 'e', 6 => 'F', 7 => 'G ', 8 => 'h', 9 => 'I', 10 => 'J', 11 => 'K', 12 => 'L ', 13 => 'm', 14 => 'N', 15 => 'O', 16 => 'P', 17 => 'Q ', 18 => 'R', 19 =>'s ', 20 => 'T', 21 => 'u', 22 => 'V ', 23 => 'W', 24 => 'X', 25 => 'y', 26 => 'Z'); // echo $ highestRow. $ highestColumn; // read a column for ($ row = 5; $ row <= $ highestRow; $ row ++) {for ($ column = 0; $ arr [$ column]! = 'T'; $ column ++) {$ val = $ sheet-> getCellByColumnAndRow ($ column, $ row)-> getValue (); echo $ val ;}}

Supplement: The editor recommends a php formatting and formatting typographical tool on this site to help you typeset code in future PHP programming:

Php code online formatting and beautification tools:

Http://tools.jb51.net/code/phpformat

In addition, because php belongs to the C language style, the following tool can also format php code:

C language style/HTML/CSS/json code formatting and beautification tools:
Http://tools.jb51.net/code/ccode_html_css_json

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.