ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
22heavilyformatted.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
34define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
35
36date_default_timezone_set('Europe/London');
37
39require_once dirname(__FILE__) . '/../Classes/PHPExcel.php';
40
41
42// Create new PHPExcel object
43echo date('H:i:s') , " Create new PHPExcel object" , EOL;
45
46// Set document properties
47echo date('H:i:s') , " Set document properties" , EOL;
48$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
49 ->setLastModifiedBy("Maarten Balliauw")
50 ->setTitle("Office 2007 XLSX Test Document")
51 ->setSubject("Office 2007 XLSX Test Document")
52 ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
53 ->setKeywords("office 2007 openxml php")
54 ->setCategory("Test result file");
55
56
57// Add some data
58echo date('H:i:s') , " Add some data" , EOL;
59$objPHPExcel->setActiveSheetIndex(0);
60
61$objPHPExcel->getActiveSheet()->getStyle('A1:T100')->applyFromArray(
62 array('fill' => array(
64 'color' => array('argb' => 'FFCCFFCC')
65 ),
66 'borders' => array(
67 'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN),
68 'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM)
69 )
70 )
71 );
72
73$objPHPExcel->getActiveSheet()->getStyle('C5:R95')->applyFromArray(
74 array('fill' => array(
76 'color' => array('argb' => 'FFFFFF00')
77 ),
78 )
79 );
80
81// Save Excel 2007 file
82echo date('H:i:s') , " Write to Excel2007 format" , EOL;
83$callStartTime = microtime(true);
84
86$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
87$callEndTime = microtime(true);
89
90echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
91echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
92// Echo memory usage
93echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
94
95
96// Save Excel 95 file
97echo date('H:i:s') , " Write to Excel5 format" , EOL;
98$callStartTime = microtime(true);
99
101$objWriter->save(str_replace('.php', '.xls', __FILE__));
102$callEndTime = microtime(true);
104
105echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
106echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
107// Echo memory usage
108echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
109
110
111// Echo memory peak usage
112echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
113
114// Echo done
115echo date('H:i:s') , " Done writing file" , EOL;
116echo 'File has been created in ' , getcwd() , EOL;
memory_get_peak_usage(true)/1024/1024)
const EOL
$callStartTime
memory_get_usage(true)/1024/1024)
sprintf('%.4f', $callTime)
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
An exception for terminatinating execution or to throw for unit testing.
static createWriter(PHPExcel $phpExcel, $writerType='')
Create PHPExcel_Writer_IWriter.
Definition: IOFactory.php:132
const FILL_SOLID
Definition: Fill.php:40