问高手 一个phpexcel导出excel的问题

weixin_38050751 2018-11-30 05:52:13
 开发四年只会写业务代码,分布式高并发都不会还做程序员?->>>    phpexcel 导出excel的时候 在服务器和 本地都同时导出了一份,为什么的我服务器上面的excel打开有数据,本地的打开是空白的,啥都没有啦

$param = [
                'uid' => 2120872
            ];
            $order = Jdbc::getMemberDate('new_order',$param,2);

            $objPHPExcel = new \PHPExcel();
            // 设置
            $objSheet = $objPHPExcel->getActiveSheet();
            // 设置表的title
            $objSheet->setTitle("XXXXXXX");
            // 遍历表列
            $objSheet->setCellValue("A1","oid")
                     ->setCellValue("B1","uid")
                     ->setCellValue("C1","bespeak_store_id")
                     ->setCellValue("D1","store_id")
                     ->setCellValue("E1","cartid")
                     ->setCellValue("F1",'order_number')
                     ->setCellValue("G1",'price')
                     ->setCellValue("H1",'order_time')
                     ->setCellValue("I1",'good_number')
                     ->setCellValue("J1",'type');
            $j = 2;
            foreach ($order as $k => $v){
                $objSheet->setCellValue("A".$j,$v['oid'])
                         ->setCellValue("B".$j,$v['uid'])
                         ->setCellValue("C".$j,$v['bespeak_store_id'])
                         ->setCellValue("D".$j,$v['store_id'])
                         ->setCellValue("E".$j,$v['cartid'])
                         ->setCellValue("F".$j,$v['order_number'])
                         ->setCellValue("G".$j,$v['price'])
                         ->setCellValue("H".$j,$v['order_time'])
                         ->setCellValue("I".$j,$v['good_number'])
                         ->setCellValue("J".$j,$v['type']);
                $j++;
            }
            $file_name = "order订单统计表".date("Y-m-d",time()).".xls";
            $response = $this->response();
            $response->withHeader('Cache-Control','public');
            $response->withHeader('Content-Type','application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
            $response->withHeader('Content-Type','application/octet-stream');
            $response->withHeader('Content-Type','application/download');
            $response->withHeader('Content-Transfer-Encoding','binary');
            $response->withHeader('Last-Modified','' . gmdate("D, d M Y H:i:s") . 'GMT');
            $response->withHeader('Cache-Control','must-revalidate, post-check=0, pre-check=0');
            $response->withHeader('Pragma','no-cache');
            $response->withHeader('Content-Type','application/download');
            $response->withHeader('Content-Disposition','attachment;filename='.$file_name.'');
            $xlsWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
            $xlsWriter->save($file_name); // 'php://output'
...全文
17 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复

474

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧