ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
All Data Structures Namespaces Files Functions Variables Typedefs Modules Pages
06largescale-with-cellcaching-sqlite3.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 
33 define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
34 
35 date_default_timezone_set('Europe/London');
36 
38 require_once dirname(__FILE__) . '/../Classes/PHPExcel.php';
39 
42  echo date('H:i:s') , " Enable Cell Caching using " , $cacheMethod , " method" , EOL;
43 } else {
44  echo date('H:i:s') , " Unable to set Cell Caching using " , $cacheMethod , " method, reverting to memory" , EOL;
45 }
46 
47 
48 // Create new PHPExcel object
49 echo date('H:i:s') , " Create new PHPExcel object" , EOL;
51 
52 // Set document properties
53 echo date('H:i:s') , " Set properties" , EOL;
54 $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
55  ->setLastModifiedBy("Maarten Balliauw")
56  ->setTitle("Office 2007 XLSX Test Document")
57  ->setSubject("Office 2007 XLSX Test Document")
58  ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
59  ->setKeywords("office 2007 openxml php")
60  ->setCategory("Test result file");
61 
62 
63 // Create a first sheet
64 echo date('H:i:s') , " Add data" , EOL;
65 $objPHPExcel->setActiveSheetIndex(0);
66 $objPHPExcel->getActiveSheet()->setCellValue('A1', "Firstname");
67 $objPHPExcel->getActiveSheet()->setCellValue('B1', "Lastname");
68 $objPHPExcel->getActiveSheet()->setCellValue('C1', "Phone");
69 $objPHPExcel->getActiveSheet()->setCellValue('D1', "Fax");
70 $objPHPExcel->getActiveSheet()->setCellValue('E1', "Is Client ?");
71 
72 
73 // Hide "Phone" and "fax" column
74 echo date('H:i:s') , " Hide 'Phone' and 'fax' columns" , EOL;
75 $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setVisible(false);
76 $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setVisible(false);
77 
78 
79 // Set outline levels
80 echo date('H:i:s') , " Set outline levels" , EOL;
81 $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setOutlineLevel(1)
82  ->setVisible(false)
83  ->setCollapsed(true);
84 
85 // Freeze panes
86 echo date('H:i:s') , " Freeze panes" , EOL;
87 $objPHPExcel->getActiveSheet()->freezePane('A2');
88 
89 
90 // Rows to repeat at top
91 echo date('H:i:s') , " Rows to repeat at top" , EOL;
92 $objPHPExcel->getActiveSheet()->getPageSetup()->setRowsToRepeatAtTopByStartAndEnd(1, 1);
93 
94 
95 // Add data
96 for ($i = 2; $i <= 5000; $i++) {
97  $objPHPExcel->getActiveSheet()->setCellValue('A' . $i, "FName $i")
98  ->setCellValue('B' . $i, "LName $i")
99  ->setCellValue('C' . $i, "PhoneNo $i")
100  ->setCellValue('D' . $i, "FaxNo $i")
101  ->setCellValue('E' . $i, true);
102 }
103 
104 
105 // Set active sheet index to the first sheet, so Excel opens this as the first sheet
106 $objPHPExcel->setActiveSheetIndex(0);
107 
108 
109 // Save Excel 2007 file
110 echo date('H:i:s') , " Write to Excel2007 format" , EOL;
111 $callStartTime = microtime(true);
112 
114 $objWriter->save(str_replace('.php', '.xlsx', __FILE__));
115 $callEndTime = microtime(true);
117 
118 echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
119 echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
120 // Echo memory usage
121 echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
122 
123 
124 // Echo memory peak usage
125 echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
126 
127 // Echo done
128 echo date('H:i:s') , " Done writing file" , EOL;
129 echo 'File has been created in ' , getcwd() , EOL;
static createWriter(PHPExcel $phpExcel, $writerType='')
Create PHPExcel_Writer_IWriter.
Definition: IOFactory.php:132
if($is_dev) echo "Review changes write something in WHATSNEW and and then commit with log PHP_EOL
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
static setCacheStorageMethod( $method=PHPExcel_CachedObjectStorageFactory::cache_in_memory, $arguments=array())
Set the method that should be used for cell cacheing.
Definition: Settings.php:176
$cacheMethod
Include PHPExcel.