Using PHPExcel to export files _ PHP Tutorial

Source: Internet
Author: User
Use PHPExcel to export files. Step 1. create an excel table to instantiate the PHPExcel class 2. create a sheet (built-in table) createSheet () setActiveSheetIndex () getActiveSheet () 3. fill in the data and use PHPExcel to export the file

Export procedure

1. create an excel table

Instantiate the PHPExcel class

2. create a sheet (built-in table)

CreateSheet ()

SetActiveSheetIndex ()

GetActiveSheet ()

3. fill in data

SetCellValue ()

4. Save the file

PHPExcel_IOFactory: createWriter ()

Save ()

 SetActiveSheetIndex (0); $ objSheet = $ objPHPExcel-> getActiveSheet (); // get the current sheet $ objSheet-> setTitle (demo ); // Set the name $ array = array (name, score), array (Li Si, 60), array (Wang Wu, 70) for the current sheet )); $ objSheet-> setCellValue (A5, name); $ objSheet-> setCellValue (B5, score); // fill data with the current sheet $ objSheet-> setCellValue (A6, Zhang San ); $ objSheet-> setCellValue (B6, 70); $ objSheet-> fromArray ($ array); // directly load data blocks to fill in data $ objWriter = PHPExcel_IOFactory: createWriter ($ objPHPExcel, 'excel2007 '); // Generate an excel file in the specified format $ objWriter-> save (str_replace ('. php ', '.xls', _ FILE __));


Export export step 1. create an excel table to instantiate the PHPExcel class 2. create a sheet (built-in table) createSheet () setActiveSheetIndex () getActiveSheet () 3. fill in the data...

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.