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