@@ -30,26 +30,26 @@ discard block |
||
30 | 30 | ini_set('display_errors', TRUE); |
31 | 31 | ini_set('display_startup_errors', TRUE); |
32 | 32 | |
33 | -define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />'); |
|
33 | +define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '<br />'); |
|
34 | 34 | |
35 | 35 | /** PHPExcel */ |
36 | 36 | require_once dirname(__FILE__) . '/../src/Bootstrap.php'; |
37 | 37 | |
38 | 38 | |
39 | 39 | // Set timezone |
40 | -echo date('H:i:s') , " Set timezone" , EOL; |
|
40 | +echo date('H:i:s'), " Set timezone", EOL; |
|
41 | 41 | date_default_timezone_set('UTC'); |
42 | 42 | |
43 | 43 | // Set value binder |
44 | -echo date('H:i:s') , " Set value binder" , EOL; |
|
45 | -\PHPExcel\Cell::setValueBinder( new \PHPExcel\Cell\AdvancedValueBinder() ); |
|
44 | +echo date('H:i:s'), " Set value binder", EOL; |
|
45 | +\PHPExcel\Cell::setValueBinder(new \PHPExcel\Cell\AdvancedValueBinder()); |
|
46 | 46 | |
47 | 47 | // Create new PHPExcel object |
48 | -echo date('H:i:s') , " Create new PHPExcel object" , EOL; |
|
48 | +echo date('H:i:s'), " Create new PHPExcel object", EOL; |
|
49 | 49 | $objPHPExcel = new \PHPExcel\Spreadsheet(); |
50 | 50 | |
51 | 51 | // Set document properties |
52 | -echo date('H:i:s') , " Set document properties" , EOL; |
|
52 | +echo date('H:i:s'), " Set document properties", EOL; |
|
53 | 53 | $objPHPExcel->getProperties()->setCreator("Maarten Balliauw") |
54 | 54 | ->setLastModifiedBy("Maarten Balliauw") |
55 | 55 | ->setTitle("Office 2007 XLSX Test Document") |
@@ -59,17 +59,17 @@ discard block |
||
59 | 59 | ->setCategory("Test result file"); |
60 | 60 | |
61 | 61 | // Set default font |
62 | -echo date('H:i:s') , " Set default font" , EOL; |
|
62 | +echo date('H:i:s'), " Set default font", EOL; |
|
63 | 63 | $objPHPExcel->getActiveSheet()->getDefaultStyle()->getFont()->setName('Arial'); |
64 | 64 | $objPHPExcel->getActiveSheet()->getDefaultStyle()->getFont()->setSize(10); |
65 | 65 | |
66 | 66 | // Set column widths |
67 | -echo date('H:i:s') , " Set column widths" , EOL; |
|
67 | +echo date('H:i:s'), " Set column widths", EOL; |
|
68 | 68 | $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setAutoSize(true); |
69 | 69 | $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(14); |
70 | 70 | |
71 | 71 | // Add some data, resembling some different data types |
72 | -echo date('H:i:s') , " Add some data" , EOL; |
|
72 | +echo date('H:i:s'), " Add some data", EOL; |
|
73 | 73 | $objPHPExcel->getActiveSheet()->setCellValue('A1', 'String value:') |
74 | 74 | ->setCellValue('B1', 'Mark Baker'); |
75 | 75 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | ->setCellValue('B28', '=SUM(B2:B9)'); |
156 | 156 | |
157 | 157 | // Rename worksheet |
158 | -echo date('H:i:s') , " Rename worksheet" , EOL; |
|
158 | +echo date('H:i:s'), " Rename worksheet", EOL; |
|
159 | 159 | $objPHPExcel->getActiveSheet()->setTitle('Advanced value binder'); |
160 | 160 | |
161 | 161 | |
@@ -164,20 +164,20 @@ discard block |
||
164 | 164 | |
165 | 165 | |
166 | 166 | // Save Excel 2007 file |
167 | -echo date('H:i:s') , " Write to Excel2007 format" , EOL; |
|
167 | +echo date('H:i:s'), " Write to Excel2007 format", EOL; |
|
168 | 168 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007'); |
169 | 169 | $objWriter->save(str_replace('.php', '.xlsx', __FILE__)); |
170 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
170 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
171 | 171 | // Save Excel5 file |
172 | -echo date('H:i:s') , " Write to Excel5 format" , EOL; |
|
172 | +echo date('H:i:s'), " Write to Excel5 format", EOL; |
|
173 | 173 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5'); |
174 | 174 | $objWriter->save(str_replace('.php', '.xls', __FILE__)); |
175 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
175 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
176 | 176 | |
177 | 177 | |
178 | 178 | // Echo memory peak usage |
179 | -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
179 | +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; |
|
180 | 180 | |
181 | 181 | // Echo done |
182 | -echo date('H:i:s') , " Done writing file" , EOL; |
|
183 | -echo 'File has been created in ' , getcwd() , EOL; |
|
182 | +echo date('H:i:s'), " Done writing file", EOL; |
|
183 | +echo 'File has been created in ', getcwd(), EOL; |
@@ -34,12 +34,12 @@ discard block |
||
34 | 34 | require_once dirname(__FILE__) . '/../Classes/PHPExcel/IOFactory.php'; |
35 | 35 | |
36 | 36 | |
37 | -echo date('H:i:s') , " Load from XML file" , PHP_EOL; |
|
37 | +echo date('H:i:s'), " Load from XML file", PHP_EOL; |
|
38 | 38 | $inputFileName = "XMLTest.xml"; |
39 | 39 | |
40 | 40 | /** Identify the type of $inputFileName **/ |
41 | 41 | $inputFileType = \PHPExcel\IOFactory::identify($inputFileName); |
42 | -echo 'Loading ' , $inputFileName , ' using ' , $inputFileType , " Reader" , PHP_EOL; |
|
42 | +echo 'Loading ', $inputFileName, ' using ', $inputFileType, " Reader", PHP_EOL; |
|
43 | 43 | |
44 | 44 | /** Create a new Reader of the type that has been identified **/ |
45 | 45 | $objReader = \PHPExcel\IOFactory::createReader($inputFileType); |
@@ -47,14 +47,14 @@ discard block |
||
47 | 47 | $objPHPExcel = $objReader->load($inputFileName); |
48 | 48 | |
49 | 49 | |
50 | -echo date('H:i:s') , " Write to Excel2007 format" , PHP_EOL; |
|
50 | +echo date('H:i:s'), " Write to Excel2007 format", PHP_EOL; |
|
51 | 51 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007'); |
52 | 52 | $objWriter->save(str_replace('.php', '.xlsx', __FILE__)); |
53 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', __FILE__) , PHP_EOL; |
|
53 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xlsx', __FILE__), PHP_EOL; |
|
54 | 54 | |
55 | 55 | |
56 | 56 | // Echo memory peak usage |
57 | -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL; |
|
57 | +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", PHP_EOL; |
|
58 | 58 | |
59 | 59 | // Echo done |
60 | -echo date('H:i:s') , " Done writing file" , PHP_EOL; |
|
60 | +echo date('H:i:s'), " Done writing file", PHP_EOL; |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | ini_set('display_startup_errors', TRUE); |
32 | 32 | date_default_timezone_set('Europe/London'); |
33 | 33 | |
34 | -define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />'); |
|
34 | +define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '<br />'); |
|
35 | 35 | |
36 | 36 | date_default_timezone_set('Europe/London'); |
37 | 37 | |
@@ -52,14 +52,14 @@ discard block |
||
52 | 52 | $rendererLibraryPath = '/php/libraries/PDF/' . $rendererLibrary; |
53 | 53 | |
54 | 54 | |
55 | -echo date('H:i:s') , " Hide grid lines" , EOL; |
|
55 | +echo date('H:i:s'), " Hide grid lines", EOL; |
|
56 | 56 | $objPHPExcel->getActiveSheet()->setShowGridLines(false); |
57 | 57 | |
58 | -echo date('H:i:s') , " Set orientation to landscape" , EOL; |
|
58 | +echo date('H:i:s'), " Set orientation to landscape", EOL; |
|
59 | 59 | $objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(\PHPExcel\Worksheet\PageSetup::ORIENTATION_LANDSCAPE); |
60 | 60 | |
61 | 61 | |
62 | -echo date('H:i:s') , " Write to PDF format using {$rendererName}" , EOL; |
|
62 | +echo date('H:i:s'), " Write to PDF format using {$rendererName}", EOL; |
|
63 | 63 | |
64 | 64 | if (!\PHPExcel\Settings::setPdfRenderer( |
65 | 65 | $rendererName, |
@@ -77,18 +77,18 @@ discard block |
||
77 | 77 | |
78 | 78 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'PDF'); |
79 | 79 | $objWriter->setSheetIndex(0); |
80 | -$objWriter->save(str_replace('.php', '_'.$rendererName.'.pdf', __FILE__)); |
|
80 | +$objWriter->save(str_replace('.php', '_' . $rendererName . '.pdf', __FILE__)); |
|
81 | 81 | $callEndTime = microtime(true); |
82 | 82 | $callTime = $callEndTime - $callStartTime; |
83 | -echo date('H:i:s') , " File written to " , str_replace('.php', '_'.$rendererName.'.pdf', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
84 | -echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL; |
|
83 | +echo date('H:i:s'), " File written to ", str_replace('.php', '_' . $rendererName . '.pdf', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
84 | +echo 'Call time to write Workbook was ', sprintf('%.4f', $callTime), " seconds", EOL; |
|
85 | 85 | // Echo memory usage |
86 | -echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
86 | +echo date('H:i:s'), ' Current memory usage: ', (memory_get_usage(true) / 1024 / 1024), " MB", EOL; |
|
87 | 87 | |
88 | 88 | |
89 | 89 | // Echo memory peak usage |
90 | -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
90 | +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; |
|
91 | 91 | |
92 | 92 | // Echo done |
93 | -echo date('H:i:s') , " Done writing files" , EOL; |
|
94 | -echo 'File has been created in ' , getcwd() , EOL; |
|
93 | +echo date('H:i:s'), " Done writing files", EOL; |
|
94 | +echo 'File has been created in ', getcwd(), EOL; |
@@ -31,18 +31,18 @@ discard block |
||
31 | 31 | ini_set('display_startup_errors', TRUE); |
32 | 32 | date_default_timezone_set('Europe/London'); |
33 | 33 | |
34 | -define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />'); |
|
34 | +define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '<br />'); |
|
35 | 35 | |
36 | 36 | /** Include PHPExcel */ |
37 | 37 | require_once dirname(__FILE__) . '/../src/Bootstrap.php'; |
38 | 38 | |
39 | 39 | |
40 | 40 | // Create new PHPExcel object |
41 | -echo date('H:i:s').' Create new PHPExcel object'.EOL; |
|
41 | +echo date('H:i:s') . ' Create new PHPExcel object' . EOL; |
|
42 | 42 | $objPHPExcel = new \PHPExcel\Spreadsheet(); |
43 | 43 | |
44 | 44 | // Set document properties |
45 | -echo date('H:i:s').' Set document properties'.EOL; |
|
45 | +echo date('H:i:s') . ' Set document properties' . EOL; |
|
46 | 46 | $objPHPExcel->getProperties()->setCreator('Maarten Balliauw') |
47 | 47 | ->setLastModifiedBy('Maarten Balliauw') |
48 | 48 | ->setTitle('PHPExcel Test Document') |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | ->setCategory('Test result file'); |
53 | 53 | |
54 | 54 | // Create the worksheet |
55 | -echo date('H:i:s').' Add data'.EOL; |
|
55 | +echo date('H:i:s') . ' Add data' . EOL; |
|
56 | 56 | $objPHPExcel->setActiveSheetIndex(0); |
57 | 57 | $objPHPExcel->getActiveSheet()->setCellValue('A1', 'Financial Year') |
58 | 58 | ->setCellValue('B1', 'Financial Period') |
@@ -65,44 +65,44 @@ discard block |
||
65 | 65 | $startYear--; |
66 | 66 | $endYear++; |
67 | 67 | |
68 | -$years = range($startYear,$endYear); |
|
69 | -$periods = range(1,12); |
|
70 | -$countries = array( 'United States', 'UK', 'France', 'Germany', |
|
71 | - 'Italy', 'Spain', 'Portugal', 'Japan' |
|
68 | +$years = range($startYear, $endYear); |
|
69 | +$periods = range(1, 12); |
|
70 | +$countries = array('United States', 'UK', 'France', 'Germany', |
|
71 | + 'Italy', 'Spain', 'Portugal', 'Japan' |
|
72 | 72 | ); |
73 | 73 | |
74 | 74 | $row = 2; |
75 | -foreach($years as $year) { |
|
76 | - foreach($periods as $period) { |
|
77 | - foreach($countries as $country) { |
|
78 | - $endDays = date('t',mktime(0,0,0,$period,1,$year)); |
|
79 | - for($i = 1; $i <= $endDays; ++$i) { |
|
75 | +foreach ($years as $year) { |
|
76 | + foreach ($periods as $period) { |
|
77 | + foreach ($countries as $country) { |
|
78 | + $endDays = date('t', mktime(0, 0, 0, $period, 1, $year)); |
|
79 | + for ($i = 1; $i <= $endDays; ++$i) { |
|
80 | 80 | $eDate = \PHPExcel\Shared\Date::formattedPHPToExcel( |
81 | 81 | $year, |
82 | 82 | $period, |
83 | 83 | $i |
84 | 84 | ); |
85 | - $value = rand(500,1000) * (1 + rand(-0.25,+0.25)); |
|
85 | + $value = rand(500, 1000) * (1 + rand(-0.25, +0.25)); |
|
86 | 86 | $salesValue = $invoiceValue = NULL; |
87 | - $incomeOrExpenditure = rand(-1,1); |
|
87 | + $incomeOrExpenditure = rand(-1, 1); |
|
88 | 88 | if ($incomeOrExpenditure == -1) { |
89 | - $expenditure = rand(-500,-1000) * (1 + rand(-0.25,+0.25)); |
|
89 | + $expenditure = rand(-500, -1000) * (1 + rand(-0.25, +0.25)); |
|
90 | 90 | $income = NULL; |
91 | 91 | } elseif ($incomeOrExpenditure == 1) { |
92 | - $expenditure = rand(-500,-1000) * (1 + rand(-0.25,+0.25)); |
|
93 | - $income = rand(500,1000) * (1 + rand(-0.25,+0.25));; |
|
92 | + $expenditure = rand(-500, -1000) * (1 + rand(-0.25, +0.25)); |
|
93 | + $income = rand(500, 1000) * (1 + rand(-0.25, +0.25)); ; |
|
94 | 94 | } else { |
95 | 95 | $expenditure = NULL; |
96 | - $income = rand(500,1000) * (1 + rand(-0.25,+0.25));; |
|
96 | + $income = rand(500, 1000) * (1 + rand(-0.25, +0.25)); ; |
|
97 | 97 | } |
98 | - $dataArray = array( $year, |
|
98 | + $dataArray = array($year, |
|
99 | 99 | $period, |
100 | 100 | $country, |
101 | 101 | $eDate, |
102 | 102 | $income, |
103 | 103 | $expenditure, |
104 | 104 | ); |
105 | - $objPHPExcel->getActiveSheet()->fromArray($dataArray, NULL, 'A'.$row++); |
|
105 | + $objPHPExcel->getActiveSheet()->fromArray($dataArray, NULL, 'A' . $row++); |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 | } |
@@ -111,20 +111,20 @@ discard block |
||
111 | 111 | |
112 | 112 | |
113 | 113 | // Set styling |
114 | -echo date('H:i:s').' Set styling'.EOL; |
|
114 | +echo date('H:i:s') . ' Set styling' . EOL; |
|
115 | 115 | $objPHPExcel->getActiveSheet()->getStyle('A1:F1')->getFont()->setBold(true); |
116 | 116 | $objPHPExcel->getActiveSheet()->getStyle('A1:F1')->getAlignment()->setWrapText(TRUE); |
117 | 117 | $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(12.5); |
118 | 118 | $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(10.5); |
119 | -$objPHPExcel->getActiveSheet()->getStyle('D2:D'.$row)->getNumberFormat()->setFormatCode(\PHPExcel\Style\NumberFormat::FORMAT_DATE_YYYYMMDD2); |
|
120 | -$objPHPExcel->getActiveSheet()->getStyle('E2:F'.$row)->getNumberFormat()->setFormatCode(\PHPExcel\Style\NumberFormat::FORMAT_CURRENCY_USD_SIMPLE); |
|
119 | +$objPHPExcel->getActiveSheet()->getStyle('D2:D' . $row)->getNumberFormat()->setFormatCode(\PHPExcel\Style\NumberFormat::FORMAT_DATE_YYYYMMDD2); |
|
120 | +$objPHPExcel->getActiveSheet()->getStyle('E2:F' . $row)->getNumberFormat()->setFormatCode(\PHPExcel\Style\NumberFormat::FORMAT_CURRENCY_USD_SIMPLE); |
|
121 | 121 | $objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(14); |
122 | 122 | $objPHPExcel->getActiveSheet()->freezePane('A2'); |
123 | 123 | |
124 | 124 | |
125 | 125 | |
126 | 126 | // Set autofilter range |
127 | -echo date('H:i:s').' Set autofilter range'.EOL; |
|
127 | +echo date('H:i:s') . ' Set autofilter range' . EOL; |
|
128 | 128 | // Always include the complete filter range! |
129 | 129 | // Excel does support setting only the caption |
130 | 130 | // row, but that's not a best practise... |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | |
133 | 133 | // Set active filters |
134 | 134 | $autoFilter = $objPHPExcel->getActiveSheet()->getAutoFilter(); |
135 | -echo date('H:i:s').' Set active filters'.EOL; |
|
135 | +echo date('H:i:s') . ' Set active filters' . EOL; |
|
136 | 136 | // Filter the Country column on a filter value of countries beginning with the letter U (or Japan) |
137 | 137 | // We use * as a wildcard, so specify as U* and using a wildcard requires customFilter |
138 | 138 | $autoFilter->getColumn('C') |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | ->setRuleType(\PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER); |
153 | 153 | // Filter the Date column on a filter value of the first day of every period of the current year |
154 | 154 | // We us a dateGroup ruletype for this, although it is still a standard filter |
155 | -foreach($periods as $period) { |
|
156 | - $endDate = date('t',mktime(0,0,0,$period,1,$currentYear)); |
|
155 | +foreach ($periods as $period) { |
|
156 | + $endDate = date('t', mktime(0, 0, 0, $period, 1, $currentYear)); |
|
157 | 157 | |
158 | 158 | $autoFilter->getColumn('D') |
159 | 159 | ->setFilterType(\PHPExcel\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_FILTER) |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | |
185 | 185 | |
186 | 186 | // Save Excel 2007 file |
187 | -echo date('H:i:s') , " Write to Excel2007 format" , EOL; |
|
187 | +echo date('H:i:s'), " Write to Excel2007 format", EOL; |
|
188 | 188 | $callStartTime = microtime(true); |
189 | 189 | |
190 | 190 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007'); |
@@ -192,14 +192,14 @@ discard block |
||
192 | 192 | $callEndTime = microtime(true); |
193 | 193 | $callTime = $callEndTime - $callStartTime; |
194 | 194 | |
195 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
196 | -echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL; |
|
195 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
196 | +echo 'Call time to write Workbook was ', sprintf('%.4f', $callTime), " seconds", EOL; |
|
197 | 197 | // Echo memory usage |
198 | -echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
198 | +echo date('H:i:s'), ' Current memory usage: ', (memory_get_usage(true) / 1024 / 1024), " MB", EOL; |
|
199 | 199 | |
200 | 200 | |
201 | 201 | // Save Excel 95 file |
202 | -echo date('H:i:s') , " Write to Excel5 format" , EOL; |
|
202 | +echo date('H:i:s'), " Write to Excel5 format", EOL; |
|
203 | 203 | $callStartTime = microtime(true); |
204 | 204 | |
205 | 205 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5'); |
@@ -207,15 +207,15 @@ discard block |
||
207 | 207 | $callEndTime = microtime(true); |
208 | 208 | $callTime = $callEndTime - $callStartTime; |
209 | 209 | |
210 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
211 | -echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL; |
|
210 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
211 | +echo 'Call time to write Workbook was ', sprintf('%.4f', $callTime), " seconds", EOL; |
|
212 | 212 | // Echo memory usage |
213 | -echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
213 | +echo date('H:i:s'), ' Current memory usage: ', (memory_get_usage(true) / 1024 / 1024), " MB", EOL; |
|
214 | 214 | |
215 | 215 | |
216 | 216 | // Echo memory peak usage |
217 | -echo date('H:i:s').' Peak memory usage: '.(memory_get_peak_usage(true) / 1024 / 1024).' MB'.EOL; |
|
217 | +echo date('H:i:s') . ' Peak memory usage: ' . (memory_get_peak_usage(true) / 1024 / 1024) . ' MB' . EOL; |
|
218 | 218 | |
219 | 219 | // Echo done |
220 | -echo date('H:i:s').' Done writing files'.EOL; |
|
221 | -echo 'Files have been created in ' , getcwd() , EOL; |
|
220 | +echo date('H:i:s') . ' Done writing files' . EOL; |
|
221 | +echo 'Files have been created in ', getcwd(), EOL; |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | ini_set('display_errors', TRUE); |
31 | 31 | ini_set('display_startup_errors', TRUE); |
32 | 32 | |
33 | -define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />'); |
|
33 | +define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '<br />'); |
|
34 | 34 | |
35 | 35 | date_default_timezone_set('Europe/London'); |
36 | 36 | |
@@ -39,26 +39,26 @@ discard block |
||
39 | 39 | |
40 | 40 | |
41 | 41 | // Read from Excel5 (.xls) template |
42 | -echo date('H:i:s') , " Load Excel2007 template file" , EOL; |
|
42 | +echo date('H:i:s'), " Load Excel2007 template file", EOL; |
|
43 | 43 | $objReader = \PHPExcel\IOFactory::createReader('Excel5'); |
44 | 44 | $objPHPExcel = $objReader->load("templates/27template.xls"); |
45 | 45 | |
46 | 46 | // Export to Excel2007 (.xlsx) |
47 | -echo date('H:i:s') , " Write to Excel5 format" , EOL; |
|
47 | +echo date('H:i:s'), " Write to Excel5 format", EOL; |
|
48 | 48 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007'); |
49 | 49 | $objWriter->save(str_replace('.php', '.xlsx', __FILE__)); |
50 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
50 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
51 | 51 | |
52 | 52 | // Export to Excel5 (.xls) |
53 | -echo date('H:i:s') , " Write to Excel5 format" , EOL; |
|
53 | +echo date('H:i:s'), " Write to Excel5 format", EOL; |
|
54 | 54 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5'); |
55 | 55 | $objWriter->save(str_replace('.php', '.xls', __FILE__)); |
56 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
56 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
57 | 57 | |
58 | 58 | |
59 | 59 | // Echo memory peak usage |
60 | -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
60 | +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; |
|
61 | 61 | |
62 | 62 | // Echo done |
63 | -echo date('H:i:s') , " Done writing files" , EOL; |
|
64 | -echo 'Files have been created in ' , getcwd() , EOL; |
|
63 | +echo date('H:i:s'), " Done writing files", EOL; |
|
64 | +echo 'Files have been created in ', getcwd(), EOL; |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | ini_set('display_errors', TRUE); |
31 | 31 | ini_set('display_startup_errors', TRUE); |
32 | 32 | |
33 | -define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />'); |
|
33 | +define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '<br />'); |
|
34 | 34 | |
35 | 35 | date_default_timezone_set('Europe/London'); |
36 | 36 | |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | |
40 | 40 | |
41 | 41 | // Create new PHPExcel object |
42 | -echo date('H:i:s') , " Create new PHPExcel object" , EOL; |
|
42 | +echo date('H:i:s'), " Create new PHPExcel object", EOL; |
|
43 | 43 | $objPHPExcel = new \PHPExcel\Spreadsheet(); |
44 | 44 | |
45 | 45 | // Set document properties |
46 | -echo date('H:i:s') , " Set document properties" , EOL; |
|
46 | +echo date('H:i:s'), " Set document properties", EOL; |
|
47 | 47 | $objPHPExcel->getProperties()->setCreator("Mark Baker") |
48 | 48 | ->setLastModifiedBy("Mark Baker") |
49 | 49 | ->setTitle("Office 2007 XLSX Test Document") |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | |
56 | 56 | // Add some data |
57 | -echo date('H:i:s') , " Add some data" , EOL; |
|
57 | +echo date('H:i:s'), " Add some data", EOL; |
|
58 | 58 | $objPHPExcel->setActiveSheetIndex(0); |
59 | 59 | $objPHPExcel->getActiveSheet()->setCellValue('A1', 'Crouching'); |
60 | 60 | $objPHPExcel->getActiveSheet()->setCellValue('B1', 'Tiger'); |
@@ -62,16 +62,16 @@ discard block |
||
62 | 62 | $objPHPExcel->getActiveSheet()->setCellValue('B2', 'Dragon'); |
63 | 63 | |
64 | 64 | // Rename worksheet |
65 | -echo date('H:i:s') , " Rename worksheet" , EOL; |
|
65 | +echo date('H:i:s'), " Rename worksheet", EOL; |
|
66 | 66 | $objPHPExcel->getActiveSheet()->setTitle('Simple'); |
67 | 67 | |
68 | 68 | |
69 | 69 | // Set document security |
70 | -echo date('H:i:s') , " Set cell protection" , EOL; |
|
70 | +echo date('H:i:s'), " Set cell protection", EOL; |
|
71 | 71 | |
72 | 72 | |
73 | 73 | // Set sheet security |
74 | -echo date('H:i:s') , " Set sheet security" , EOL; |
|
74 | +echo date('H:i:s'), " Set sheet security", EOL; |
|
75 | 75 | $objPHPExcel->getActiveSheet()->getProtection()->setSheet(true); |
76 | 76 | $objPHPExcel->getActiveSheet() |
77 | 77 | ->getStyle('A2:B2') |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | |
86 | 86 | |
87 | 87 | // Save Excel 2007 file |
88 | -echo date('H:i:s') , " Write to Excel2007 format" , EOL; |
|
88 | +echo date('H:i:s'), " Write to Excel2007 format", EOL; |
|
89 | 89 | $callStartTime = microtime(true); |
90 | 90 | |
91 | 91 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007'); |
@@ -93,15 +93,15 @@ discard block |
||
93 | 93 | $callEndTime = microtime(true); |
94 | 94 | $callTime = $callEndTime - $callStartTime; |
95 | 95 | |
96 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
97 | -echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL; |
|
96 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
97 | +echo 'Call time to write Workbook was ', sprintf('%.4f', $callTime), " seconds", EOL; |
|
98 | 98 | // Echo memory usage |
99 | -echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
99 | +echo date('H:i:s'), ' Current memory usage: ', (memory_get_usage(true) / 1024 / 1024), " MB", EOL; |
|
100 | 100 | |
101 | 101 | |
102 | 102 | // Echo memory peak usage |
103 | -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
103 | +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; |
|
104 | 104 | |
105 | 105 | // Echo done |
106 | -echo date('H:i:s') , " Done writing file" , EOL; |
|
107 | -echo 'File has been created in ' , getcwd() , EOL; |
|
106 | +echo date('H:i:s'), " Done writing file", EOL; |
|
107 | +echo 'File has been created in ', getcwd(), EOL; |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | ini_set('display_errors', TRUE); |
31 | 31 | ini_set('display_startup_errors', TRUE); |
32 | 32 | |
33 | -define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />'); |
|
33 | +define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '<br />'); |
|
34 | 34 | |
35 | 35 | date_default_timezone_set('Europe/London'); |
36 | 36 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | |
43 | 43 | // Save Excel 95 file |
44 | -echo date('H:i:s') , " Write to Excel5 format" , EOL; |
|
44 | +echo date('H:i:s'), " Write to Excel5 format", EOL; |
|
45 | 45 | $callStartTime = microtime(true); |
46 | 46 | |
47 | 47 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5'); |
@@ -49,15 +49,15 @@ discard block |
||
49 | 49 | $callEndTime = microtime(true); |
50 | 50 | $callTime = $callEndTime - $callStartTime; |
51 | 51 | |
52 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
53 | -echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL; |
|
52 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
53 | +echo 'Call time to write Workbook was ', sprintf('%.4f', $callTime), " seconds", EOL; |
|
54 | 54 | // Echo memory usage |
55 | -echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
55 | +echo date('H:i:s'), ' Current memory usage: ', (memory_get_usage(true) / 1024 / 1024), " MB", EOL; |
|
56 | 56 | |
57 | 57 | |
58 | 58 | // Echo memory peak usage |
59 | -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
59 | +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; |
|
60 | 60 | |
61 | 61 | // Echo done |
62 | -echo date('H:i:s') , " Done writing file" , EOL; |
|
63 | -echo 'File has been created in ' , getcwd() , EOL; |
|
62 | +echo date('H:i:s'), " Done writing file", EOL; |
|
63 | +echo 'File has been created in ', getcwd(), EOL; |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | |
34 | 34 | |
35 | 35 | // Create new PHPExcel object |
36 | -echo date('H:i:s') , " Create new PHPExcel object" , EOL; |
|
36 | +echo date('H:i:s'), " Create new PHPExcel object", EOL; |
|
37 | 37 | $objPHPExcel = new \PHPExcel\Spreadsheet(); |
38 | 38 | |
39 | 39 | // Set document properties |
40 | -echo date('H:i:s') , " Set document properties" , EOL; |
|
40 | +echo date('H:i:s'), " Set document properties", EOL; |
|
41 | 41 | $objPHPExcel->getProperties()->setCreator("Maarten Balliauw") |
42 | 42 | ->setLastModifiedBy("Maarten Balliauw") |
43 | 43 | ->setTitle("Office 2007 XLSX Test Document") |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | |
49 | 49 | |
50 | 50 | // Create a first sheet, representing sales data |
51 | -echo date('H:i:s') , " Add some data" , EOL; |
|
51 | +echo date('H:i:s'), " Add some data", EOL; |
|
52 | 52 | $objPHPExcel->setActiveSheetIndex(0); |
53 | 53 | $objPHPExcel->getActiveSheet()->setCellValue('B1', 'Invoice'); |
54 | -$objPHPExcel->getActiveSheet()->setCellValue('D1', \PHPExcel\Shared\Date::PHPToExcel( gmmktime(0,0,0,date('m'),date('d'),date('Y')) )); |
|
54 | +$objPHPExcel->getActiveSheet()->setCellValue('D1', \PHPExcel\Shared\Date::PHPToExcel(gmmktime(0, 0, 0, date('m'), date('d'), date('Y')))); |
|
55 | 55 | $objPHPExcel->getActiveSheet()->getStyle('D1')->getNumberFormat()->setFormatCode(\PHPExcel\Style\NumberFormat::FORMAT_DATE_XLSX15); |
56 | 56 | $objPHPExcel->getActiveSheet()->setCellValue('E1', '#12566'); |
57 | 57 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | $objPHPExcel->getActiveSheet()->setCellValue('E13', '=E11+E12'); |
89 | 89 | |
90 | 90 | // Add comment |
91 | -echo date('H:i:s') , " Add comments" , EOL; |
|
91 | +echo date('H:i:s'), " Add comments", EOL; |
|
92 | 92 | |
93 | 93 | $objPHPExcel->getActiveSheet()->getComment('E11')->setAuthor('PHPExcel'); |
94 | 94 | $objCommentRichText = $objPHPExcel->getActiveSheet()->getComment('E11')->getText()->createTextRun('PHPExcel:'); |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | |
115 | 115 | |
116 | 116 | // Add rich-text string |
117 | -echo date('H:i:s') , " Add rich-text string" , EOL; |
|
117 | +echo date('H:i:s'), " Add rich-text string", EOL; |
|
118 | 118 | $objRichText = new \PHPExcel\RichText(); |
119 | 119 | $objRichText->createText('This invoice is '); |
120 | 120 | |
@@ -128,28 +128,28 @@ discard block |
||
128 | 128 | $objPHPExcel->getActiveSheet()->getCell('A18')->setValue($objRichText); |
129 | 129 | |
130 | 130 | // Merge cells |
131 | -echo date('H:i:s') , " Merge cells" , EOL; |
|
131 | +echo date('H:i:s'), " Merge cells", EOL; |
|
132 | 132 | $objPHPExcel->getActiveSheet()->mergeCells('A18:E22'); |
133 | -$objPHPExcel->getActiveSheet()->mergeCells('A28:B28'); // Just to test... |
|
134 | -$objPHPExcel->getActiveSheet()->unmergeCells('A28:B28'); // Just to test... |
|
133 | +$objPHPExcel->getActiveSheet()->mergeCells('A28:B28'); // Just to test... |
|
134 | +$objPHPExcel->getActiveSheet()->unmergeCells('A28:B28'); // Just to test... |
|
135 | 135 | |
136 | 136 | // Protect cells |
137 | -echo date('H:i:s') , " Protect cells" , EOL; |
|
138 | -$objPHPExcel->getActiveSheet()->getProtection()->setSheet(true); // Needs to be set to true in order to enable any worksheet protection! |
|
137 | +echo date('H:i:s'), " Protect cells", EOL; |
|
138 | +$objPHPExcel->getActiveSheet()->getProtection()->setSheet(true); // Needs to be set to true in order to enable any worksheet protection! |
|
139 | 139 | $objPHPExcel->getActiveSheet()->protectCells('A3:E13', 'PHPExcel'); |
140 | 140 | |
141 | 141 | // Set cell number formats |
142 | -echo date('H:i:s') , " Set cell number formats" , EOL; |
|
142 | +echo date('H:i:s'), " Set cell number formats", EOL; |
|
143 | 143 | $objPHPExcel->getActiveSheet()->getStyle('E4:E13')->getNumberFormat()->setFormatCode(\PHPExcel\Style\NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE); |
144 | 144 | |
145 | 145 | // Set column widths |
146 | -echo date('H:i:s') , " Set column widths" , EOL; |
|
146 | +echo date('H:i:s'), " Set column widths", EOL; |
|
147 | 147 | $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true); |
148 | 148 | $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(12); |
149 | 149 | $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(12); |
150 | 150 | |
151 | 151 | // Set fonts |
152 | -echo date('H:i:s') , " Set fonts" , EOL; |
|
152 | +echo date('H:i:s'), " Set fonts", EOL; |
|
153 | 153 | $objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setName('Candara'); |
154 | 154 | $objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setSize(20); |
155 | 155 | $objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setBold(true); |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | $objPHPExcel->getActiveSheet()->getStyle('E13')->getFont()->setBold(true); |
164 | 164 | |
165 | 165 | // Set alignments |
166 | -echo date('H:i:s') , " Set alignments" , EOL; |
|
166 | +echo date('H:i:s'), " Set alignments", EOL; |
|
167 | 167 | $objPHPExcel->getActiveSheet()->getStyle('D11')->getAlignment()->setHorizontal(\PHPExcel\Style\Alignment::HORIZONTAL_RIGHT); |
168 | 168 | $objPHPExcel->getActiveSheet()->getStyle('D12')->getAlignment()->setHorizontal(\PHPExcel\Style\Alignment::HORIZONTAL_RIGHT); |
169 | 169 | $objPHPExcel->getActiveSheet()->getStyle('D13')->getAlignment()->setHorizontal(\PHPExcel\Style\Alignment::HORIZONTAL_RIGHT); |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | $objPHPExcel->getActiveSheet()->getStyle('B5')->getAlignment()->setShrinkToFit(true); |
175 | 175 | |
176 | 176 | // Set thin black border outline around column |
177 | -echo date('H:i:s') , " Set thin black border outline around column" , EOL; |
|
177 | +echo date('H:i:s'), " Set thin black border outline around column", EOL; |
|
178 | 178 | $styleThinBlackBorderOutline = array( |
179 | 179 | 'borders' => array( |
180 | 180 | 'outline' => array( |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | |
188 | 188 | |
189 | 189 | // Set thick brown border outline around "Total" |
190 | -echo date('H:i:s') , " Set thick brown border outline around Total" , EOL; |
|
190 | +echo date('H:i:s'), " Set thick brown border outline around Total", EOL; |
|
191 | 191 | $styleThickBrownBorderOutline = array( |
192 | 192 | 'borders' => array( |
193 | 193 | 'outline' => array( |
@@ -199,12 +199,12 @@ discard block |
||
199 | 199 | $objPHPExcel->getActiveSheet()->getStyle('D13:E13')->applyFromArray($styleThickBrownBorderOutline); |
200 | 200 | |
201 | 201 | // Set fills |
202 | -echo date('H:i:s') , " Set fills" , EOL; |
|
202 | +echo date('H:i:s'), " Set fills", EOL; |
|
203 | 203 | $objPHPExcel->getActiveSheet()->getStyle('A1:E1')->getFill()->setFillType(\PHPExcel\Style\Fill::FILL_SOLID); |
204 | 204 | $objPHPExcel->getActiveSheet()->getStyle('A1:E1')->getFill()->getStartColor()->setARGB('FF808080'); |
205 | 205 | |
206 | 206 | // Set style for header row using alternative method |
207 | -echo date('H:i:s') , " Set style for header row using alternative method" , EOL; |
|
207 | +echo date('H:i:s'), " Set style for header row using alternative method", EOL; |
|
208 | 208 | $objPHPExcel->getActiveSheet()->getStyle('A3:E3')->applyFromArray( |
209 | 209 | array( |
210 | 210 | 'font' => array( |
@@ -263,24 +263,24 @@ discard block |
||
263 | 263 | ); |
264 | 264 | |
265 | 265 | // Unprotect a cell |
266 | -echo date('H:i:s') , " Unprotect a cell" , EOL; |
|
266 | +echo date('H:i:s'), " Unprotect a cell", EOL; |
|
267 | 267 | $objPHPExcel->getActiveSheet()->getStyle('B1')->getProtection()->setLocked(\PHPExcel\Style\Protection::PROTECTION_UNPROTECTED); |
268 | 268 | |
269 | 269 | // Add a hyperlink to the sheet |
270 | -echo date('H:i:s') , " Add a hyperlink to an external website" , EOL; |
|
270 | +echo date('H:i:s'), " Add a hyperlink to an external website", EOL; |
|
271 | 271 | $objPHPExcel->getActiveSheet()->setCellValue('E26', 'www.phpexcel.net'); |
272 | 272 | $objPHPExcel->getActiveSheet()->getCell('E26')->getHyperlink()->setUrl('http://www.phpexcel.net'); |
273 | 273 | $objPHPExcel->getActiveSheet()->getCell('E26')->getHyperlink()->setTooltip('Navigate to website'); |
274 | 274 | $objPHPExcel->getActiveSheet()->getStyle('E26')->getAlignment()->setHorizontal(\PHPExcel\Style\Alignment::HORIZONTAL_RIGHT); |
275 | 275 | |
276 | -echo date('H:i:s') , " Add a hyperlink to another cell on a different worksheet within the workbook" , EOL; |
|
276 | +echo date('H:i:s'), " Add a hyperlink to another cell on a different worksheet within the workbook", EOL; |
|
277 | 277 | $objPHPExcel->getActiveSheet()->setCellValue('E27', 'Terms and conditions'); |
278 | 278 | $objPHPExcel->getActiveSheet()->getCell('E27')->getHyperlink()->setUrl("sheet://'Terms and conditions'!A1"); |
279 | 279 | $objPHPExcel->getActiveSheet()->getCell('E27')->getHyperlink()->setTooltip('Review terms and conditions'); |
280 | 280 | $objPHPExcel->getActiveSheet()->getStyle('E27')->getAlignment()->setHorizontal(\PHPExcel\Style\Alignment::HORIZONTAL_RIGHT); |
281 | 281 | |
282 | 282 | // Add a drawing to the worksheet |
283 | -echo date('H:i:s') , " Add a drawing to the worksheet" , EOL; |
|
283 | +echo date('H:i:s'), " Add a drawing to the worksheet", EOL; |
|
284 | 284 | $objDrawing = new \PHPExcel\Worksheet\Drawing(); |
285 | 285 | $objDrawing->setName('Logo'); |
286 | 286 | $objDrawing->setDescription('Logo'); |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | $objDrawing->setWorksheet($objPHPExcel->getActiveSheet()); |
290 | 290 | |
291 | 291 | // Add a drawing to the worksheet |
292 | -echo date('H:i:s') , " Add a drawing to the worksheet" , EOL; |
|
292 | +echo date('H:i:s'), " Add a drawing to the worksheet", EOL; |
|
293 | 293 | $objDrawing = new \PHPExcel\Worksheet\Drawing(); |
294 | 294 | $objDrawing->setName('Paid'); |
295 | 295 | $objDrawing->setDescription('Paid'); |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | $objDrawing->setWorksheet($objPHPExcel->getActiveSheet()); |
303 | 303 | |
304 | 304 | // Add a drawing to the worksheet |
305 | -echo date('H:i:s') , " Add a drawing to the worksheet" , EOL; |
|
305 | +echo date('H:i:s'), " Add a drawing to the worksheet", EOL; |
|
306 | 306 | $objDrawing = new \PHPExcel\Worksheet\Drawing(); |
307 | 307 | $objDrawing->setName('PHPExcel logo'); |
308 | 308 | $objDrawing->setDescription('PHPExcel logo'); |
@@ -313,36 +313,36 @@ discard block |
||
313 | 313 | $objDrawing->setWorksheet($objPHPExcel->getActiveSheet()); |
314 | 314 | |
315 | 315 | // Play around with inserting and removing rows and columns |
316 | -echo date('H:i:s') , " Play around with inserting and removing rows and columns" , EOL; |
|
316 | +echo date('H:i:s'), " Play around with inserting and removing rows and columns", EOL; |
|
317 | 317 | $objPHPExcel->getActiveSheet()->insertNewRowBefore(6, 10); |
318 | 318 | $objPHPExcel->getActiveSheet()->removeRow(6, 10); |
319 | 319 | $objPHPExcel->getActiveSheet()->insertNewColumnBefore('E', 5); |
320 | 320 | $objPHPExcel->getActiveSheet()->removeColumn('E', 5); |
321 | 321 | |
322 | 322 | // Set header and footer. When no different headers for odd/even are used, odd header is assumed. |
323 | -echo date('H:i:s') , " Set header/footer" , EOL; |
|
323 | +echo date('H:i:s'), " Set header/footer", EOL; |
|
324 | 324 | $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&L&BInvoice&RPrinted on &D'); |
325 | 325 | $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&L&B' . $objPHPExcel->getProperties()->getTitle() . '&RPage &P of &N'); |
326 | 326 | |
327 | 327 | // Set page orientation and size |
328 | -echo date('H:i:s') , " Set page orientation and size" , EOL; |
|
328 | +echo date('H:i:s'), " Set page orientation and size", EOL; |
|
329 | 329 | $objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(\PHPExcel\Worksheet\PageSetup::ORIENTATION_PORTRAIT); |
330 | 330 | $objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(\PHPExcel\Worksheet\PageSetup::PAPERSIZE_A4); |
331 | 331 | |
332 | 332 | // Rename first worksheet |
333 | -echo date('H:i:s') , " Rename first worksheet" , EOL; |
|
333 | +echo date('H:i:s'), " Rename first worksheet", EOL; |
|
334 | 334 | $objPHPExcel->getActiveSheet()->setTitle('Invoice'); |
335 | 335 | |
336 | 336 | |
337 | 337 | // Create a new worksheet, after the default sheet |
338 | -echo date('H:i:s') , " Create a second Worksheet object" , EOL; |
|
338 | +echo date('H:i:s'), " Create a second Worksheet object", EOL; |
|
339 | 339 | $objPHPExcel->createSheet(); |
340 | 340 | |
341 | 341 | // Llorem ipsum... |
342 | 342 | $sLloremIpsum = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vivamus eget ante. Sed cursus nunc semper tortor. Aliquam luctus purus non elit. Fusce vel elit commodo sapien dignissim dignissim. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Curabitur accumsan magna sed massa. Nullam bibendum quam ac ipsum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Proin augue. Praesent malesuada justo sed orci. Pellentesque lacus ligula, sodales quis, ultricies a, ultricies vitae, elit. Sed luctus consectetuer dolor. Vivamus vel sem ut nisi sodales accumsan. Nunc et felis. Suspendisse semper viverra odio. Morbi at odio. Integer a orci a purus venenatis molestie. Nam mattis. Praesent rhoncus, nisi vel mattis auctor, neque nisi faucibus sem, non dapibus elit pede ac nisl. Cras turpis.'; |
343 | 343 | |
344 | 344 | // Add some data to the second sheet, resembling some different data types |
345 | -echo date('H:i:s') , " Add some data" , EOL; |
|
345 | +echo date('H:i:s'), " Add some data", EOL; |
|
346 | 346 | $objPHPExcel->setActiveSheetIndex(1); |
347 | 347 | $objPHPExcel->getActiveSheet()->setCellValue('A1', 'Terms and conditions'); |
348 | 348 | $objPHPExcel->getActiveSheet()->setCellValue('A3', $sLloremIpsum); |
@@ -351,19 +351,19 @@ discard block |
||
351 | 351 | $objPHPExcel->getActiveSheet()->setCellValue('A6', $sLloremIpsum); |
352 | 352 | |
353 | 353 | // Set the worksheet tab color |
354 | -echo date('H:i:s') , " Set the worksheet tab color" , EOL; |
|
355 | -$objPHPExcel->getActiveSheet()->getTabColor()->setARGB('FF0094FF');; |
|
354 | +echo date('H:i:s'), " Set the worksheet tab color", EOL; |
|
355 | +$objPHPExcel->getActiveSheet()->getTabColor()->setARGB('FF0094FF'); ; |
|
356 | 356 | |
357 | 357 | // Set alignments |
358 | -echo date('H:i:s') , " Set alignments" , EOL; |
|
358 | +echo date('H:i:s'), " Set alignments", EOL; |
|
359 | 359 | $objPHPExcel->getActiveSheet()->getStyle('A3:A6')->getAlignment()->setWrapText(true); |
360 | 360 | |
361 | 361 | // Set column widths |
362 | -echo date('H:i:s') , " Set column widths" , EOL; |
|
362 | +echo date('H:i:s'), " Set column widths", EOL; |
|
363 | 363 | $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(80); |
364 | 364 | |
365 | 365 | // Set fonts |
366 | -echo date('H:i:s') , " Set fonts" , EOL; |
|
366 | +echo date('H:i:s'), " Set fonts", EOL; |
|
367 | 367 | $objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setName('Candara'); |
368 | 368 | $objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setSize(20); |
369 | 369 | $objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true); |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | $objPHPExcel->getActiveSheet()->getStyle('A3:A6')->getFont()->setSize(8); |
373 | 373 | |
374 | 374 | // Add a drawing to the worksheet |
375 | -echo date('H:i:s') , " Add a drawing to the worksheet" , EOL; |
|
375 | +echo date('H:i:s'), " Add a drawing to the worksheet", EOL; |
|
376 | 376 | $objDrawing = new \PHPExcel\Worksheet\Drawing(); |
377 | 377 | $objDrawing->setName('Terms and conditions'); |
378 | 378 | $objDrawing->setDescription('Terms and conditions'); |
@@ -381,12 +381,12 @@ discard block |
||
381 | 381 | $objDrawing->setWorksheet($objPHPExcel->getActiveSheet()); |
382 | 382 | |
383 | 383 | // Set page orientation and size |
384 | -echo date('H:i:s') , " Set page orientation and size" , EOL; |
|
384 | +echo date('H:i:s'), " Set page orientation and size", EOL; |
|
385 | 385 | $objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(\PHPExcel\Worksheet\PageSetup::ORIENTATION_LANDSCAPE); |
386 | 386 | $objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(\PHPExcel\Worksheet\PageSetup::PAPERSIZE_A4); |
387 | 387 | |
388 | 388 | // Rename second worksheet |
389 | -echo date('H:i:s') , " Rename second worksheet" , EOL; |
|
389 | +echo date('H:i:s'), " Rename second worksheet", EOL; |
|
390 | 390 | $objPHPExcel->getActiveSheet()->setTitle('Terms and conditions'); |
391 | 391 | |
392 | 392 |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | ini_set('display_startup_errors', TRUE); |
7 | 7 | date_default_timezone_set('Europe/London'); |
8 | 8 | |
9 | -define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />'); |
|
9 | +define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '<br />'); |
|
10 | 10 | |
11 | 11 | date_default_timezone_set('Europe/London'); |
12 | 12 | |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | $objWorksheet = $objPHPExcel->getActiveSheet(); |
45 | 45 | $objWorksheet->fromArray( |
46 | 46 | array( |
47 | - array('', 2010, 2011, 2012), |
|
48 | - array('Q1', 12, 15, 21), |
|
49 | - array('Q2', 56, 73, 86), |
|
50 | - array('Q3', 52, 61, 69), |
|
51 | - array('Q4', 30, 32, 0), |
|
47 | + array('', 2010, 2011, 2012), |
|
48 | + array('Q1', 12, 15, 21), |
|
49 | + array('Q2', 56, 73, 86), |
|
50 | + array('Q3', 52, 61, 69), |
|
51 | + array('Q4', 30, 32, 0), |
|
52 | 52 | ) |
53 | 53 | ); |
54 | 54 | |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | // Data values |
61 | 61 | // Data Marker |
62 | 62 | $dataSeriesLabels = array( |
63 | - new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // 2010 |
|
64 | - new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011 |
|
65 | - new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 2012 |
|
63 | + new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // 2010 |
|
64 | + new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011 |
|
65 | + new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 2012 |
|
66 | 66 | ); |
67 | 67 | // Set the X-Axis Labels |
68 | 68 | // Datatype |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | // Data values |
73 | 73 | // Data Marker |
74 | 74 | $xAxisTickValues = array( |
75 | - new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', NULL, 4), // Q1 to Q4 |
|
75 | + new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', NULL, 4), // Q1 to Q4 |
|
76 | 76 | ); |
77 | 77 | // Set the Data values for each data series we want to plot |
78 | 78 | // Datatype |
@@ -89,11 +89,11 @@ discard block |
||
89 | 89 | |
90 | 90 | // Build the dataseries |
91 | 91 | $series = new \PHPExcel\Chart\DataSeries( |
92 | - \PHPExcel\Chart\DataSeries::TYPE_BARCHART, // plotType |
|
93 | - \PHPExcel\Chart\DataSeries::GROUPING_STANDARD, // plotGrouping |
|
94 | - range(0, count($dataSeriesValues)-1), // plotOrder |
|
95 | - $dataSeriesLabels, // plotLabel |
|
96 | - $xAxisTickValues, // plotCategory |
|
92 | + \PHPExcel\Chart\DataSeries::TYPE_BARCHART, // plotType |
|
93 | + \PHPExcel\Chart\DataSeries::GROUPING_STANDARD, // plotGrouping |
|
94 | + range(0, count($dataSeriesValues) - 1), // plotOrder |
|
95 | + $dataSeriesLabels, // plotLabel |
|
96 | + $xAxisTickValues, // plotCategory |
|
97 | 97 | $dataSeriesValues // plotValues |
98 | 98 | ); |
99 | 99 | // Set additional dataseries parameters |
@@ -111,13 +111,13 @@ discard block |
||
111 | 111 | |
112 | 112 | // Create the chart |
113 | 113 | $chart = new \PHPExcel\Chart( |
114 | - 'chart1', // name |
|
115 | - $title, // title |
|
116 | - $legend, // legend |
|
117 | - $plotArea, // plotArea |
|
118 | - true, // plotVisibleOnly |
|
119 | - 0, // displayBlanksAs |
|
120 | - NULL, // xAxisLabel |
|
114 | + 'chart1', // name |
|
115 | + $title, // title |
|
116 | + $legend, // legend |
|
117 | + $plotArea, // plotArea |
|
118 | + true, // plotVisibleOnly |
|
119 | + 0, // displayBlanksAs |
|
120 | + NULL, // xAxisLabel |
|
121 | 121 | $yAxisLabel // yAxisLabel |
122 | 122 | ); |
123 | 123 | |
@@ -130,16 +130,16 @@ discard block |
||
130 | 130 | |
131 | 131 | |
132 | 132 | // Save Excel 2007 file |
133 | -echo date('H:i:s') , " Write to Excel2007 format" , EOL; |
|
133 | +echo date('H:i:s'), " Write to Excel2007 format", EOL; |
|
134 | 134 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007'); |
135 | 135 | $objWriter->setIncludeCharts(TRUE); |
136 | 136 | $objWriter->save(str_replace('.php', '.xlsx', __FILE__)); |
137 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
137 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
138 | 138 | |
139 | 139 | |
140 | 140 | // Echo memory peak usage |
141 | -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
141 | +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; |
|
142 | 142 | |
143 | 143 | // Echo done |
144 | -echo date('H:i:s') , " Done writing file" , EOL; |
|
145 | -echo 'File has been created in ' , getcwd() , EOL; |
|
144 | +echo date('H:i:s'), " Done writing file", EOL; |
|
145 | +echo 'File has been created in ', getcwd(), EOL; |