PHP exports excel through the PHPExcel class, while some simplified processing of PHPExcel, basically can meet the data export excel function. View php import exce
PHP exports excel through the PHPExcel class, while some simplified processing of PHPExcel, basically can meet the data export excel function. View php import excel
File: http://pan.baidu.com/share/link? Consumer id = 1345826295 & uk = 2332350821
The code is as follows:
GetProperties (); $ objProps-> setCreator ("Lao Mao"); $ objProps-> setLastModifiedBy ("Lao Mao "); $ objProps-> setTitle ("Office XLS Test Document"); $ objProps-> setSubject ("Office XLS Test Document, Demo"); $ objProps-> setDescription ("Test document, generated by PHPExcel. "); $ objProps-> setKeywords (" office excel PHPExcel "); $ objProps-> setCategory (" Test "); // set the current sheet index, used for subsequent content operations. // Display the call only when multiple sheets are used. // By default, PHPExcel will automatically create the first sheet and set SheetIndex = 0 $ objPHPExcel-> setActiveSheetIndex (0 ); // Set the name of the current active sheet $ objActSheet = $ objPHPExcel-> getActiveSheet (); $ objActSheet-> setTitle ('test Sheet '); // Set the cell content // The data here can be read from the database, and then processed cyclically $ objPHPExcel-> getActiveSheet ()-> SetCellValue ('A1', 'A1 '); $ objPHPExcel-> getActiveSheet ()-> SetCellValue ('A2 ', 'A2'); $ objPHPExcel-> getActiveSheet ()-> SetCellValue ('A3 ', 'A3 '); $ objPHPExcel-> getActiveSheet ()-> SetCellValue ('A4 ', 'A4'); $ objPHPExcel-> getActiveSheet ()-> SetCellValue ('a5 ', 'a5 '); $ objPHPExcel-> getActiveSheet ()-> SetCellValue ('b1 ', 'b1'); $ objPHPExcel-> getActiveSheet ()-> SetCellValue ('B2', 'B2 '); $ objPHPExcel-> getActiveSheet ()-> SetCellValue ('b3', 'b3'); $ objPHPExcel-> getActiveSheet ()-> SetCellValue ('B4 ', 'B4 '); $ objPHPExcel-> getActiveSheet ()-> SetCellValue ('b5 ', 'b5'); $ objPHPExcel-> getActiveSheet ()-> SetCellValue ('C1', 'C1 '); $ objPHPExcel-> getActiveSheet ()-> SetCellValue ('C2 ', 'C2'); $ objPHPExcel-> getActiveSheet ()-> SetCellValue ('C3', 'C3 '); $ objPHPExcel-> getActiveSheet ()-> SetCellValue ('C4 ', 'C4'); $ objPHPExcel-> getActiveSheet ()-> SetCellValue ('c5 ', 'c5 '); // output the document $ objWriter = new PHPExcel_Writer_Excel5 ($ objPHPExcel); // Set the header information and output it to the browser // header ('content-Type: application/vnd. ms-excel '); // header ("Content-Disposition: attachment; filename=demo.xls"); // header ('cache-Control: max-age = 0 '); // $ objWriter-> save ('php: // output'); // save to a location $ objWriter-> save (dirname (_ FILE __). '/demo.xls ');