1

I using exporting data to excel 2007 using PhpExcel 1.8.0. Its working but Excel File is saved in Client side but when I open the downloaded Excel file, I get the warning message

We found a problem with some content in 'filename.xlsx'. Do you want us to try to recover as much as we can? If you trust the source of this workbook, click Yes.

I am using PhpExcel library in Magento.

Could anyone help me to solve this problem?

Code is below:

$objPHPExcel->getActiveSheet()->setTitle($store_name." Product List");
$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
header("Content-Disposition: attachment; filename=".Mage::getBaseDir().'/media/productpricinglist/'.$store_name.'product_list.xlsx');
header("Cache-Control: max-age=2");
ob_clean();
$objWriter->save("php://output");
pnuts
  • 58,317
  • 11
  • 87
  • 139
user123456789
  • 189
  • 3
  • 5
  • 17

1 Answers1

1

I had this problem too. I just added exit; at the end of my PHP script

Javad Yousefi
  • 2,250
  • 4
  • 35
  • 52