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...