Worksheet is Blank

Topics: User Forum
Mar 8, 2013 at 8:04 AM
Hello ,
i tried below code and my worksheet is opening with blank:

<?php

/* require the PHPExcel file 1.0 /
require 'Classes/PHPExcel.php';
/* Set Memory Limit 1.0 /
ini_set("memory_limit","500M"); // set your memory limit in the case of memory problem
/* Caching to discISAM 1.0/
$cacheMethod = PHPExcel_CachedObjectStorageFactory:: cache_to_discISAM;
$cacheSettings = array( 'dir' => '/usr/local/tmp' // If you have a large file you can cache it optional
                  );
PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
$objPHPExcel = new PHPExcel();
$objPHPExcel->getActiveSheet()->setTitle('Data');
$objPHPExcel->getActiveSheet()->setCellValue('A1','hello');
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="Technical.xlsx"');
header('Cache-Control: max-age=0');
$objPHPExcel = new PHPExcel();
/ $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);/

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

Please help

Thanks
Mar 8, 2013 at 8:21 AM
Hi,

i have the same problem if i send the file directly to browser with Excel2007, so i change my export and save it first to disk
$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
$objWriter->setPreCalculateFormulas(false);
ob_end_clean();
$filename = 'Technical.xlsx';

$objWriter->save($filename);
header('Content-disposition: attachment; filename='.$filename);
header('Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Length: ' . filesize($filename));
header('Content-Transfer-Encoding: binary');
header('Cache-Control: must-revalidate');
header('Pragma: public');
if(ob_get_length() > 0) {
    ob_clean();
}
flush();
readfile($filename);
Hope it helps.
Mar 8, 2013 at 8:33 AM
I having the same problem i tries changing the code

<?php

/* require the PHPExcel file 1.0 /
require 'Classes/PHPExcel.php';
/* Set Memory Limit 1.0 /
ini_set("memory_limit","500M"); // set your memory limit in the case of memory problem
/* Caching to discISAM 1.0/
$cacheMethod = PHPExcel_CachedObjectStorageFactory:: cache_to_discISAM;
$cacheSettings = array( 'dir' => '/usr/local/tmp' // If you have a large file you can cache it optional
                  );
PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
$objPHPExcel = new PHPExcel();
$objPHPExcel->getActiveSheet()->setTitle('Data');
$objPHPExcel->getActiveSheet()->setCellValue('A1','hello');
/* header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="Technical.xlsx"');
header('Cache-Control: max-age=0');*/
$objPHPExcel = new PHPExcel();
$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);

//$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->setPreCalculateFormulas(false);
ob_end_clean();
$filename = 'Technical.xlsx';

$objWriter->save($filename);
header('Content-disposition: attachment; filename='.$filename);
header('Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Length: ' . filesize($filename));
header('Content-Transfer-Encoding: binary');
header('Cache-Control: must-revalidate');
header('Pragma: public');
if(ob_get_length() > 0) {
ob_clean();
}
flush();
readfile($filename);

// $objWriter->save('php://output');
exit;
?>
Mar 8, 2013 at 10:49 AM
HI,

can you post the error message you get in log files?

if often show where you find the solution
Mar 8, 2013 at 10:53 AM
i am newbie to this can you please let me know where actually we can find the log file