Home  >  Article  >  Backend Development  >  yii phpexcel automatically generates files and saves them to the server_PHP tutorial

yii phpexcel automatically generates files and saves them to the server_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:18:07999browse

yii phpexcel automatically generates files and saves them on the server

I recently completed a report task. I had to export the table and send it to the administrator via email in excel format every day. I used phpexcel to save the table to the server, and then sent it through phpmailer.

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);



Note that when you open the generated excel again, an fopen permission error will appear when you generate it again. Helpful message, haha

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/885676.htmlTechArticleyii phpexcel automatically generates files and saves them on the server. Recently, a report task has been completed. The table must be exported and pressed in excel every day. Send an email to the administrator and use phpexcel to save the table to the server...
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