PHPExcel Warning/Error when opening document

PHPphpexcel

I have built an Excel document using the PHPExcel Library. My document opens and looks fine both in Numbers (mac) and Office 2007 (windows). I am saving my file as a .xlsx file.

When I open the file, although it displays properly, it gives the following errors/warnings.

In Numbers, it gives the warning "Password protection on sheets isn't supported and was removed"

In Office 2007 it gives te error "Excel found unreadable content in 'filename.xlsx'. Do you want to recover the contents of this workbook? If you trust the source of this workbook, click Yes." When I click yes, everything displays fine, and it says "Removed Records: Merge cells from /sl/worksheets/sheet1.xml part".

It should be noted that I did not add any password to my file. I also have only one workbook. Anyone know how I can get rid of these or what might be causing them?

Best Answer

I've had the same problem and i resolved simply putting an

exit();

justafter the $objWriter->save('php://output'); command.

Eg.

// Redirect output to a client’s web browser (Excel2007)
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="industrializzazione_RTW_'.$rows[0]['stagione'].'.xlsx"');
header('Cache-Control: max-age=0');

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); 
$objWriter->save('php://output'); 
exit();
Related Topic