PHPExcel_Writer_Exception : Could not close zip file php://output

Topics: Developer Forum, User Forum
Aug 26, 2013 at 7:01 AM
Edited Aug 26, 2013 at 7:02 AM
Hello,

I have the following fonction on a drupal V7 environment:

unction RSE_Export_export_stuff() {
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Europe/London');
require_once("sites/all/libraries/PHPExcel/Classes/PHPExcel.php");
require_once("sites/all/libraries/PHPExcel/Classes/PHPExcel/IOFactory.php");

//module_load_include('inc', 'phpexcel');
$data = array();
$headers = array();

// First worksheet

global $user;
$userId = $user->name;

...


// Freeze pane so that the heading line won't scroll
$objPHPExcel->getActiveSheet()->freezePane('A2');

// Save as an Excel BIFF (xls) file

$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
header('Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition:inline;filename=contacts.xlsx');
ob_clean();
if ( headers_sent() ) die("**Error: headers sent");
$objWriter->save('php://output');

exit;


}

It works fine on the development environment.

On the test environment, I have the following message:

PHPExcel_Writer_Exception : Could not close zip file php://output. dans PHPExcel_Writer_Excel2007->save() (ligne 348 dans /home/site1394/www/sites/all/libraries/PHPExcel/Classes/PHPExcel/Writer/Excel2007.php).

I have checked the rights on site/default/files and they are the same than on the development.

The goal is to generate an excel file and to download it on the PC.

Do you have an idea??

Thanks

Didier