yii phpexcel自动生成文件保存到服务器上
最近再整一个报表任务,每天必须把表导出来按excel格式发送邮件给管理员,利用phpexcel把表保存到服务器上,然后再通过phpmailer发送就ok.
ob_end_clean();
ob_start();
$objectPHPExcel = new PHPExcel();
$objectPHPExcel->setActiveSheetIndex(0);
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue("A$i",$resource->source_name);
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue("B$i", $one);
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue("C$i", $two);
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue("D$i", $three);
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue("E$i", $price);
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue("F$i", $goods_price);
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue("G$i", $product);
$objectPHPExcel->setActiveSheetIndex(0)->setCellValue("H$i", $count);
$filename = "c.xls";
$objWriter = PHPExcel_IOFactory::createWriter($objectPHPExcel, 'Excel5');
$objWriter->save($filename);
注意再生成的时候打开生成的excel,再次生成就会出现fopen权限报错。帮助到的留言,哈哈
发布php中文网,转载请注明出处,感谢您的尊重!