Read Excel-PHP source code

Source: Internet
Author: User
Read Excel php code

/* Report all errors failed t E_NOTICE */error_reporting (E_ALL ^ E_NOTICE); $ filename = $ _ GET ['filename']; $ xlsPath = $ filename; // specify the exls path to be read // $ type = 'excel2007 '; // Set the Excel type to be parsed (2003 or below) or Excel2007 $ type = 'excel5'; // introduces the excel class include 'load. php '; include' Classes/PHPExcel. php'; include 'classes/PHPExcel/IOFactory. php '; $ xlsReader = PHPExcel_IOFactory: createReader ($ type); $ xlsReader-> setReadDataOnly (true); $ xlsReader-> setLoadSheetsOnly (true ); $ Sheets = $ xlsReader-> load ($ xlsPath); // start to read $ Sheet = $ Sheets-> getSheet (0)-> toArray (); // read the first worksheet (note that the number starts from 0). If you want to read multiple worksheets, you can create a loop of 0, 1, 2, 3 .... // Obtain a two-dimensional array. each small array is the echo ''; echo 'Count the total number of orders 'in each row containing this row in an excel table '; $ data = array (); for ($ I = 2; $ i0) {$ info [$ val ['name'] =++ $ sum ;} else {$ info [$ val ['name'] = -- $ sum;} foreach ($ info as $ key => $ val) {echo "". $ key. "". $ val. "";}

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.