开发者

PHPExcel exception: "Could not close zip file ... "

I am using XAMPP a Mac for local development, but I used this code at work (using Windows and an otherwise identical development environment) and it worked fine:

$objPHPExcel = new PHPExcel();
$sheet       = $objPHPExcel->createSheet();
$sh开发者_StackOverflow社区eet->fromArray($a);
...
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
//$objWriter->save('P:/Projects/Mess3/Sadness.xlsx');
$objWriter->save('/Users/tjb1982/Desktop/sadness.xlsx');

The commented-out text works with my Windows system at work. I tried to output the file to 'php://output' and got a garbled mess (is that what is to be expected?).

I can't seem to find anyone who is experiencing this problem outside of those who had permissions problems or had the file open when they were trying to save it. Please help!


I was getting the same error "Cannot close zip file.." and realized it didn't have permissions to write to that directory. Check your write permissions. (IIS8 + php + mysql + oracle)

Once i allowed write permissions problem was immediately fixed.


Generally this means one of 3 things:

The directory where you're trying to save the file doesn't exist
The directory/file has permissions that preclude you from writing to it
The file is already open in some other application, or has a lock on it 


I had the same problem, just added the path in the save method and it worked

$objWriter->save(dirname(FILE)."dir1"."/".$file.".xlsx");


I found that this problem is caused when you execute the code once and then open the outputted excel file with Office excel. Try closing the file in excel and then try! Hope this helps!


I had the same problem, actually you have to modify the basic rights of reading and writing given to your PHPWord directory:

chmod -R 777 PHPWord/
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜