I'm using php and mysql.
Excel - 2007
I export data to excel sheet using PHPExcel Library.
I hope someone use this library. I'm newbiw to PHPExcel Library.
well, I come to my question. when I try to save excel file in client server the junk data is saved. I don't know why it is come.
In server side, excel file save correct data. The problem is in client side only, could anyone know about this problem? Please help out.
Please check my code.
Code: Select all
date_default_timezone_set('Europe/London');
include_once($_SERVER['DOCUMENT_ROOT']."/../include/common_class.php");
include_once(DOCUMENT_ROOT."/../include/db_class_mysqli.php");
include_once(DOCUMENT_ROOT."/../Classes/PHPExcel.php");
$objPHPExcel = new PHPExcel();
// Set properties
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
->setLastModifiedBy("Maarten Balliauw")
->setTitle("Office 2007 XLSX Test Document")
->setSubject("Office 2007 XLSX Test Document")
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
->setKeywords("office 2007 openxml php")
->setCategory("Test result file");
// Add some data
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A1', 'Hello')
->setCellValue('B2', 'world!')
->setCellValue('C1', 'Hello')
->setCellValue('D2', 'world!');
// Miscellaneous glyphs, UTF-8
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A4', 'Miscellaneous glyphs')
->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');
// Rename sheet
$objPHPExcel->getActiveSheet()->setTitle('Simple');
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
$objPHPExcel->setActiveSheetIndex(0);
// Redirect output to a client’s web browser (Excel2007)
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="01simple.xlsx"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('php://output');
exit;
thenndral