ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
01simple-download-ods.php
Go to the documentation of this file.
1 <?php
29 error_reporting(E_ALL);
30 ini_set('display_errors', TRUE);
31 ini_set('display_startup_errors', TRUE);
32 date_default_timezone_set('Europe/London');
33 
34 if (PHP_SAPI == 'cli')
35  die('This example should only be run from a Web Browser');
36 
38 require_once dirname(__FILE__) . '/../Classes/PHPExcel.php';
39 
40 
41 // Create new PHPExcel object
43 
44 // Set document properties
45 $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
46  ->setLastModifiedBy("Maarten Balliauw")
47  ->setTitle("Office 2007 XLSX Test Document")
48  ->setSubject("Office 2007 XLSX Test Document")
49  ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
50  ->setKeywords("office 2007 openxml php")
51  ->setCategory("Test result file");
52 
53 
54 // Add some data
55 $objPHPExcel->setActiveSheetIndex(0)
56  ->setCellValue('A1', 'Hello')
57  ->setCellValue('B2', 'world!')
58  ->setCellValue('C1', 'Hello')
59  ->setCellValue('D2', 'world!');
60 
61 // Miscellaneous glyphs, UTF-8
62 $objPHPExcel->setActiveSheetIndex(0)
63  ->setCellValue('A4', 'Miscellaneous glyphs')
64  ->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');
65 
66 // Rename worksheet
67 $objPHPExcel->getActiveSheet()->setTitle('Simple');
68 
69 
70 // Set active sheet index to the first sheet, so Excel opens this as the first sheet
71 $objPHPExcel->setActiveSheetIndex(0);
72 
73 
74 // Redirect output to a client’s web browser (OpenDocument)
75 header('Content-Type: application/vnd.oasis.opendocument.spreadsheet');
76 header('Content-Disposition: attachment;filename="01simple.ods"');
77 header('Cache-Control: max-age=0');
78 // If you're serving to IE 9, then the following may be needed
79 header('Cache-Control: max-age=1');
80 
81 // If you're serving to IE over SSL, then the following may be needed
82 header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
83 header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified
84 header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
85 header ('Pragma: public'); // HTTP/1.0
86 
88 $objWriter->save('php://output');
$objPHPExcel
Include PHPExcel.
static createWriter(PHPExcel $phpExcel, $writerType='')
Create PHPExcel_Writer_IWriter.
Definition: IOFactory.php:132
Add a drawing to the header
Definition: 04printing.php:69