PHPExcel生成excel
Posted 诗里刻画的影子
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHPExcel生成excel相关的知识,希望对你有一定的参考价值。
include ‘statics/phpExcel/PHPExcel.php‘; include ‘statics/PHPExcel/PHPExcel/Writer/Excel5.php‘; $objPHPExcel = new PHPExcel(); ini_set("memory_limit", "1024M"); // 设置php可使用内存 set_time_limit(0); $objPHPExcel->getProperties()->setCreator($nickname) ->setLastModifiedBy($nickname) ->setTitle("数据EXCEL导出") ->setSubject("数据EXCEL导出") ->setDescription("备份查询数据") ->setKeywords("excel") ->setCategory("result file"); $objPHPExcel->getActiveSheet()->setCellValue(‘A1‘, ‘日期‘); $objPHPExcel->getActiveSheet()->setCellValue(‘B1‘, ‘反馈数量‘); $objPHPExcel->getActiveSheet()->setCellValue(‘C1‘, ‘反馈人数‘); /*$objPHPExcel->getActiveSheet()->setCellValue(‘Z1‘, ‘来源页URL‘);*/ if($feed){ $i=2; foreach ($feed as $key => $v) { $objPHPExcel->getActiveSheet()->setCellValue(‘A‘.$i,$tim[$key]); $objPHPExcel->getActiveSheet()->setCellValue(‘B‘.$i,$v); $objPHPExcel->getActiveSheet()->setCellValue(‘C‘.$i,$num[$key]); $i++; } $objPHPExcel->getActiveSheet()->setTitle(‘反馈统计表‘);//重命名工作表 $objPHPExcel->setActiveSheetIndex(0);//设置打开excel时显示的工作表 $callStartTime = microtime(true); $filename=‘PDT‘.(date(‘Y-m-d,H:i:s‘)); header(‘Content-Type: application/vnd.ms-excel‘); header(‘Content-Disposition: attachment;filename="‘.$filename.‘.xls"‘); //日期为文件名后缀 header(‘Cache-Control: max-age=0‘); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, ‘Excel5‘); $objWriter->save(‘php://output‘);
PHPExcel类库下载地址:https://www.php.cn/xiazai/leiku/1491
以上是关于PHPExcel生成excel的主要内容,如果未能解决你的问题,请参考以下文章