phpexcel常用处理
##导入类库require 'PHPExcel/Classes/PHPExcel.php';require 'PHPExcel/Classes/PHPExcel/Writer/Excel5.php'; //非07格式的写出类 ##基础属性设定$objPHPExcel = /PHPExcel_IOFactory::load('a.xls'); //读入指定excel文件$objPHPExcel->setActiveSheetIndex(0); //指定活动工作表$objPHPExcel->getActiveSheet()->getDefaultStyle()->getFont()->setName('宋体');$objPHPExcel->getProperties()->setTitle('xxx'); ##单元格编辑$objPHPExcel->getActiveSheet()->setCellValue('A3', 'xxx'); //设定A3单元格值为xxx ##单元格绘图$objDrawing = new /PHPExcel_Worksheet_Drawing();$objDrawing->setPath('a.jpg'); //指定图片路径。若要远程图片需PHPExcel/Classes/PHPExcel/Worksheet/Drawing.php:106处file_exists换成file_get_contents$objDrawing->setCoordinates('A4'); //指定在A4单元格绘图$objDrawing->setName('Photo');$objDrawing->setDescription('Photo');$objDrawing->setHeight(120);$objDrawing->setWidth(100);$objDrawing->setOffsetX(7);$objDrawing->setOffsetY(7);$objDrawing->setWorksheet($objPHPExcel->getActiveSheet()); ##excel文件浏览器下载导出$filename='a.xls';$encoded_filename = rawurlencode($filename);$ua = $_SERVER["HTTP_USER_AGENT"];header('Content-type: application/vnd.ms-excel');if (preg_match("/MSIE/", $ua) || preg_match("/Trident//7.0/", $ua) || preg_match("/Edge/", $ua)) { header('Content-Disposition: attachment; filename="' . $encoded_filename . '"');} else if (preg_match("/Firefox/", $ua)) { header("Content-Disposition: attachment; filename*=/"utf8''" . $filename . '"');} else { header('Content-Disposition: attachment; filename="' . $filename . '"');}header("Pragma:no-cache");header("Expires:0");$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');$objWriter->save('php://output'); ##excel文件html显示(可用于调试)$objWriter = new /PHPExcel_Writer_HTML($objPHPExcel);$objWriter->save('php://output');