Home  >  Article  >  php教程  >  yii phpexcel自动生成文件保存到服务器上

yii phpexcel自动生成文件保存到服务器上

WBOY
WBOYOriginal
2016-06-13 09:24:431181browse

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权限报错。帮助到的留言,哈哈

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn