ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
01simple-download-xls.php
Go to the documentation of this file.
1<?php
29error_reporting(E_ALL);
30ini_set('display_errors', TRUE);
31ini_set('display_startup_errors', TRUE);
32date_default_timezone_set('Europe/London');
33
34if (PHP_SAPI == 'cli')
35 die('This example should only be run from a Web Browser');
36
38require_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 (Excel5)
75header('Content-Type: application/vnd.ms-excel');
76header('Content-Disposition: attachment;filename="01simple.xls"');
77header('Cache-Control: max-age=0');
78// If you're serving to IE 9, then the following may be needed
79header('Cache-Control: max-age=1');
80
81// If you're serving to IE over SSL, then the following may be needed
82header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
83header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified
84header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
85header ('Pragma: public'); // HTTP/1.0
86
88$objWriter->save('php://output');
$objPHPExcel
Include PHPExcel.
An exception for terminatinating execution or to throw for unit testing.
static createWriter(PHPExcel $phpExcel, $writerType='')
Create PHPExcel_Writer_IWriter.
Definition: IOFactory.php:132