PhpExcel is very convenient to operate on excel, especially when images can be conveniently added. jpggifpng format is supported.
PhpExcel is very convenient to operate on excel, especially when images can be conveniently added. jpg and png formats are supported.
: Http://www.codeplex.com/PHPExcel
The following are the usage methods
Include 'phpexcel. php ';
Include 'phpexcel/Writer/excel2007.php ';
// Or include 'phpexcel/Writer/excel5.php'; for output. xls
Create an excel file
$ ObjPHPExcel = new PHPExcel ();
Save the excel-2007 format
$ ObjWriter = new PHPExcel_Writer_Excel2007 ($ objPHPExcel );
// Or $ objWriter = new PHPExcel_Writer_Excel5 ($ objPHPExcel); non-2007 format
$ ObjWriter-> save(”xxx.xlsx ");
Output directly to the browser
$ ObjWriter = new PHPExcel_Writer_Excel5 ($ objPHPExcel );
Header ("Pragma: public ");
Header ("Expires: 0 ″);
Header ("Cache-Control: must-revalidate, post-check = 0, pre-check = 0 ″);
Header ("Content-Type: application/force-download ");
Header ("Content-Type: application/vnd. ms-execl ");
Header ("Content-Type: application/octet-stream ");
Header ("Content-Type: application/download ");;
Header ('content-Disposition: attachment?filename=#resume.xls "');
Header ("Content-Transfer-Encoding: binary ");
$ ObjWriter-> save ('php: // output ');
---------------------------------------
Set excel attributes:
Created
$ ObjPHPExcel-> getProperties ()-> setCreator ("Maarten Balliauw ");
Last modified
$ ObjPHPExcel-> getProperties ()-> setLastModifiedBy ("Maarten Balliauw ");
Title
$ ObjPHPExcel-> getProperties ()-> setTitle ("Office 2007 XLSX Test Document ");
Question
$ ObjPHPExcel-> getProperties ()-> setSubject ("Office 2007 XLSX Test Document ");
Description
$ ObjPHPExcel-> getProperties ()-> setDescription ("Test document for Office 2007 XLSX, generated using PHP classes .");
Keywords
$ ObjPHPExcel-> getProperties ()-> setKeywords ("office 2007 openxml php ");
Type
$ ObjPHPExcel-> getProperties ()-> setCategory ("Test result file ");
---------------------------------------
Set the current sheet
$ ObjPHPExcel-> setActiveSheetIndex (0 );
Set sheet name
$ ObjPHPExcel-> getActiveSheet ()-> setTitle ('simple ');
Set the cell value
$ ObjPHPExcel-> getActiveSheet ()-> setCellValue ('A1', 'string ');
$ ObjPHPExcel-> getActiveSheet ()-> setCellValue ('A2 ', 12 );
$ ObjPHPExcel-> getActiveSheet ()-> setCellValue ('A3 ', true );
$ ObjPHPExcel-> getActiveSheet ()-> setCellValue ('c5 ',' = SUM (C2: C4 )');
$ ObjPHPExcel-> getActiveSheet ()-> setCellValue ('b8', '= MIN (B2: C5 )');
Merge cells
$ ObjPHPExcel-> getActiveSheet ()-> mergeCells ('a18: e22 ′);
Separate cells
$ ObjPHPExcel-> getActiveSheet ()-> unmergeCells ('a28: b28 ′);