phpexcel在linux服务器上下载excel文件打不开

浏览:1976 发布日期:2017/11/16 分类:求助交流 关键字: phpexcel
 vendor('PHPExcel.PHPExcel');
            $phpexcel=new \PHPExcel();
            $currentSheet=$phpexcel->getActiveSheet();//获取当前活动sheet
            $currentSheet->setTitle('helloworld');//给当前活动sheet设置名称
            $currentSheet->setCellValue('A1', '姓名')->setCellValue('B1', '电话');
            $currentSheet->setCellValue('A2', '李老')->setCellValue('B2', '111111111');
            $excelSave=\PHPExcel_IOFactory::createWriter($phpexcel, 'Excel2007');
            header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
            header('Content-Disposition: attachment;filename="01simple.xlsx"');
            header('Cache-Control: max-age=0');
            $excelSave->save('php://output');
此代码在本地windows上测试没有任何问题,下载打开都正常,但是在linux服务器上下载下来文件大小为0,打不开,这是什么原因呢? vendor('PHPExcel.PHPExcel');
            $phpexcel=new \PHPExcel();
            $currentSheet=$phpexcel->getActiveSheet();//获取当前活动sheet
            $currentSheet->setTitle('helloworld');//给当前活动sheet设置名称
            //$currentSheet->fromArray($viewData);
            $currentSheet->setCellValue('A1', '姓名')->setCellValue('B1', '电话');
            $currentSheet->setCellValue('A2', '李老')->setCellValue('B2', '111111111');
            $excelSave=\PHPExcel_IOFactory::createWriter($phpexcel, 'Excel2007');
            $excelSave->save('01simple.xlsx');
另如果不输出至浏览器下载,而使用直接保存,则没有这种问题,一下为服务器相关信息,大神求助
最佳答案
评论( 相关
后面还有条评论,点击查看>>