data .xlsx corrupt because error output only 0kb

Topics: Developer Forum, Project Management Forum, User Forum
Jan 3, 2014 at 6:05 PM
PHPExcel me no problems when exported but when I open in Ms.Excel2007, it can not be opened because it is corrupt or invalid format,
because when i want to download it output only 0kb

This sample code themselves:
// redirect output to client browser
            header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
            header('Content-Disposition: attachment;filename="backup_categories_products.xlsx"');
            header('Cache-Control: max-age=0');
            $objWriter = PHPExcel_IOFactory::createWriter($workbook,'Excel2007');           
            $objWriter->save('$filename');

            // Clear the spreadsheet caches
            $this->clearSpreadsheetCache();
            exit;
Please help me to resolve this problem
thanks
Coordinator
Jan 3, 2014 at 8:24 PM
So what's the value of '$filename' and why is it quoted? That will literally try to save the file to a file called $filename (not the value of the $filename variable, but actually called $filename) on your server.

Save to 'php://output' if you want to send the file to the browser
Jan 4, 2014 at 5:30 AM
but if I set it to Save to 'php :/ / output' message "failed to open the Save to 'php :/ / output'"

explanation please