@@ -43,13 +43,13 @@ discard block |
||
43 | 43 | $objPHPExcel = new \PHPExcel\Spreadsheet(); |
44 | 44 | $objWorksheet = $objPHPExcel->getActiveSheet(); |
45 | 45 | $objWorksheet->fromArray( |
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), |
|
52 | - ) |
|
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), |
|
52 | + ) |
|
53 | 53 | ); |
54 | 54 | |
55 | 55 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | // Data values |
62 | 62 | // Data Marker |
63 | 63 | $dataSeriesLabels1 = array( |
64 | - new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011 |
|
64 | + new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011 |
|
65 | 65 | ); |
66 | 66 | // Set the X-Axis Labels |
67 | 67 | // Datatype |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | // Data values |
72 | 72 | // Data Marker |
73 | 73 | $xAxisTickValues1 = array( |
74 | - new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', NULL, 4), // Q1 to Q4 |
|
74 | + new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', NULL, 4), // Q1 to Q4 |
|
75 | 75 | ); |
76 | 76 | // Set the Data values for each data series we want to plot |
77 | 77 | // Datatype |
@@ -81,17 +81,17 @@ discard block |
||
81 | 81 | // Data values |
82 | 82 | // Data Marker |
83 | 83 | $dataSeriesValues1 = array( |
84 | - new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', NULL, 4), |
|
84 | + new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', NULL, 4), |
|
85 | 85 | ); |
86 | 86 | |
87 | 87 | // Build the dataseries |
88 | 88 | $series1 = new \PHPExcel\Chart\DataSeries( |
89 | - \PHPExcel\Chart\DataSeries::TYPE_PIECHART, // plotType |
|
90 | - NULL, // plotGrouping (Pie charts don't have any grouping) |
|
91 | - range(0, count($dataSeriesValues1)-1), // plotOrder |
|
92 | - $dataSeriesLabels1, // plotLabel |
|
93 | - $xAxisTickValues1, // plotCategory |
|
94 | - $dataSeriesValues1 // plotValues |
|
89 | + \PHPExcel\Chart\DataSeries::TYPE_PIECHART, // plotType |
|
90 | + NULL, // plotGrouping (Pie charts don't have any grouping) |
|
91 | + range(0, count($dataSeriesValues1)-1), // plotOrder |
|
92 | + $dataSeriesLabels1, // plotLabel |
|
93 | + $xAxisTickValues1, // plotCategory |
|
94 | + $dataSeriesValues1 // plotValues |
|
95 | 95 | ); |
96 | 96 | |
97 | 97 | // Set up a layout object for the Pie chart |
@@ -109,14 +109,14 @@ discard block |
||
109 | 109 | |
110 | 110 | // Create the chart |
111 | 111 | $chart1 = new \PHPExcel\Chart( |
112 | - 'chart1', // name |
|
113 | - $title1, // title |
|
114 | - $legend1, // legend |
|
115 | - $plotArea1, // plotArea |
|
116 | - true, // plotVisibleOnly |
|
117 | - 0, // displayBlanksAs |
|
118 | - NULL, // xAxisLabel |
|
119 | - NULL // yAxisLabel - Pie charts don't have a Y-Axis |
|
112 | + 'chart1', // name |
|
113 | + $title1, // title |
|
114 | + $legend1, // legend |
|
115 | + $plotArea1, // plotArea |
|
116 | + true, // plotVisibleOnly |
|
117 | + 0, // displayBlanksAs |
|
118 | + NULL, // xAxisLabel |
|
119 | + NULL // yAxisLabel - Pie charts don't have a Y-Axis |
|
120 | 120 | ); |
121 | 121 | |
122 | 122 | // Set the position where the chart should appear in the worksheet |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | // Data values |
136 | 136 | // Data Marker |
137 | 137 | $dataSeriesLabels2 = array( |
138 | - new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011 |
|
138 | + new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011 |
|
139 | 139 | ); |
140 | 140 | // Set the X-Axis Labels |
141 | 141 | // Datatype |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | // Data values |
146 | 146 | // Data Marker |
147 | 147 | $xAxisTickValues2 = array( |
148 | - new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', NULL, 4), // Q1 to Q4 |
|
148 | + new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', NULL, 4), // Q1 to Q4 |
|
149 | 149 | ); |
150 | 150 | // Set the Data values for each data series we want to plot |
151 | 151 | // Datatype |
@@ -155,17 +155,17 @@ discard block |
||
155 | 155 | // Data values |
156 | 156 | // Data Marker |
157 | 157 | $dataSeriesValues2 = array( |
158 | - new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', NULL, 4), |
|
158 | + new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', NULL, 4), |
|
159 | 159 | ); |
160 | 160 | |
161 | 161 | // Build the dataseries |
162 | 162 | $series2 = new \PHPExcel\Chart\DataSeries( |
163 | - \PHPExcel\Chart\DataSeries::TYPE_DONUTCHART, // plotType |
|
164 | - NULL, // plotGrouping (Donut charts don't have any grouping) |
|
165 | - range(0, count($dataSeriesValues2)-1), // plotOrder |
|
166 | - $dataSeriesLabels2, // plotLabel |
|
167 | - $xAxisTickValues2, // plotCategory |
|
168 | - $dataSeriesValues2 // plotValues |
|
163 | + \PHPExcel\Chart\DataSeries::TYPE_DONUTCHART, // plotType |
|
164 | + NULL, // plotGrouping (Donut charts don't have any grouping) |
|
165 | + range(0, count($dataSeriesValues2)-1), // plotOrder |
|
166 | + $dataSeriesLabels2, // plotLabel |
|
167 | + $xAxisTickValues2, // plotCategory |
|
168 | + $dataSeriesValues2 // plotValues |
|
169 | 169 | ); |
170 | 170 | |
171 | 171 | // Set up a layout object for the Pie chart |
@@ -181,14 +181,14 @@ discard block |
||
181 | 181 | |
182 | 182 | // Create the chart |
183 | 183 | $chart2 = new \PHPExcel\Chart( |
184 | - 'chart2', // name |
|
185 | - $title2, // title |
|
186 | - NULL, // legend |
|
187 | - $plotArea2, // plotArea |
|
188 | - true, // plotVisibleOnly |
|
189 | - 0, // displayBlanksAs |
|
190 | - NULL, // xAxisLabel |
|
191 | - NULL // yAxisLabel - Like Pie charts, Donut charts don't have a Y-Axis |
|
184 | + 'chart2', // name |
|
185 | + $title2, // title |
|
186 | + NULL, // legend |
|
187 | + $plotArea2, // plotArea |
|
188 | + true, // plotVisibleOnly |
|
189 | + 0, // displayBlanksAs |
|
190 | + NULL, // xAxisLabel |
|
191 | + NULL // yAxisLabel - Like Pie charts, Donut charts don't have a Y-Axis |
|
192 | 192 | ); |
193 | 193 | |
194 | 194 | // Set the position where the chart should appear in the worksheet |
@@ -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 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | // Data values |
62 | 62 | // Data Marker |
63 | 63 | $dataSeriesLabels1 = array( |
64 | - new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011 |
|
64 | + new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011 |
|
65 | 65 | ); |
66 | 66 | // Set the X-Axis Labels |
67 | 67 | // Datatype |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | // Data values |
72 | 72 | // Data Marker |
73 | 73 | $xAxisTickValues1 = array( |
74 | - new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', NULL, 4), // Q1 to Q4 |
|
74 | + new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', NULL, 4), // Q1 to Q4 |
|
75 | 75 | ); |
76 | 76 | // Set the Data values for each data series we want to plot |
77 | 77 | // Datatype |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | |
87 | 87 | // Build the dataseries |
88 | 88 | $series1 = new \PHPExcel\Chart\DataSeries( |
89 | - \PHPExcel\Chart\DataSeries::TYPE_PIECHART, // plotType |
|
90 | - NULL, // plotGrouping (Pie charts don't have any grouping) |
|
91 | - range(0, count($dataSeriesValues1)-1), // plotOrder |
|
92 | - $dataSeriesLabels1, // plotLabel |
|
93 | - $xAxisTickValues1, // plotCategory |
|
89 | + \PHPExcel\Chart\DataSeries::TYPE_PIECHART, // plotType |
|
90 | + NULL, // plotGrouping (Pie charts don't have any grouping) |
|
91 | + range(0, count($dataSeriesValues1) - 1), // plotOrder |
|
92 | + $dataSeriesLabels1, // plotLabel |
|
93 | + $xAxisTickValues1, // plotCategory |
|
94 | 94 | $dataSeriesValues1 // plotValues |
95 | 95 | ); |
96 | 96 | |
@@ -109,13 +109,13 @@ discard block |
||
109 | 109 | |
110 | 110 | // Create the chart |
111 | 111 | $chart1 = new \PHPExcel\Chart( |
112 | - 'chart1', // name |
|
113 | - $title1, // title |
|
114 | - $legend1, // legend |
|
115 | - $plotArea1, // plotArea |
|
116 | - true, // plotVisibleOnly |
|
117 | - 0, // displayBlanksAs |
|
118 | - NULL, // xAxisLabel |
|
112 | + 'chart1', // name |
|
113 | + $title1, // title |
|
114 | + $legend1, // legend |
|
115 | + $plotArea1, // plotArea |
|
116 | + true, // plotVisibleOnly |
|
117 | + 0, // displayBlanksAs |
|
118 | + NULL, // xAxisLabel |
|
119 | 119 | NULL // yAxisLabel - Pie charts don't have a Y-Axis |
120 | 120 | ); |
121 | 121 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | // Data values |
136 | 136 | // Data Marker |
137 | 137 | $dataSeriesLabels2 = array( |
138 | - new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011 |
|
138 | + new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011 |
|
139 | 139 | ); |
140 | 140 | // Set the X-Axis Labels |
141 | 141 | // Datatype |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | // Data values |
146 | 146 | // Data Marker |
147 | 147 | $xAxisTickValues2 = array( |
148 | - new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', NULL, 4), // Q1 to Q4 |
|
148 | + new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', NULL, 4), // Q1 to Q4 |
|
149 | 149 | ); |
150 | 150 | // Set the Data values for each data series we want to plot |
151 | 151 | // Datatype |
@@ -160,11 +160,11 @@ discard block |
||
160 | 160 | |
161 | 161 | // Build the dataseries |
162 | 162 | $series2 = new \PHPExcel\Chart\DataSeries( |
163 | - \PHPExcel\Chart\DataSeries::TYPE_DONUTCHART, // plotType |
|
164 | - NULL, // plotGrouping (Donut charts don't have any grouping) |
|
165 | - range(0, count($dataSeriesValues2)-1), // plotOrder |
|
166 | - $dataSeriesLabels2, // plotLabel |
|
167 | - $xAxisTickValues2, // plotCategory |
|
163 | + \PHPExcel\Chart\DataSeries::TYPE_DONUTCHART, // plotType |
|
164 | + NULL, // plotGrouping (Donut charts don't have any grouping) |
|
165 | + range(0, count($dataSeriesValues2) - 1), // plotOrder |
|
166 | + $dataSeriesLabels2, // plotLabel |
|
167 | + $xAxisTickValues2, // plotCategory |
|
168 | 168 | $dataSeriesValues2 // plotValues |
169 | 169 | ); |
170 | 170 | |
@@ -181,13 +181,13 @@ discard block |
||
181 | 181 | |
182 | 182 | // Create the chart |
183 | 183 | $chart2 = new \PHPExcel\Chart( |
184 | - 'chart2', // name |
|
185 | - $title2, // title |
|
186 | - NULL, // legend |
|
187 | - $plotArea2, // plotArea |
|
188 | - true, // plotVisibleOnly |
|
189 | - 0, // displayBlanksAs |
|
190 | - NULL, // xAxisLabel |
|
184 | + 'chart2', // name |
|
185 | + $title2, // title |
|
186 | + NULL, // legend |
|
187 | + $plotArea2, // plotArea |
|
188 | + true, // plotVisibleOnly |
|
189 | + 0, // displayBlanksAs |
|
190 | + NULL, // xAxisLabel |
|
191 | 191 | NULL // yAxisLabel - Like Pie charts, Donut charts don't have a Y-Axis |
192 | 192 | ); |
193 | 193 | |
@@ -200,16 +200,16 @@ discard block |
||
200 | 200 | |
201 | 201 | |
202 | 202 | // Save Excel 2007 file |
203 | -echo date('H:i:s') , " Write to Excel2007 format" , EOL; |
|
203 | +echo date('H:i:s'), " Write to Excel2007 format", EOL; |
|
204 | 204 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007'); |
205 | 205 | $objWriter->setIncludeCharts(TRUE); |
206 | 206 | $objWriter->save(str_replace('.php', '.xlsx', __FILE__)); |
207 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
207 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
208 | 208 | |
209 | 209 | |
210 | 210 | // Echo memory peak usage |
211 | -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
211 | +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; |
|
212 | 212 | |
213 | 213 | // Echo done |
214 | -echo date('H:i:s') , " Done writing file" , EOL; |
|
215 | -echo 'File has been created in ' , getcwd() , EOL; |
|
214 | +echo date('H:i:s'), " Done writing file", EOL; |
|
215 | +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 | |
@@ -53,11 +53,11 @@ discard block |
||
53 | 53 | */ |
54 | 54 | |
55 | 55 | // Create new PHPExcel object |
56 | -echo date('H:i:s') , " Create new PHPExcel object" , EOL; |
|
56 | +echo date('H:i:s'), " Create new PHPExcel object", EOL; |
|
57 | 57 | $objPHPExcel = new \PHPExcel\Spreadsheet(); |
58 | 58 | |
59 | 59 | // Set document properties |
60 | -echo date('H:i:s') , " Set properties" , EOL; |
|
60 | +echo date('H:i:s'), " Set properties", EOL; |
|
61 | 61 | $objPHPExcel->getProperties()->setCreator("Maarten Balliauw") |
62 | 62 | ->setLastModifiedBy("Maarten Balliauw") |
63 | 63 | ->setTitle("Office 2007 XLSX Test Document") |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | |
69 | 69 | |
70 | 70 | // Create a first sheet |
71 | -echo date('H:i:s') , " Add data" , EOL; |
|
71 | +echo date('H:i:s'), " Add data", EOL; |
|
72 | 72 | $objPHPExcel->setActiveSheetIndex(0); |
73 | 73 | $objPHPExcel->getActiveSheet()->setCellValue('A1', "Firstname"); |
74 | 74 | $objPHPExcel->getActiveSheet()->setCellValue('B1', "Lastname"); |
@@ -78,24 +78,24 @@ discard block |
||
78 | 78 | |
79 | 79 | |
80 | 80 | // Hide "Phone" and "fax" column |
81 | -echo date('H:i:s') , " Hide 'Phone' and 'fax' columns" , EOL; |
|
81 | +echo date('H:i:s'), " Hide 'Phone' and 'fax' columns", EOL; |
|
82 | 82 | $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setVisible(false); |
83 | 83 | $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setVisible(false); |
84 | 84 | |
85 | 85 | |
86 | 86 | // Set outline levels |
87 | -echo date('H:i:s') , " Set outline levels" , EOL; |
|
87 | +echo date('H:i:s'), " Set outline levels", EOL; |
|
88 | 88 | $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setOutlineLevel(1) |
89 | 89 | ->setVisible(false) |
90 | 90 | ->setCollapsed(true); |
91 | 91 | |
92 | 92 | // Freeze panes |
93 | -echo date('H:i:s') , " Freeze panes" , EOL; |
|
93 | +echo date('H:i:s'), " Freeze panes", EOL; |
|
94 | 94 | $objPHPExcel->getActiveSheet()->freezePane('A2'); |
95 | 95 | |
96 | 96 | |
97 | 97 | // Rows to repeat at top |
98 | -echo date('H:i:s') , " Rows to repeat at top" , EOL; |
|
98 | +echo date('H:i:s'), " Rows to repeat at top", EOL; |
|
99 | 99 | $objPHPExcel->getActiveSheet()->getPageSetup()->setRowsToRepeatAtTopByStartAndEnd(1, 1); |
100 | 100 | |
101 | 101 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | |
115 | 115 | |
116 | 116 | // Save Excel 95 file |
117 | -echo date('H:i:s') , " Write to Excel5 format" , EOL; |
|
117 | +echo date('H:i:s'), " Write to Excel5 format", EOL; |
|
118 | 118 | $callStartTime = microtime(true); |
119 | 119 | |
120 | 120 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5'); |
@@ -122,15 +122,15 @@ discard block |
||
122 | 122 | $callEndTime = microtime(true); |
123 | 123 | $callTime = $callEndTime - $callStartTime; |
124 | 124 | |
125 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
126 | -echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL; |
|
125 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
126 | +echo 'Call time to write Workbook was ', sprintf('%.4f', $callTime), " seconds", EOL; |
|
127 | 127 | // Echo memory usage |
128 | -echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
128 | +echo date('H:i:s'), ' Current memory usage: ', (memory_get_usage(true) / 1024 / 1024), " MB", EOL; |
|
129 | 129 | |
130 | 130 | |
131 | 131 | // Echo memory peak usage |
132 | -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
132 | +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; |
|
133 | 133 | |
134 | 134 | // Echo done |
135 | -echo date('H:i:s') , " Done writing file" , EOL; |
|
136 | -echo 'File has been created in ' , getcwd() , EOL; |
|
135 | +echo date('H:i:s'), " Done writing file", EOL; |
|
136 | +echo 'File has been created in ', getcwd(), EOL; |
@@ -52,12 +52,12 @@ discard block |
||
52 | 52 | // Set document properties |
53 | 53 | echo date('H:i:s') , " Set properties" , EOL; |
54 | 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"); |
|
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 | 61 | |
62 | 62 | |
63 | 63 | // Create a first sheet |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | // Set outline levels |
80 | 80 | echo date('H:i:s') , " Set outline levels" , EOL; |
81 | 81 | $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setOutlineLevel(1) |
82 | - ->setVisible(false) |
|
83 | - ->setCollapsed(true); |
|
82 | + ->setVisible(false) |
|
83 | + ->setCollapsed(true); |
|
84 | 84 | |
85 | 85 | // Freeze panes |
86 | 86 | echo date('H:i:s') , " Freeze panes" , EOL; |
@@ -94,11 +94,11 @@ discard block |
||
94 | 94 | |
95 | 95 | // Add data |
96 | 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); |
|
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 | 102 | } |
103 | 103 | |
104 | 104 |
@@ -52,142 +52,142 @@ discard block |
||
52 | 52 | // Add some data, we will use some formulas here |
53 | 53 | echo date('H:i:s') , " Add some data and formulas" , EOL; |
54 | 54 | $objPHPExcel->getActiveSheet()->setCellValue('A14', 'Count:') |
55 | - ->setCellValue('A15', 'Sum:') |
|
56 | - ->setCellValue('A16', 'Max:') |
|
57 | - ->setCellValue('A17', 'Min:') |
|
58 | - ->setCellValue('A18', 'Average:') |
|
59 | - ->setCellValue('A19', 'Median:') |
|
60 | - ->setCellValue('A20', 'Mode:'); |
|
55 | + ->setCellValue('A15', 'Sum:') |
|
56 | + ->setCellValue('A16', 'Max:') |
|
57 | + ->setCellValue('A17', 'Min:') |
|
58 | + ->setCellValue('A18', 'Average:') |
|
59 | + ->setCellValue('A19', 'Median:') |
|
60 | + ->setCellValue('A20', 'Mode:'); |
|
61 | 61 | |
62 | 62 | $objPHPExcel->getActiveSheet()->setCellValue('A22', 'CountA:') |
63 | - ->setCellValue('A23', 'MaxA:') |
|
64 | - ->setCellValue('A24', 'MinA:'); |
|
63 | + ->setCellValue('A23', 'MaxA:') |
|
64 | + ->setCellValue('A24', 'MinA:'); |
|
65 | 65 | |
66 | 66 | $objPHPExcel->getActiveSheet()->setCellValue('A26', 'StDev:') |
67 | - ->setCellValue('A27', 'StDevA:') |
|
68 | - ->setCellValue('A28', 'StDevP:') |
|
69 | - ->setCellValue('A29', 'StDevPA:'); |
|
67 | + ->setCellValue('A27', 'StDevA:') |
|
68 | + ->setCellValue('A28', 'StDevP:') |
|
69 | + ->setCellValue('A29', 'StDevPA:'); |
|
70 | 70 | |
71 | 71 | $objPHPExcel->getActiveSheet()->setCellValue('A31', 'DevSq:') |
72 | - ->setCellValue('A32', 'Var:') |
|
73 | - ->setCellValue('A33', 'VarA:') |
|
74 | - ->setCellValue('A34', 'VarP:') |
|
75 | - ->setCellValue('A35', 'VarPA:'); |
|
72 | + ->setCellValue('A32', 'Var:') |
|
73 | + ->setCellValue('A33', 'VarA:') |
|
74 | + ->setCellValue('A34', 'VarP:') |
|
75 | + ->setCellValue('A35', 'VarPA:'); |
|
76 | 76 | |
77 | 77 | $objPHPExcel->getActiveSheet()->setCellValue('A37', 'Date:'); |
78 | 78 | |
79 | 79 | |
80 | 80 | $objPHPExcel->getActiveSheet()->setCellValue('B1', 'Range 1') |
81 | - ->setCellValue('B2', 2) |
|
82 | - ->setCellValue('B3', 8) |
|
83 | - ->setCellValue('B4', 10) |
|
84 | - ->setCellValue('B5', True) |
|
85 | - ->setCellValue('B6', False) |
|
86 | - ->setCellValue('B7', 'Text String') |
|
87 | - ->setCellValue('B9', '22') |
|
88 | - ->setCellValue('B10', 4) |
|
89 | - ->setCellValue('B11', 6) |
|
90 | - ->setCellValue('B12', 12); |
|
81 | + ->setCellValue('B2', 2) |
|
82 | + ->setCellValue('B3', 8) |
|
83 | + ->setCellValue('B4', 10) |
|
84 | + ->setCellValue('B5', True) |
|
85 | + ->setCellValue('B6', False) |
|
86 | + ->setCellValue('B7', 'Text String') |
|
87 | + ->setCellValue('B9', '22') |
|
88 | + ->setCellValue('B10', 4) |
|
89 | + ->setCellValue('B11', 6) |
|
90 | + ->setCellValue('B12', 12); |
|
91 | 91 | |
92 | 92 | $objPHPExcel->getActiveSheet()->setCellValue('B14', '=COUNT(B2:B12)') |
93 | - ->setCellValue('B15', '=SUM(B2:B12)') |
|
94 | - ->setCellValue('B16', '=MAX(B2:B12)') |
|
95 | - ->setCellValue('B17', '=MIN(B2:B12)') |
|
96 | - ->setCellValue('B18', '=AVERAGE(B2:B12)') |
|
97 | - ->setCellValue('B19', '=MEDIAN(B2:B12)') |
|
98 | - ->setCellValue('B20', '=MODE(B2:B12)'); |
|
93 | + ->setCellValue('B15', '=SUM(B2:B12)') |
|
94 | + ->setCellValue('B16', '=MAX(B2:B12)') |
|
95 | + ->setCellValue('B17', '=MIN(B2:B12)') |
|
96 | + ->setCellValue('B18', '=AVERAGE(B2:B12)') |
|
97 | + ->setCellValue('B19', '=MEDIAN(B2:B12)') |
|
98 | + ->setCellValue('B20', '=MODE(B2:B12)'); |
|
99 | 99 | |
100 | 100 | $objPHPExcel->getActiveSheet()->setCellValue('B22', '=COUNTA(B2:B12)') |
101 | - ->setCellValue('B23', '=MAXA(B2:B12)') |
|
102 | - ->setCellValue('B24', '=MINA(B2:B12)'); |
|
101 | + ->setCellValue('B23', '=MAXA(B2:B12)') |
|
102 | + ->setCellValue('B24', '=MINA(B2:B12)'); |
|
103 | 103 | |
104 | 104 | $objPHPExcel->getActiveSheet()->setCellValue('B26', '=STDEV(B2:B12)') |
105 | - ->setCellValue('B27', '=STDEVA(B2:B12)') |
|
106 | - ->setCellValue('B28', '=STDEVP(B2:B12)') |
|
107 | - ->setCellValue('B29', '=STDEVPA(B2:B12)'); |
|
105 | + ->setCellValue('B27', '=STDEVA(B2:B12)') |
|
106 | + ->setCellValue('B28', '=STDEVP(B2:B12)') |
|
107 | + ->setCellValue('B29', '=STDEVPA(B2:B12)'); |
|
108 | 108 | |
109 | 109 | $objPHPExcel->getActiveSheet()->setCellValue('B31', '=DEVSQ(B2:B12)') |
110 | - ->setCellValue('B32', '=VAR(B2:B12)') |
|
111 | - ->setCellValue('B33', '=VARA(B2:B12)') |
|
112 | - ->setCellValue('B34', '=VARP(B2:B12)') |
|
113 | - ->setCellValue('B35', '=VARPA(B2:B12)'); |
|
110 | + ->setCellValue('B32', '=VAR(B2:B12)') |
|
111 | + ->setCellValue('B33', '=VARA(B2:B12)') |
|
112 | + ->setCellValue('B34', '=VARP(B2:B12)') |
|
113 | + ->setCellValue('B35', '=VARPA(B2:B12)'); |
|
114 | 114 | |
115 | 115 | $objPHPExcel->getActiveSheet()->setCellValue('B37', '=DATE(2007, 12, 21)') |
116 | - ->setCellValue('B38', '=DATEDIF( DATE(2007, 12, 21), DATE(2007, 12, 22), "D" )') |
|
117 | - ->setCellValue('B39', '=DATEVALUE("01-Feb-2006 10:06 AM")') |
|
118 | - ->setCellValue('B40', '=DAY( DATE(2006, 1, 2) )') |
|
119 | - ->setCellValue('B41', '=DAYS360( DATE(2002, 2, 3), DATE(2005, 5, 31) )'); |
|
116 | + ->setCellValue('B38', '=DATEDIF( DATE(2007, 12, 21), DATE(2007, 12, 22), "D" )') |
|
117 | + ->setCellValue('B39', '=DATEVALUE("01-Feb-2006 10:06 AM")') |
|
118 | + ->setCellValue('B40', '=DAY( DATE(2006, 1, 2) )') |
|
119 | + ->setCellValue('B41', '=DAYS360( DATE(2002, 2, 3), DATE(2005, 5, 31) )'); |
|
120 | 120 | |
121 | 121 | |
122 | 122 | $objPHPExcel->getActiveSheet()->setCellValue('C1', 'Range 2') |
123 | - ->setCellValue('C2', 1) |
|
124 | - ->setCellValue('C3', 2) |
|
125 | - ->setCellValue('C4', 2) |
|
126 | - ->setCellValue('C5', 3) |
|
127 | - ->setCellValue('C6', 3) |
|
128 | - ->setCellValue('C7', 3) |
|
129 | - ->setCellValue('C8', '0') |
|
130 | - ->setCellValue('C9', 4) |
|
131 | - ->setCellValue('C10', 4) |
|
132 | - ->setCellValue('C11', 4) |
|
133 | - ->setCellValue('C12', 4); |
|
123 | + ->setCellValue('C2', 1) |
|
124 | + ->setCellValue('C3', 2) |
|
125 | + ->setCellValue('C4', 2) |
|
126 | + ->setCellValue('C5', 3) |
|
127 | + ->setCellValue('C6', 3) |
|
128 | + ->setCellValue('C7', 3) |
|
129 | + ->setCellValue('C8', '0') |
|
130 | + ->setCellValue('C9', 4) |
|
131 | + ->setCellValue('C10', 4) |
|
132 | + ->setCellValue('C11', 4) |
|
133 | + ->setCellValue('C12', 4); |
|
134 | 134 | |
135 | 135 | $objPHPExcel->getActiveSheet()->setCellValue('C14', '=COUNT(C2:C12)') |
136 | - ->setCellValue('C15', '=SUM(C2:C12)') |
|
137 | - ->setCellValue('C16', '=MAX(C2:C12)') |
|
138 | - ->setCellValue('C17', '=MIN(C2:C12)') |
|
139 | - ->setCellValue('C18', '=AVERAGE(C2:C12)') |
|
140 | - ->setCellValue('C19', '=MEDIAN(C2:C12)') |
|
141 | - ->setCellValue('C20', '=MODE(C2:C12)'); |
|
136 | + ->setCellValue('C15', '=SUM(C2:C12)') |
|
137 | + ->setCellValue('C16', '=MAX(C2:C12)') |
|
138 | + ->setCellValue('C17', '=MIN(C2:C12)') |
|
139 | + ->setCellValue('C18', '=AVERAGE(C2:C12)') |
|
140 | + ->setCellValue('C19', '=MEDIAN(C2:C12)') |
|
141 | + ->setCellValue('C20', '=MODE(C2:C12)'); |
|
142 | 142 | |
143 | 143 | $objPHPExcel->getActiveSheet()->setCellValue('C22', '=COUNTA(C2:C12)') |
144 | - ->setCellValue('C23', '=MAXA(C2:C12)') |
|
145 | - ->setCellValue('C24', '=MINA(C2:C12)'); |
|
144 | + ->setCellValue('C23', '=MAXA(C2:C12)') |
|
145 | + ->setCellValue('C24', '=MINA(C2:C12)'); |
|
146 | 146 | |
147 | 147 | $objPHPExcel->getActiveSheet()->setCellValue('C26', '=STDEV(C2:C12)') |
148 | - ->setCellValue('C27', '=STDEVA(C2:C12)') |
|
149 | - ->setCellValue('C28', '=STDEVP(C2:C12)') |
|
150 | - ->setCellValue('C29', '=STDEVPA(C2:C12)'); |
|
148 | + ->setCellValue('C27', '=STDEVA(C2:C12)') |
|
149 | + ->setCellValue('C28', '=STDEVP(C2:C12)') |
|
150 | + ->setCellValue('C29', '=STDEVPA(C2:C12)'); |
|
151 | 151 | |
152 | 152 | $objPHPExcel->getActiveSheet()->setCellValue('C31', '=DEVSQ(C2:C12)') |
153 | - ->setCellValue('C32', '=VAR(C2:C12)') |
|
154 | - ->setCellValue('C33', '=VARA(C2:C12)') |
|
155 | - ->setCellValue('C34', '=VARP(C2:C12)') |
|
156 | - ->setCellValue('C35', '=VARPA(C2:C12)'); |
|
153 | + ->setCellValue('C32', '=VAR(C2:C12)') |
|
154 | + ->setCellValue('C33', '=VARA(C2:C12)') |
|
155 | + ->setCellValue('C34', '=VARP(C2:C12)') |
|
156 | + ->setCellValue('C35', '=VARPA(C2:C12)'); |
|
157 | 157 | |
158 | 158 | |
159 | 159 | $objPHPExcel->getActiveSheet()->setCellValue('D1', 'Range 3') |
160 | - ->setCellValue('D2', 2) |
|
161 | - ->setCellValue('D3', 3) |
|
162 | - ->setCellValue('D4', 4); |
|
160 | + ->setCellValue('D2', 2) |
|
161 | + ->setCellValue('D3', 3) |
|
162 | + ->setCellValue('D4', 4); |
|
163 | 163 | |
164 | 164 | $objPHPExcel->getActiveSheet()->setCellValue('D14', '=((D2 * D3) + D4) & " should be 10"'); |
165 | 165 | |
166 | 166 | $objPHPExcel->getActiveSheet()->setCellValue('E12', 'Other functions') |
167 | - ->setCellValue('E14', '=PI()') |
|
168 | - ->setCellValue('E15', '=RAND()') |
|
169 | - ->setCellValue('E16', '=RANDBETWEEN(5, 10)'); |
|
167 | + ->setCellValue('E14', '=PI()') |
|
168 | + ->setCellValue('E15', '=RAND()') |
|
169 | + ->setCellValue('E16', '=RANDBETWEEN(5, 10)'); |
|
170 | 170 | |
171 | 171 | $objPHPExcel->getActiveSheet()->setCellValue('E17', 'Count of both ranges:') |
172 | - ->setCellValue('F17', '=COUNT(B2:C12)'); |
|
172 | + ->setCellValue('F17', '=COUNT(B2:C12)'); |
|
173 | 173 | |
174 | 174 | $objPHPExcel->getActiveSheet()->setCellValue('E18', 'Total of both ranges:') |
175 | - ->setCellValue('F18', '=SUM(B2:C12)'); |
|
175 | + ->setCellValue('F18', '=SUM(B2:C12)'); |
|
176 | 176 | |
177 | 177 | $objPHPExcel->getActiveSheet()->setCellValue('E19', 'Maximum of both ranges:') |
178 | - ->setCellValue('F19', '=MAX(B2:C12)'); |
|
178 | + ->setCellValue('F19', '=MAX(B2:C12)'); |
|
179 | 179 | |
180 | 180 | $objPHPExcel->getActiveSheet()->setCellValue('E20', 'Minimum of both ranges:') |
181 | - ->setCellValue('F20', '=MIN(B2:C12)'); |
|
181 | + ->setCellValue('F20', '=MIN(B2:C12)'); |
|
182 | 182 | |
183 | 183 | $objPHPExcel->getActiveSheet()->setCellValue('E21', 'Average of both ranges:') |
184 | - ->setCellValue('F21', '=AVERAGE(B2:C12)'); |
|
184 | + ->setCellValue('F21', '=AVERAGE(B2:C12)'); |
|
185 | 185 | |
186 | 186 | $objPHPExcel->getActiveSheet()->setCellValue('E22', 'Median of both ranges:') |
187 | - ->setCellValue('F22', '=MEDIAN(B2:C12)'); |
|
187 | + ->setCellValue('F22', '=MEDIAN(B2:C12)'); |
|
188 | 188 | |
189 | 189 | $objPHPExcel->getActiveSheet()->setCellValue('E23', 'Mode of both ranges:') |
190 | - ->setCellValue('F23', '=MODE(B2:C12)'); |
|
190 | + ->setCellValue('F23', '=MODE(B2:C12)'); |
|
191 | 191 | |
192 | 192 | |
193 | 193 | // Calculated data |
@@ -195,9 +195,9 @@ discard block |
||
195 | 195 | for ($col = 'B'; $col != 'G'; ++$col) { |
196 | 196 | for($row = 14; $row <= 41; ++$row) { |
197 | 197 | if ((!is_null($formula = $objPHPExcel->getActiveSheet()->getCell($col.$row)->getValue())) && |
198 | - ($formula[0] == '=')) { |
|
198 | + ($formula[0] == '=')) { |
|
199 | 199 | echo 'Value of ' , $col , $row , ' [' , $formula , ']: ' , |
200 | - $objPHPExcel->getActiveSheet()->getCell($col.$row)->getCalculatedValue() . EOL; |
|
200 | + $objPHPExcel->getActiveSheet()->getCell($col.$row)->getCalculatedValue() . EOL; |
|
201 | 201 | } |
202 | 202 | } |
203 | 203 | } |
@@ -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 | mt_srand(1234567890); |
@@ -41,16 +41,16 @@ discard block |
||
41 | 41 | |
42 | 42 | |
43 | 43 | // List functions |
44 | -echo date('H:i:s') , " List implemented functions" , EOL; |
|
44 | +echo date('H:i:s'), " List implemented functions", EOL; |
|
45 | 45 | $objCalc = \PHPExcel\Calculation::getInstance(); |
46 | 46 | print_r($objCalc->listFunctionNames()); |
47 | 47 | |
48 | 48 | // Create new PHPExcel object |
49 | -echo date('H:i:s') , " Create new PHPExcel object" , EOL; |
|
49 | +echo date('H:i:s'), " Create new PHPExcel object", EOL; |
|
50 | 50 | $objPHPExcel = new \PHPExcel\Spreadsheet(); |
51 | 51 | |
52 | 52 | // Add some data, we will use some formulas here |
53 | -echo date('H:i:s') , " Add some data and formulas" , EOL; |
|
53 | +echo date('H:i:s'), " Add some data and formulas", EOL; |
|
54 | 54 | $objPHPExcel->getActiveSheet()->setCellValue('A14', 'Count:') |
55 | 55 | ->setCellValue('A15', 'Sum:') |
56 | 56 | ->setCellValue('A16', 'Max:') |
@@ -191,20 +191,20 @@ discard block |
||
191 | 191 | |
192 | 192 | |
193 | 193 | // Calculated data |
194 | -echo date('H:i:s') , " Calculated data" , EOL; |
|
194 | +echo date('H:i:s'), " Calculated data", EOL; |
|
195 | 195 | for ($col = 'B'; $col != 'G'; ++$col) { |
196 | - for($row = 14; $row <= 41; ++$row) { |
|
197 | - if ((!is_null($formula = $objPHPExcel->getActiveSheet()->getCell($col.$row)->getValue())) && |
|
196 | + for ($row = 14; $row <= 41; ++$row) { |
|
197 | + if ((!is_null($formula = $objPHPExcel->getActiveSheet()->getCell($col . $row)->getValue())) && |
|
198 | 198 | ($formula[0] == '=')) { |
199 | - echo 'Value of ' , $col , $row , ' [' , $formula , ']: ' , |
|
200 | - $objPHPExcel->getActiveSheet()->getCell($col.$row)->getCalculatedValue() . EOL; |
|
199 | + echo 'Value of ', $col, $row, ' [', $formula, ']: ', |
|
200 | + $objPHPExcel->getActiveSheet()->getCell($col . $row)->getCalculatedValue() . EOL; |
|
201 | 201 | } |
202 | 202 | } |
203 | 203 | } |
204 | 204 | |
205 | 205 | |
206 | 206 | // Save Excel 2007 file |
207 | -echo date('H:i:s') , " Write to Excel2007 format" , EOL; |
|
207 | +echo date('H:i:s'), " Write to Excel2007 format", EOL; |
|
208 | 208 | $callStartTime = microtime(true); |
209 | 209 | |
210 | 210 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007'); |
@@ -221,15 +221,15 @@ discard block |
||
221 | 221 | $callEndTime = microtime(true); |
222 | 222 | $callTime = $callEndTime - $callStartTime; |
223 | 223 | |
224 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
225 | -echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL; |
|
224 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
225 | +echo 'Call time to write Workbook was ', sprintf('%.4f', $callTime), " seconds", EOL; |
|
226 | 226 | // Echo memory usage |
227 | -echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
227 | +echo date('H:i:s'), ' Current memory usage: ', (memory_get_usage(true) / 1024 / 1024), " MB", EOL; |
|
228 | 228 | |
229 | 229 | |
230 | 230 | // Echo memory peak usage |
231 | -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
231 | +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; |
|
232 | 232 | |
233 | 233 | // Echo done |
234 | -echo date('H:i:s') , " Done writing file" , EOL; |
|
235 | -echo 'File has been created in ' , getcwd() , EOL; |
|
234 | +echo date('H:i:s'), " Done writing file", EOL; |
|
235 | +echo 'File has been created in ', getcwd(), EOL; |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | date_default_timezone_set('Europe/London'); |
33 | 33 | |
34 | 34 | if (PHP_SAPI == 'cli') |
35 | - die('This example should only be run from a Web Browser'); |
|
35 | + die('This example should only be run from a Web Browser'); |
|
36 | 36 | |
37 | 37 | /** Include PHPExcel */ |
38 | 38 | require_once dirname(__FILE__) . '/../src/Bootstrap.php'; |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | |
44 | 44 | // Set document properties |
45 | 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"); |
|
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 | 52 | |
53 | 53 | |
54 | 54 | // Add some data |
@@ -79,10 +79,10 @@ |
||
79 | 79 | header('Cache-Control: max-age=1'); |
80 | 80 | |
81 | 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 |
|
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 | 86 | |
87 | 87 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5'); |
88 | 88 | $objWriter->save('php://output'); |
@@ -31,8 +31,9 @@ |
||
31 | 31 | ini_set('display_startup_errors', TRUE); |
32 | 32 | date_default_timezone_set('Europe/London'); |
33 | 33 | |
34 | -if (PHP_SAPI == 'cli') |
|
34 | +if (PHP_SAPI == 'cli') { |
|
35 | 35 | die('This example should only be run from a Web Browser'); |
36 | +} |
|
36 | 37 | |
37 | 38 | /** Include PHPExcel */ |
38 | 39 | require_once dirname(__FILE__) . '/../src/Bootstrap.php'; |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | $cacheMethod = \PHPExcel\CachedObjectStorageFactory::CACHE_IN_MEMORY_GZIP; |
41 | 41 | if (!\PHPExcel\Settings::setCacheStorageMethod($cacheMethod)) { |
42 | - die($cacheMethod . " caching method is not available" . EOL); |
|
42 | + die($cacheMethod . " caching method is not available" . EOL); |
|
43 | 43 | } |
44 | 44 | echo date('H:i:s') , " Enable Cell Caching using " , $cacheMethod , " method" , EOL; |
45 | 45 | |
@@ -51,12 +51,12 @@ discard block |
||
51 | 51 | // Set document properties |
52 | 52 | echo date('H:i:s') , " Set properties" , EOL; |
53 | 53 | $objPHPExcel->getProperties()->setCreator("Maarten Balliauw") |
54 | - ->setLastModifiedBy("Maarten Balliauw") |
|
55 | - ->setTitle("Office 2007 XLSX Test Document") |
|
56 | - ->setSubject("Office 2007 XLSX Test Document") |
|
57 | - ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.") |
|
58 | - ->setKeywords("office 2007 openxml php") |
|
59 | - ->setCategory("Test result file"); |
|
54 | + ->setLastModifiedBy("Maarten Balliauw") |
|
55 | + ->setTitle("Office 2007 XLSX Test Document") |
|
56 | + ->setSubject("Office 2007 XLSX Test Document") |
|
57 | + ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.") |
|
58 | + ->setKeywords("office 2007 openxml php") |
|
59 | + ->setCategory("Test result file"); |
|
60 | 60 | |
61 | 61 | |
62 | 62 | // Create a first sheet |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | // Set outline levels |
79 | 79 | echo date('H:i:s') , " Set outline levels" , EOL; |
80 | 80 | $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setOutlineLevel(1) |
81 | - ->setVisible(false) |
|
82 | - ->setCollapsed(true); |
|
81 | + ->setVisible(false) |
|
82 | + ->setCollapsed(true); |
|
83 | 83 | |
84 | 84 | // Freeze panes |
85 | 85 | echo date('H:i:s') , " Freeze panes" , EOL; |
@@ -93,11 +93,11 @@ discard block |
||
93 | 93 | |
94 | 94 | // Add data |
95 | 95 | for ($i = 2; $i <= 5000; $i++) { |
96 | - $objPHPExcel->getActiveSheet()->setCellValue('A' . $i, "FName $i") |
|
97 | - ->setCellValue('B' . $i, "LName $i") |
|
98 | - ->setCellValue('C' . $i, "PhoneNo $i") |
|
99 | - ->setCellValue('D' . $i, "FaxNo $i") |
|
100 | - ->setCellValue('E' . $i, true); |
|
96 | + $objPHPExcel->getActiveSheet()->setCellValue('A' . $i, "FName $i") |
|
97 | + ->setCellValue('B' . $i, "LName $i") |
|
98 | + ->setCellValue('C' . $i, "PhoneNo $i") |
|
99 | + ->setCellValue('D' . $i, "FaxNo $i") |
|
100 | + ->setCellValue('E' . $i, true); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 |
@@ -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,15 +41,15 @@ discard block |
||
41 | 41 | if (!\PHPExcel\Settings::setCacheStorageMethod($cacheMethod)) { |
42 | 42 | die($cacheMethod . " caching method is not available" . EOL); |
43 | 43 | } |
44 | -echo date('H:i:s') , " Enable Cell Caching using " , $cacheMethod , " method" , EOL; |
|
44 | +echo date('H:i:s'), " Enable Cell Caching using ", $cacheMethod, " method", EOL; |
|
45 | 45 | |
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 properties" , EOL; |
|
52 | +echo date('H:i:s'), " Set properties", EOL; |
|
53 | 53 | $objPHPExcel->getProperties()->setCreator("Maarten Balliauw") |
54 | 54 | ->setLastModifiedBy("Maarten Balliauw") |
55 | 55 | ->setTitle("Office 2007 XLSX Test Document") |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | |
61 | 61 | |
62 | 62 | // Create a first sheet |
63 | -echo date('H:i:s') , " Add data" , EOL; |
|
63 | +echo date('H:i:s'), " Add data", EOL; |
|
64 | 64 | $objPHPExcel->setActiveSheetIndex(0); |
65 | 65 | $objPHPExcel->getActiveSheet()->setCellValue('A1', "Firstname"); |
66 | 66 | $objPHPExcel->getActiveSheet()->setCellValue('B1', "Lastname"); |
@@ -70,24 +70,24 @@ discard block |
||
70 | 70 | |
71 | 71 | |
72 | 72 | // Hide "Phone" and "fax" column |
73 | -echo date('H:i:s') , " Hide 'Phone' and 'fax' columns" , EOL; |
|
73 | +echo date('H:i:s'), " Hide 'Phone' and 'fax' columns", EOL; |
|
74 | 74 | $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setVisible(false); |
75 | 75 | $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setVisible(false); |
76 | 76 | |
77 | 77 | |
78 | 78 | // Set outline levels |
79 | -echo date('H:i:s') , " Set outline levels" , EOL; |
|
79 | +echo date('H:i:s'), " Set outline levels", EOL; |
|
80 | 80 | $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setOutlineLevel(1) |
81 | 81 | ->setVisible(false) |
82 | 82 | ->setCollapsed(true); |
83 | 83 | |
84 | 84 | // Freeze panes |
85 | -echo date('H:i:s') , " Freeze panes" , EOL; |
|
85 | +echo date('H:i:s'), " Freeze panes", EOL; |
|
86 | 86 | $objPHPExcel->getActiveSheet()->freezePane('A2'); |
87 | 87 | |
88 | 88 | |
89 | 89 | // Rows to repeat at top |
90 | -echo date('H:i:s') , " Rows to repeat at top" , EOL; |
|
90 | +echo date('H:i:s'), " Rows to repeat at top", EOL; |
|
91 | 91 | $objPHPExcel->getActiveSheet()->getPageSetup()->setRowsToRepeatAtTopByStartAndEnd(1, 1); |
92 | 92 | |
93 | 93 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | |
107 | 107 | |
108 | 108 | // Save Excel 2007 file |
109 | -echo date('H:i:s') , " Write to Excel2007 format" , EOL; |
|
109 | +echo date('H:i:s'), " Write to Excel2007 format", EOL; |
|
110 | 110 | $callStartTime = microtime(true); |
111 | 111 | |
112 | 112 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007'); |
@@ -114,15 +114,15 @@ discard block |
||
114 | 114 | $callEndTime = microtime(true); |
115 | 115 | $callTime = $callEndTime - $callStartTime; |
116 | 116 | |
117 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
118 | -echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL; |
|
117 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
118 | +echo 'Call time to write Workbook was ', sprintf('%.4f', $callTime), " seconds", EOL; |
|
119 | 119 | // Echo memory usage |
120 | -echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
120 | +echo date('H:i:s'), ' Current memory usage: ', (memory_get_usage(true) / 1024 / 1024), " MB", EOL; |
|
121 | 121 | |
122 | 122 | |
123 | 123 | // Echo memory peak usage |
124 | -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
124 | +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; |
|
125 | 125 | |
126 | 126 | // Echo done |
127 | -echo date('H:i:s') , " Done writing file" , EOL; |
|
128 | -echo 'File has been created in ' , getcwd() , EOL; |
|
127 | +echo date('H:i:s'), " Done writing file", EOL; |
|
128 | +echo 'File has been created in ', getcwd(), EOL; |
@@ -43,13 +43,13 @@ discard block |
||
43 | 43 | $objPHPExcel = new \PHPExcel\Spreadsheet(); |
44 | 44 | $objWorksheet = $objPHPExcel->getActiveSheet(); |
45 | 45 | $objWorksheet->fromArray( |
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), |
|
52 | - ) |
|
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), |
|
52 | + ) |
|
53 | 53 | ); |
54 | 54 | |
55 | 55 | // Set the Labels for each data series we want to plot |
@@ -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 |
@@ -82,19 +82,19 @@ discard block |
||
82 | 82 | // Data values |
83 | 83 | // Data Marker |
84 | 84 | $dataSeriesValues = array( |
85 | - new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', NULL, 4), |
|
86 | - new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', NULL, 4), |
|
87 | - new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', NULL, 4), |
|
85 | + new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', NULL, 4), |
|
86 | + new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', NULL, 4), |
|
87 | + new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', NULL, 4), |
|
88 | 88 | ); |
89 | 89 | |
90 | 90 | // Build the dataseries |
91 | 91 | $series = new \PHPExcel\Chart\DataSeries( |
92 | - \PHPExcel\Chart\DataSeries::TYPE_AREACHART, // plotType |
|
93 | - \PHPExcel\Chart\DataSeries::GROUPING_PERCENT_STACKED, // plotGrouping |
|
94 | - range(0, count($dataSeriesValues)-1), // plotOrder |
|
95 | - $dataSeriesLabels, // plotLabel |
|
96 | - $xAxisTickValues, // plotCategory |
|
97 | - $dataSeriesValues // plotValues |
|
92 | + \PHPExcel\Chart\DataSeries::TYPE_AREACHART, // plotType |
|
93 | + \PHPExcel\Chart\DataSeries::GROUPING_PERCENT_STACKED, // plotGrouping |
|
94 | + range(0, count($dataSeriesValues)-1), // plotOrder |
|
95 | + $dataSeriesLabels, // plotLabel |
|
96 | + $xAxisTickValues, // plotCategory |
|
97 | + $dataSeriesValues // plotValues |
|
98 | 98 | ); |
99 | 99 | |
100 | 100 | // Set the series in the plot area |
@@ -108,14 +108,14 @@ discard block |
||
108 | 108 | |
109 | 109 | // Create the chart |
110 | 110 | $chart = new \PHPExcel\Chart( |
111 | - 'chart1', // name |
|
112 | - $title, // title |
|
113 | - $legend, // legend |
|
114 | - $plotArea, // plotArea |
|
115 | - true, // plotVisibleOnly |
|
116 | - 0, // displayBlanksAs |
|
117 | - NULL, // xAxisLabel |
|
118 | - $yAxisLabel // yAxisLabel |
|
111 | + 'chart1', // name |
|
112 | + $title, // title |
|
113 | + $legend, // legend |
|
114 | + $plotArea, // plotArea |
|
115 | + true, // plotVisibleOnly |
|
116 | + 0, // displayBlanksAs |
|
117 | + NULL, // xAxisLabel |
|
118 | + $yAxisLabel // yAxisLabel |
|
119 | 119 | ); |
120 | 120 | |
121 | 121 | // Set the position where the chart should appear in the worksheet |
@@ -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_AREACHART, // plotType |
|
93 | - \PHPExcel\Chart\DataSeries::GROUPING_PERCENT_STACKED, // plotGrouping |
|
94 | - range(0, count($dataSeriesValues)-1), // plotOrder |
|
95 | - $dataSeriesLabels, // plotLabel |
|
96 | - $xAxisTickValues, // plotCategory |
|
92 | + \PHPExcel\Chart\DataSeries::TYPE_AREACHART, // plotType |
|
93 | + \PHPExcel\Chart\DataSeries::GROUPING_PERCENT_STACKED, // plotGrouping |
|
94 | + range(0, count($dataSeriesValues) - 1), // plotOrder |
|
95 | + $dataSeriesLabels, // plotLabel |
|
96 | + $xAxisTickValues, // plotCategory |
|
97 | 97 | $dataSeriesValues // plotValues |
98 | 98 | ); |
99 | 99 | |
@@ -108,13 +108,13 @@ discard block |
||
108 | 108 | |
109 | 109 | // Create the chart |
110 | 110 | $chart = new \PHPExcel\Chart( |
111 | - 'chart1', // name |
|
112 | - $title, // title |
|
113 | - $legend, // legend |
|
114 | - $plotArea, // plotArea |
|
115 | - true, // plotVisibleOnly |
|
116 | - 0, // displayBlanksAs |
|
117 | - NULL, // xAxisLabel |
|
111 | + 'chart1', // name |
|
112 | + $title, // title |
|
113 | + $legend, // legend |
|
114 | + $plotArea, // plotArea |
|
115 | + true, // plotVisibleOnly |
|
116 | + 0, // displayBlanksAs |
|
117 | + NULL, // xAxisLabel |
|
118 | 118 | $yAxisLabel // yAxisLabel |
119 | 119 | ); |
120 | 120 | |
@@ -127,16 +127,16 @@ discard block |
||
127 | 127 | |
128 | 128 | |
129 | 129 | // Save Excel 2007 file |
130 | -echo date('H:i:s') , " Write to Excel2007 format" , EOL; |
|
130 | +echo date('H:i:s'), " Write to Excel2007 format", EOL; |
|
131 | 131 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007'); |
132 | 132 | $objWriter->setIncludeCharts(TRUE); |
133 | 133 | $objWriter->save(str_replace('.php', '.xlsx', __FILE__)); |
134 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
134 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
135 | 135 | |
136 | 136 | |
137 | 137 | // Echo memory peak usage |
138 | -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
138 | +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; |
|
139 | 139 | |
140 | 140 | // Echo done |
141 | -echo date('H:i:s') , " Done writing file" , EOL; |
|
142 | -echo 'File has been created in ' , getcwd() , EOL; |
|
141 | +echo date('H:i:s'), " Done writing file", EOL; |
|
142 | +echo 'File has been created in ', getcwd(), EOL; |
@@ -77,23 +77,23 @@ |
||
77 | 77 | // Export to PDF (.pdf) |
78 | 78 | echo date('H:i:s') , " Write to PDF format" , EOL; |
79 | 79 | try { |
80 | - if (!\PHPExcel\Settings::setPdfRenderer( |
|
81 | - $rendererName, |
|
82 | - $rendererLibraryPath |
|
83 | - )) { |
|
84 | - echo ( |
|
85 | - 'NOTICE: Please set the $rendererName and $rendererLibraryPath values' . |
|
86 | - EOL . |
|
87 | - 'at the top of this script as appropriate for your directory structure' . |
|
88 | - EOL |
|
89 | - ); |
|
90 | - } else { |
|
91 | - $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'PDF'); |
|
92 | - $objWriter->save(str_replace('.php', '.pdf', __FILE__)); |
|
93 | - echo date('H:i:s') , " File written to " , str_replace('.php', '.pdf', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
94 | - } |
|
80 | + if (!\PHPExcel\Settings::setPdfRenderer( |
|
81 | + $rendererName, |
|
82 | + $rendererLibraryPath |
|
83 | + )) { |
|
84 | + echo ( |
|
85 | + 'NOTICE: Please set the $rendererName and $rendererLibraryPath values' . |
|
86 | + EOL . |
|
87 | + 'at the top of this script as appropriate for your directory structure' . |
|
88 | + EOL |
|
89 | + ); |
|
90 | + } else { |
|
91 | + $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'PDF'); |
|
92 | + $objWriter->save(str_replace('.php', '.pdf', __FILE__)); |
|
93 | + echo date('H:i:s') , " File written to " , str_replace('.php', '.pdf', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
94 | + } |
|
95 | 95 | } catch (Exception $e) { |
96 | - echo date('H:i:s') , ' EXCEPTION: ', $e->getMessage() , EOL; |
|
96 | + echo date('H:i:s') , ' EXCEPTION: ', $e->getMessage() , EOL; |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | // Remove first two rows with field headers before exporting to CSV |
@@ -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 | |
@@ -50,32 +50,32 @@ discard block |
||
50 | 50 | |
51 | 51 | |
52 | 52 | // Read from Excel2007 (.xlsx) template |
53 | -echo date('H:i:s') , " Load Excel2007 template file" , EOL; |
|
53 | +echo date('H:i:s'), " Load Excel2007 template file", EOL; |
|
54 | 54 | $objReader = \PHPExcel\IOFactory::createReader('Excel2007'); |
55 | 55 | $objPHPExcel = $objReader->load("templates/26template.xlsx"); |
56 | 56 | |
57 | 57 | /** at this point, we could do some manipulations with the template, but we skip this step */ |
58 | 58 | |
59 | 59 | // Export to Excel2007 (.xlsx) |
60 | -echo date('H:i:s') , " Write to Excel5 format" , EOL; |
|
60 | +echo date('H:i:s'), " Write to Excel5 format", EOL; |
|
61 | 61 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007'); |
62 | 62 | $objWriter->save(str_replace('.php', '.xlsx', __FILE__)); |
63 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
63 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
64 | 64 | |
65 | 65 | // Export to Excel5 (.xls) |
66 | -echo date('H:i:s') , " Write to Excel5 format" , EOL; |
|
66 | +echo date('H:i:s'), " Write to Excel5 format", EOL; |
|
67 | 67 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5'); |
68 | 68 | $objWriter->save(str_replace('.php', '.xls', __FILE__)); |
69 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
69 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
70 | 70 | |
71 | 71 | // Export to HTML (.html) |
72 | -echo date('H:i:s') , " Write to HTML format" , EOL; |
|
72 | +echo date('H:i:s'), " Write to HTML format", EOL; |
|
73 | 73 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'HTML'); |
74 | 74 | $objWriter->save(str_replace('.php', '.htm', __FILE__)); |
75 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.htm', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
75 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.htm', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
76 | 76 | |
77 | 77 | // Export to PDF (.pdf) |
78 | -echo date('H:i:s') , " Write to PDF format" , EOL; |
|
78 | +echo date('H:i:s'), " Write to PDF format", EOL; |
|
79 | 79 | try { |
80 | 80 | if (!\PHPExcel\Settings::setPdfRenderer( |
81 | 81 | $rendererName, |
@@ -90,33 +90,33 @@ discard block |
||
90 | 90 | } else { |
91 | 91 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'PDF'); |
92 | 92 | $objWriter->save(str_replace('.php', '.pdf', __FILE__)); |
93 | - echo date('H:i:s') , " File written to " , str_replace('.php', '.pdf', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
93 | + echo date('H:i:s'), " File written to ", str_replace('.php', '.pdf', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
94 | 94 | } |
95 | 95 | } catch (Exception $e) { |
96 | - echo date('H:i:s') , ' EXCEPTION: ', $e->getMessage() , EOL; |
|
96 | + echo date('H:i:s'), ' EXCEPTION: ', $e->getMessage(), EOL; |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | // Remove first two rows with field headers before exporting to CSV |
100 | -echo date('H:i:s') , " Removing first two heading rows for CSV export" , EOL; |
|
100 | +echo date('H:i:s'), " Removing first two heading rows for CSV export", EOL; |
|
101 | 101 | $objWorksheet = $objPHPExcel->getActiveSheet(); |
102 | 102 | $objWorksheet->removeRow(1, 2); |
103 | 103 | |
104 | 104 | // Export to CSV (.csv) |
105 | -echo date('H:i:s') , " Write to CSV format" , EOL; |
|
105 | +echo date('H:i:s'), " Write to CSV format", EOL; |
|
106 | 106 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'CSV'); |
107 | 107 | $objWriter->save(str_replace('.php', '.csv', __FILE__)); |
108 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.csv', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
108 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.csv', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
109 | 109 | |
110 | 110 | // Export to CSV with BOM (.csv) |
111 | -echo date('H:i:s') , " Write to CSV format (with BOM)" , EOL; |
|
111 | +echo date('H:i:s'), " Write to CSV format (with BOM)", EOL; |
|
112 | 112 | $objWriter->setUseBOM(true); |
113 | 113 | $objWriter->save(str_replace('.php', '-bom.csv', __FILE__)); |
114 | -echo date('H:i:s') , " File written to " , str_replace('.php', '-bom.csv', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
114 | +echo date('H:i:s'), " File written to ", str_replace('.php', '-bom.csv', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
115 | 115 | |
116 | 116 | |
117 | 117 | // Echo memory peak usage |
118 | -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
118 | +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; |
|
119 | 119 | |
120 | 120 | // Echo done |
121 | -echo date('H:i:s') , " Done writing files" , EOL; |
|
122 | -echo 'Files have been created in ' , getcwd() , EOL; |
|
121 | +echo date('H:i:s'), " Done writing files", EOL; |
|
122 | +echo 'Files have been created in ', getcwd(), EOL; |
@@ -52,12 +52,12 @@ discard block |
||
52 | 52 | // Set document properties |
53 | 53 | echo date('H:i:s') , " Set properties" , EOL; |
54 | 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"); |
|
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 | 61 | |
62 | 62 | |
63 | 63 | // Create a first sheet |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | // Set outline levels |
80 | 80 | echo date('H:i:s') , " Set outline levels" , EOL; |
81 | 81 | $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setOutlineLevel(1) |
82 | - ->setVisible(false) |
|
83 | - ->setCollapsed(true); |
|
82 | + ->setVisible(false) |
|
83 | + ->setCollapsed(true); |
|
84 | 84 | |
85 | 85 | // Freeze panes |
86 | 86 | echo date('H:i:s') , " Freeze panes" , EOL; |
@@ -94,11 +94,11 @@ discard block |
||
94 | 94 | |
95 | 95 | // Add data |
96 | 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); |
|
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 | 102 | } |
103 | 103 | |
104 | 104 |
@@ -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,18 +39,18 @@ discard block |
||
39 | 39 | |
40 | 40 | $cacheMethod = \PHPExcel\CachedObjectStorageFactory::CACHE_TO_SQLITE; |
41 | 41 | if (\PHPExcel\Settings::setCacheStorageMethod($cacheMethod)) { |
42 | - echo date('H:i:s') , " Enable Cell Caching using " , $cacheMethod , " method" , EOL; |
|
42 | + echo date('H:i:s'), " Enable Cell Caching using ", $cacheMethod, " method", EOL; |
|
43 | 43 | } else { |
44 | - echo date('H:i:s') , " Unable to set Cell Caching using " , $cacheMethod , " method, reverting to memory" , EOL; |
|
44 | + echo date('H:i:s'), " Unable to set Cell Caching using ", $cacheMethod, " method, reverting to memory", EOL; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | |
48 | 48 | // Create new PHPExcel object |
49 | -echo date('H:i:s') , " Create new PHPExcel object" , EOL; |
|
49 | +echo date('H:i:s'), " Create new PHPExcel object", EOL; |
|
50 | 50 | $objPHPExcel = new \PHPExcel\Spreadsheet(); |
51 | 51 | |
52 | 52 | // Set document properties |
53 | -echo date('H:i:s') , " Set properties" , EOL; |
|
53 | +echo date('H:i:s'), " Set properties", EOL; |
|
54 | 54 | $objPHPExcel->getProperties()->setCreator("Maarten Balliauw") |
55 | 55 | ->setLastModifiedBy("Maarten Balliauw") |
56 | 56 | ->setTitle("Office 2007 XLSX Test Document") |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | |
63 | 63 | // Create a first sheet |
64 | -echo date('H:i:s') , " Add data" , EOL; |
|
64 | +echo date('H:i:s'), " Add data", EOL; |
|
65 | 65 | $objPHPExcel->setActiveSheetIndex(0); |
66 | 66 | $objPHPExcel->getActiveSheet()->setCellValue('A1', "Firstname"); |
67 | 67 | $objPHPExcel->getActiveSheet()->setCellValue('B1', "Lastname"); |
@@ -71,24 +71,24 @@ discard block |
||
71 | 71 | |
72 | 72 | |
73 | 73 | // Hide "Phone" and "fax" column |
74 | -echo date('H:i:s') , " Hide 'Phone' and 'fax' columns" , EOL; |
|
74 | +echo date('H:i:s'), " Hide 'Phone' and 'fax' columns", EOL; |
|
75 | 75 | $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setVisible(false); |
76 | 76 | $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setVisible(false); |
77 | 77 | |
78 | 78 | |
79 | 79 | // Set outline levels |
80 | -echo date('H:i:s') , " Set outline levels" , EOL; |
|
80 | +echo date('H:i:s'), " Set outline levels", EOL; |
|
81 | 81 | $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setOutlineLevel(1) |
82 | 82 | ->setVisible(false) |
83 | 83 | ->setCollapsed(true); |
84 | 84 | |
85 | 85 | // Freeze panes |
86 | -echo date('H:i:s') , " Freeze panes" , EOL; |
|
86 | +echo date('H:i:s'), " Freeze panes", EOL; |
|
87 | 87 | $objPHPExcel->getActiveSheet()->freezePane('A2'); |
88 | 88 | |
89 | 89 | |
90 | 90 | // Rows to repeat at top |
91 | -echo date('H:i:s') , " Rows to repeat at top" , EOL; |
|
91 | +echo date('H:i:s'), " Rows to repeat at top", EOL; |
|
92 | 92 | $objPHPExcel->getActiveSheet()->getPageSetup()->setRowsToRepeatAtTopByStartAndEnd(1, 1); |
93 | 93 | |
94 | 94 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | |
108 | 108 | |
109 | 109 | // Save Excel 2007 file |
110 | -echo date('H:i:s') , " Write to Excel2007 format" , EOL; |
|
110 | +echo date('H:i:s'), " Write to Excel2007 format", EOL; |
|
111 | 111 | $callStartTime = microtime(true); |
112 | 112 | |
113 | 113 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007'); |
@@ -115,15 +115,15 @@ discard block |
||
115 | 115 | $callEndTime = microtime(true); |
116 | 116 | $callTime = $callEndTime - $callStartTime; |
117 | 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; |
|
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 | 120 | // Echo memory usage |
121 | -echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
121 | +echo date('H:i:s'), ' Current memory usage: ', (memory_get_usage(true) / 1024 / 1024), " MB", EOL; |
|
122 | 122 | |
123 | 123 | |
124 | 124 | // Echo memory peak usage |
125 | -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
125 | +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; |
|
126 | 126 | |
127 | 127 | // Echo done |
128 | -echo date('H:i:s') , " Done writing file" , EOL; |
|
129 | -echo 'File has been created in ' , getcwd() , EOL; |
|
128 | +echo date('H:i:s'), " Done writing file", EOL; |
|
129 | +echo 'File has been created in ', getcwd(), EOL; |
@@ -43,13 +43,13 @@ discard block |
||
43 | 43 | $objPHPExcel = new \PHPExcel\Spreadsheet(); |
44 | 44 | $objWorksheet = $objPHPExcel->getActiveSheet(); |
45 | 45 | $objWorksheet->fromArray( |
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), |
|
52 | - ) |
|
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), |
|
52 | + ) |
|
53 | 53 | ); |
54 | 54 | |
55 | 55 | // Set the Labels for each data series we want to plot |
@@ -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 |
@@ -82,19 +82,19 @@ discard block |
||
82 | 82 | // Data values |
83 | 83 | // Data Marker |
84 | 84 | $dataSeriesValues = array( |
85 | - new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', NULL, 4), |
|
86 | - new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', NULL, 4), |
|
87 | - new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', NULL, 4), |
|
85 | + new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', NULL, 4), |
|
86 | + new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', NULL, 4), |
|
87 | + new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', NULL, 4), |
|
88 | 88 | ); |
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_CLUSTERED, // plotGrouping |
|
94 | - range(0, count($dataSeriesValues)-1), // plotOrder |
|
95 | - $dataSeriesLabels, // plotLabel |
|
96 | - $xAxisTickValues, // plotCategory |
|
97 | - $dataSeriesValues // plotValues |
|
92 | + \PHPExcel\Chart\DataSeries::TYPE_BARCHART, // plotType |
|
93 | + \PHPExcel\Chart\DataSeries::GROUPING_CLUSTERED, // plotGrouping |
|
94 | + range(0, count($dataSeriesValues)-1), // plotOrder |
|
95 | + $dataSeriesLabels, // plotLabel |
|
96 | + $xAxisTickValues, // plotCategory |
|
97 | + $dataSeriesValues // plotValues |
|
98 | 98 | ); |
99 | 99 | // Set additional dataseries parameters |
100 | 100 | // Make it a horizontal bar rather than a vertical column graph |
@@ -111,14 +111,14 @@ 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 |
|
121 | - $yAxisLabel // yAxisLabel |
|
114 | + 'chart1', // name |
|
115 | + $title, // title |
|
116 | + $legend, // legend |
|
117 | + $plotArea, // plotArea |
|
118 | + true, // plotVisibleOnly |
|
119 | + 0, // displayBlanksAs |
|
120 | + NULL, // xAxisLabel |
|
121 | + $yAxisLabel // yAxisLabel |
|
122 | 122 | ); |
123 | 123 | |
124 | 124 | // Set the position where the chart should appear in the worksheet |
@@ -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_CLUSTERED, // 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_CLUSTERED, // 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; |