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?
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();
I ran into something similar while using CakePHP building a spreadsheet with mergecells. It works fine for Excel 2003 but not Excel 2007 format. If I build the 2007 spreadsheet using:
$objPHPExcel->getActiveSheet()->mergeCells('C30:E30');
the spreadsheet loads fine. However using a variable in any way such as these variants:
$mergestr = '\'C'.(30+$i).':E'.(30+$i).'\'';
$objPHPExcel->getActiveSheet()->mergeCells($mergestr);
$objPHPExcel->getActiveSheet()->mergeCells(eval("return \$$mergestr;"));
$objPHPExcel->getActiveSheet()->mergeCells('\'C'.(30+$i).':E'.(30+$i).'\'');
$objPHPExcel->getActiveSheet()->mergeCells('C'.(30+$i).':E'.(30+$i));
I get the same error you do. I'm not sure if there is a way to escape a variable in a way PHPExcel will like for the Excel2007 writer. The Excel5 writer works fine with the last example above. Hope this helps someone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With