1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- error_reporting(E_ALL);
- ini_set('display_errors', TRUE);
- ini_set('display_startup_errors', TRUE);
- date_default_timezone_set('Europe/London');
- if (PHP_SAPI == 'cli')
- die('This example should only be run from a Web Browser');
- require_once dirname(__FILE__) . '/../Classes/PHPExcel.php';
- $objPHPExcel = new PHPExcel();
- $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");
- $objPHPExcel->setActiveSheetIndex(0)
- ->setCellValue('A1', 'Hello')
- ->setCellValue('B2', 'world!')
- ->setCellValue('C1', 'Hello')
- ->setCellValue('D2', 'world!');
- $objPHPExcel->setActiveSheetIndex(0)
- ->setCellValue('A4', 'Miscellaneous glyphs')
- ->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');
- $objPHPExcel->getActiveSheet()->setTitle('Simple');
- $objPHPExcel->setActiveSheetIndex(0);
- header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
- header('Content-Disposition: attachment;filename="01simple.xlsx"');
- header('Cache-Control: max-age=0');
- header('Cache-Control: max-age=1');
- header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
- header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
- header ('Cache-Control: cache, must-revalidate');
- header ('Pragma: public');
- $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
- $objWriter->save('php://output');
- exit;
|