码迷,mamicode.com
首页 > Web开发 > 详细

PHPExcel生成excel

时间:2019-10-25 16:26:45      阅读:91      评论:0      收藏:0      [点我收藏+]

标签:clu   max   ica   actor   cat   dex   etl   result   tac   

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

标签:clu   max   ica   actor   cat   dex   etl   result   tac   

原文地址:https://www.cnblogs.com/zinging/p/11738507.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!