@@ -33,30 +33,30 @@ |
||
33 | 33 | <?php |
34 | 34 | /** If the user has submitted the form, then we need to execute a calculation **/ |
35 | 35 | if (isset($_POST['submit'])) { |
36 | - if ($_POST['A'] == 0) { |
|
37 | - echo 'The equation is not quadratic'; |
|
38 | - } else { |
|
39 | - /** So we include PHPExcel to perform the calculations **/ |
|
40 | - include 'PHPExcel/Calculation.php'; |
|
36 | + if ($_POST['A'] == 0) { |
|
37 | + echo 'The equation is not quadratic'; |
|
38 | + } else { |
|
39 | + /** So we include PHPExcel to perform the calculations **/ |
|
40 | + include 'PHPExcel/Calculation.php'; |
|
41 | 41 | |
42 | - /** Calculate and Display the results **/ |
|
43 | - echo '<hr /><b>Roots:</b><br />'; |
|
42 | + /** Calculate and Display the results **/ |
|
43 | + echo '<hr /><b>Roots:</b><br />'; |
|
44 | 44 | |
45 | - $callStartTime = microtime(true); |
|
46 | - $discriminantFormula = '=POWER('.$_POST['B'].',2) - (4 * '.$_POST['A'].' * '.$_POST['C'].')'; |
|
47 | - $discriminant = PHPExcel_Calculation::getInstance()->calculateFormula($discriminantFormula); |
|
45 | + $callStartTime = microtime(true); |
|
46 | + $discriminantFormula = '=POWER('.$_POST['B'].',2) - (4 * '.$_POST['A'].' * '.$_POST['C'].')'; |
|
47 | + $discriminant = PHPExcel_Calculation::getInstance()->calculateFormula($discriminantFormula); |
|
48 | 48 | |
49 | - $r1Formula = '=IMDIV(IMSUM(-'.$_POST['B'].',IMSQRT('.$discriminant.')),2 * '.$_POST['A'].')'; |
|
50 | - $r2Formula = '=IF('.$discriminant.'=0,"Only one root",IMDIV(IMSUB(-'.$_POST['B'].',IMSQRT('.$discriminant.')),2 * '.$_POST['A'].'))'; |
|
49 | + $r1Formula = '=IMDIV(IMSUM(-'.$_POST['B'].',IMSQRT('.$discriminant.')),2 * '.$_POST['A'].')'; |
|
50 | + $r2Formula = '=IF('.$discriminant.'=0,"Only one root",IMDIV(IMSUB(-'.$_POST['B'].',IMSQRT('.$discriminant.')),2 * '.$_POST['A'].'))'; |
|
51 | 51 | |
52 | - echo PHPExcel_Calculation::getInstance()->calculateFormula($r1Formula).'<br />'; |
|
53 | - echo PHPExcel_Calculation::getInstance()->calculateFormula($r2Formula).'<br />'; |
|
54 | - $callEndTime = microtime(true); |
|
55 | - $callTime = $callEndTime - $callStartTime; |
|
52 | + echo PHPExcel_Calculation::getInstance()->calculateFormula($r1Formula).'<br />'; |
|
53 | + echo PHPExcel_Calculation::getInstance()->calculateFormula($r2Formula).'<br />'; |
|
54 | + $callEndTime = microtime(true); |
|
55 | + $callTime = $callEndTime - $callStartTime; |
|
56 | 56 | |
57 | - echo '<hr />Call time for Quadratic Equation Solution was '.sprintf('%.4f',$callTime).' seconds<br /><hr />'; |
|
58 | - echo ' Peak memory usage: '.(memory_get_peak_usage(true) / 1024 / 1024).' MB<br />'; |
|
59 | - } |
|
57 | + echo '<hr />Call time for Quadratic Equation Solution was '.sprintf('%.4f',$callTime).' seconds<br /><hr />'; |
|
58 | + echo ' Peak memory usage: '.(memory_get_peak_usage(true) / 1024 / 1024).' MB<br />'; |
|
59 | + } |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | ?> |
@@ -43,19 +43,19 @@ |
||
43 | 43 | echo '<hr /><b>Roots:</b><br />'; |
44 | 44 | |
45 | 45 | $callStartTime = microtime(true); |
46 | - $discriminantFormula = '=POWER('.$_POST['B'].',2) - (4 * '.$_POST['A'].' * '.$_POST['C'].')'; |
|
46 | + $discriminantFormula = '=POWER(' . $_POST['B'] . ',2) - (4 * ' . $_POST['A'] . ' * ' . $_POST['C'] . ')'; |
|
47 | 47 | $discriminant = PHPExcel_Calculation::getInstance()->calculateFormula($discriminantFormula); |
48 | 48 | |
49 | - $r1Formula = '=IMDIV(IMSUM(-'.$_POST['B'].',IMSQRT('.$discriminant.')),2 * '.$_POST['A'].')'; |
|
50 | - $r2Formula = '=IF('.$discriminant.'=0,"Only one root",IMDIV(IMSUB(-'.$_POST['B'].',IMSQRT('.$discriminant.')),2 * '.$_POST['A'].'))'; |
|
49 | + $r1Formula = '=IMDIV(IMSUM(-' . $_POST['B'] . ',IMSQRT(' . $discriminant . ')),2 * ' . $_POST['A'] . ')'; |
|
50 | + $r2Formula = '=IF(' . $discriminant . '=0,"Only one root",IMDIV(IMSUB(-' . $_POST['B'] . ',IMSQRT(' . $discriminant . ')),2 * ' . $_POST['A'] . '))'; |
|
51 | 51 | |
52 | - echo PHPExcel_Calculation::getInstance()->calculateFormula($r1Formula).'<br />'; |
|
53 | - echo PHPExcel_Calculation::getInstance()->calculateFormula($r2Formula).'<br />'; |
|
52 | + echo PHPExcel_Calculation::getInstance()->calculateFormula($r1Formula) . '<br />'; |
|
53 | + echo PHPExcel_Calculation::getInstance()->calculateFormula($r2Formula) . '<br />'; |
|
54 | 54 | $callEndTime = microtime(true); |
55 | 55 | $callTime = $callEndTime - $callStartTime; |
56 | 56 | |
57 | - echo '<hr />Call time for Quadratic Equation Solution was '.sprintf('%.4f',$callTime).' seconds<br /><hr />'; |
|
58 | - echo ' Peak memory usage: '.(memory_get_peak_usage(true) / 1024 / 1024).' MB<br />'; |
|
57 | + echo '<hr />Call time for Quadratic Equation Solution was ' . sprintf('%.4f', $callTime) . ' seconds<br /><hr />'; |
|
58 | + echo ' Peak memory usage: ' . (memory_get_peak_usage(true) / 1024 / 1024) . ' MB<br />'; |
|
59 | 59 | } |
60 | 60 | } |
61 | 61 |
@@ -43,21 +43,21 @@ discard block |
||
43 | 43 | $objPHPExcel = new \PHPExcel\Spreadsheet(); |
44 | 44 | $objWorksheet = $objPHPExcel->getActiveSheet(); |
45 | 45 | $objWorksheet->fromArray( |
46 | - array( |
|
47 | - array('', 'Rainfall (mm)', 'Temperature (°F)', 'Humidity (%)'), |
|
48 | - array('Jan', 78, 52, 61), |
|
49 | - array('Feb', 64, 54, 62), |
|
50 | - array('Mar', 62, 57, 63), |
|
51 | - array('Apr', 21, 62, 59), |
|
52 | - array('May', 11, 75, 60), |
|
53 | - array('Jun', 1, 75, 57), |
|
54 | - array('Jul', 1, 79, 56), |
|
55 | - array('Aug', 1, 79, 59), |
|
56 | - array('Sep', 10, 75, 60), |
|
57 | - array('Oct', 40, 68, 63), |
|
58 | - array('Nov', 69, 62, 64), |
|
59 | - array('Dec', 89, 57, 66), |
|
60 | - ) |
|
46 | + array( |
|
47 | + array('', 'Rainfall (mm)', 'Temperature (°F)', 'Humidity (%)'), |
|
48 | + array('Jan', 78, 52, 61), |
|
49 | + array('Feb', 64, 54, 62), |
|
50 | + array('Mar', 62, 57, 63), |
|
51 | + array('Apr', 21, 62, 59), |
|
52 | + array('May', 11, 75, 60), |
|
53 | + array('Jun', 1, 75, 57), |
|
54 | + array('Jul', 1, 79, 56), |
|
55 | + array('Aug', 1, 79, 59), |
|
56 | + array('Sep', 10, 75, 60), |
|
57 | + array('Oct', 40, 68, 63), |
|
58 | + array('Nov', 69, 62, 64), |
|
59 | + array('Dec', 89, 57, 66), |
|
60 | + ) |
|
61 | 61 | ); |
62 | 62 | |
63 | 63 | |
@@ -69,13 +69,13 @@ discard block |
||
69 | 69 | // Data values |
70 | 70 | // Data Marker |
71 | 71 | $dataSeriesLabels1 = array( |
72 | - new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // Temperature |
|
72 | + new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // Temperature |
|
73 | 73 | ); |
74 | 74 | $dataSeriesLabels2 = array( |
75 | - new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // Rainfall |
|
75 | + new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // Rainfall |
|
76 | 76 | ); |
77 | 77 | $dataSeriesLabels3 = array( |
78 | - new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // Humidity |
|
78 | + new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // Humidity |
|
79 | 79 | ); |
80 | 80 | |
81 | 81 | // Set the X-Axis Labels |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | // Data values |
87 | 87 | // Data Marker |
88 | 88 | $xAxisTickValues = array( |
89 | - new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$13', NULL, 12), // Jan to Dec |
|
89 | + new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$13', NULL, 12), // Jan to Dec |
|
90 | 90 | ); |
91 | 91 | |
92 | 92 | |
@@ -98,17 +98,17 @@ discard block |
||
98 | 98 | // Data values |
99 | 99 | // Data Marker |
100 | 100 | $dataSeriesValues1 = array( |
101 | - new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$B$2:$B$13', NULL, 12), |
|
101 | + new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$B$2:$B$13', NULL, 12), |
|
102 | 102 | ); |
103 | 103 | |
104 | 104 | // Build the dataseries |
105 | 105 | $series1 = new \PHPExcel\Chart\DataSeries( |
106 | - \PHPExcel\Chart\DataSeries::TYPE_BARCHART, // plotType |
|
107 | - \PHPExcel\Chart\DataSeries::GROUPING_CLUSTERED, // plotGrouping |
|
108 | - range(0, count($dataSeriesValues1)-1), // plotOrder |
|
109 | - $dataSeriesLabels1, // plotLabel |
|
110 | - $xAxisTickValues, // plotCategory |
|
111 | - $dataSeriesValues1 // plotValues |
|
106 | + \PHPExcel\Chart\DataSeries::TYPE_BARCHART, // plotType |
|
107 | + \PHPExcel\Chart\DataSeries::GROUPING_CLUSTERED, // plotGrouping |
|
108 | + range(0, count($dataSeriesValues1)-1), // plotOrder |
|
109 | + $dataSeriesLabels1, // plotLabel |
|
110 | + $xAxisTickValues, // plotCategory |
|
111 | + $dataSeriesValues1 // plotValues |
|
112 | 112 | ); |
113 | 113 | // Set additional dataseries parameters |
114 | 114 | // Make it a vertical column rather than a horizontal bar graph |
@@ -123,17 +123,17 @@ discard block |
||
123 | 123 | // Data values |
124 | 124 | // Data Marker |
125 | 125 | $dataSeriesValues2 = array( |
126 | - new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$13', NULL, 12), |
|
126 | + new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$13', NULL, 12), |
|
127 | 127 | ); |
128 | 128 | |
129 | 129 | // Build the dataseries |
130 | 130 | $series2 = new \PHPExcel\Chart\DataSeries( |
131 | - \PHPExcel\Chart\DataSeries::TYPE_LINECHART, // plotType |
|
132 | - \PHPExcel\Chart\DataSeries::GROUPING_STANDARD, // plotGrouping |
|
133 | - range(0, count($dataSeriesValues2)-1), // plotOrder |
|
134 | - $dataSeriesLabels2, // plotLabel |
|
135 | - NULL, // plotCategory |
|
136 | - $dataSeriesValues2 // plotValues |
|
131 | + \PHPExcel\Chart\DataSeries::TYPE_LINECHART, // plotType |
|
132 | + \PHPExcel\Chart\DataSeries::GROUPING_STANDARD, // plotGrouping |
|
133 | + range(0, count($dataSeriesValues2)-1), // plotOrder |
|
134 | + $dataSeriesLabels2, // plotLabel |
|
135 | + NULL, // plotCategory |
|
136 | + $dataSeriesValues2 // plotValues |
|
137 | 137 | ); |
138 | 138 | |
139 | 139 | |
@@ -145,17 +145,17 @@ discard block |
||
145 | 145 | // Data values |
146 | 146 | // Data Marker |
147 | 147 | $dataSeriesValues3 = array( |
148 | - new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$D$2:$D$13', NULL, 12), |
|
148 | + new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$D$2:$D$13', NULL, 12), |
|
149 | 149 | ); |
150 | 150 | |
151 | 151 | // Build the dataseries |
152 | 152 | $series3 = new \PHPExcel\Chart\DataSeries( |
153 | - \PHPExcel\Chart\DataSeries::TYPE_AREACHART, // plotType |
|
154 | - \PHPExcel\Chart\DataSeries::GROUPING_STANDARD, // plotGrouping |
|
155 | - range(0, count($dataSeriesValues2)-1), // plotOrder |
|
156 | - $dataSeriesLabels3, // plotLabel |
|
157 | - NULL, // plotCategory |
|
158 | - $dataSeriesValues3 // plotValues |
|
153 | + \PHPExcel\Chart\DataSeries::TYPE_AREACHART, // plotType |
|
154 | + \PHPExcel\Chart\DataSeries::GROUPING_STANDARD, // plotGrouping |
|
155 | + range(0, count($dataSeriesValues2)-1), // plotOrder |
|
156 | + $dataSeriesLabels3, // plotLabel |
|
157 | + NULL, // plotCategory |
|
158 | + $dataSeriesValues3 // plotValues |
|
159 | 159 | ); |
160 | 160 | |
161 | 161 | |
@@ -169,14 +169,14 @@ discard block |
||
169 | 169 | |
170 | 170 | // Create the chart |
171 | 171 | $chart = new \PHPExcel\Chart( |
172 | - 'chart1', // name |
|
173 | - $title, // title |
|
174 | - $legend, // legend |
|
175 | - $plotArea, // plotArea |
|
176 | - true, // plotVisibleOnly |
|
177 | - 0, // displayBlanksAs |
|
178 | - NULL, // xAxisLabel |
|
179 | - NULL // yAxisLabel |
|
172 | + 'chart1', // name |
|
173 | + $title, // title |
|
174 | + $legend, // legend |
|
175 | + $plotArea, // plotArea |
|
176 | + true, // plotVisibleOnly |
|
177 | + 0, // displayBlanksAs |
|
178 | + NULL, // xAxisLabel |
|
179 | + NULL // yAxisLabel |
|
180 | 180 | ); |
181 | 181 | |
182 | 182 | // 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,19 +44,19 @@ discard block |
||
44 | 44 | $objWorksheet = $objPHPExcel->getActiveSheet(); |
45 | 45 | $objWorksheet->fromArray( |
46 | 46 | array( |
47 | - array('', 'Rainfall (mm)', 'Temperature (°F)', 'Humidity (%)'), |
|
48 | - array('Jan', 78, 52, 61), |
|
49 | - array('Feb', 64, 54, 62), |
|
50 | - array('Mar', 62, 57, 63), |
|
51 | - array('Apr', 21, 62, 59), |
|
52 | - array('May', 11, 75, 60), |
|
53 | - array('Jun', 1, 75, 57), |
|
54 | - array('Jul', 1, 79, 56), |
|
55 | - array('Aug', 1, 79, 59), |
|
56 | - array('Sep', 10, 75, 60), |
|
57 | - array('Oct', 40, 68, 63), |
|
58 | - array('Nov', 69, 62, 64), |
|
59 | - array('Dec', 89, 57, 66), |
|
47 | + array('', 'Rainfall (mm)', 'Temperature (°F)', 'Humidity (%)'), |
|
48 | + array('Jan', 78, 52, 61), |
|
49 | + array('Feb', 64, 54, 62), |
|
50 | + array('Mar', 62, 57, 63), |
|
51 | + array('Apr', 21, 62, 59), |
|
52 | + array('May', 11, 75, 60), |
|
53 | + array('Jun', 1, 75, 57), |
|
54 | + array('Jul', 1, 79, 56), |
|
55 | + array('Aug', 1, 79, 59), |
|
56 | + array('Sep', 10, 75, 60), |
|
57 | + array('Oct', 40, 68, 63), |
|
58 | + array('Nov', 69, 62, 64), |
|
59 | + array('Dec', 89, 57, 66), |
|
60 | 60 | ) |
61 | 61 | ); |
62 | 62 | |
@@ -69,13 +69,13 @@ discard block |
||
69 | 69 | // Data values |
70 | 70 | // Data Marker |
71 | 71 | $dataSeriesLabels1 = array( |
72 | - new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // Temperature |
|
72 | + new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // Temperature |
|
73 | 73 | ); |
74 | 74 | $dataSeriesLabels2 = array( |
75 | - new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // Rainfall |
|
75 | + new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // Rainfall |
|
76 | 76 | ); |
77 | 77 | $dataSeriesLabels3 = array( |
78 | - new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // Humidity |
|
78 | + new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // Humidity |
|
79 | 79 | ); |
80 | 80 | |
81 | 81 | // Set the X-Axis Labels |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | // Data values |
87 | 87 | // Data Marker |
88 | 88 | $xAxisTickValues = array( |
89 | - new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$13', NULL, 12), // Jan to Dec |
|
89 | + new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$13', NULL, 12), // Jan to Dec |
|
90 | 90 | ); |
91 | 91 | |
92 | 92 | |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | |
104 | 104 | // Build the dataseries |
105 | 105 | $series1 = new \PHPExcel\Chart\DataSeries( |
106 | - \PHPExcel\Chart\DataSeries::TYPE_BARCHART, // plotType |
|
107 | - \PHPExcel\Chart\DataSeries::GROUPING_CLUSTERED, // plotGrouping |
|
108 | - range(0, count($dataSeriesValues1)-1), // plotOrder |
|
109 | - $dataSeriesLabels1, // plotLabel |
|
110 | - $xAxisTickValues, // plotCategory |
|
106 | + \PHPExcel\Chart\DataSeries::TYPE_BARCHART, // plotType |
|
107 | + \PHPExcel\Chart\DataSeries::GROUPING_CLUSTERED, // plotGrouping |
|
108 | + range(0, count($dataSeriesValues1) - 1), // plotOrder |
|
109 | + $dataSeriesLabels1, // plotLabel |
|
110 | + $xAxisTickValues, // plotCategory |
|
111 | 111 | $dataSeriesValues1 // plotValues |
112 | 112 | ); |
113 | 113 | // Set additional dataseries parameters |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | |
129 | 129 | // Build the dataseries |
130 | 130 | $series2 = new \PHPExcel\Chart\DataSeries( |
131 | - \PHPExcel\Chart\DataSeries::TYPE_LINECHART, // plotType |
|
132 | - \PHPExcel\Chart\DataSeries::GROUPING_STANDARD, // plotGrouping |
|
133 | - range(0, count($dataSeriesValues2)-1), // plotOrder |
|
134 | - $dataSeriesLabels2, // plotLabel |
|
135 | - NULL, // plotCategory |
|
131 | + \PHPExcel\Chart\DataSeries::TYPE_LINECHART, // plotType |
|
132 | + \PHPExcel\Chart\DataSeries::GROUPING_STANDARD, // plotGrouping |
|
133 | + range(0, count($dataSeriesValues2) - 1), // plotOrder |
|
134 | + $dataSeriesLabels2, // plotLabel |
|
135 | + NULL, // plotCategory |
|
136 | 136 | $dataSeriesValues2 // plotValues |
137 | 137 | ); |
138 | 138 | |
@@ -150,11 +150,11 @@ discard block |
||
150 | 150 | |
151 | 151 | // Build the dataseries |
152 | 152 | $series3 = new \PHPExcel\Chart\DataSeries( |
153 | - \PHPExcel\Chart\DataSeries::TYPE_AREACHART, // plotType |
|
154 | - \PHPExcel\Chart\DataSeries::GROUPING_STANDARD, // plotGrouping |
|
155 | - range(0, count($dataSeriesValues2)-1), // plotOrder |
|
156 | - $dataSeriesLabels3, // plotLabel |
|
157 | - NULL, // plotCategory |
|
153 | + \PHPExcel\Chart\DataSeries::TYPE_AREACHART, // plotType |
|
154 | + \PHPExcel\Chart\DataSeries::GROUPING_STANDARD, // plotGrouping |
|
155 | + range(0, count($dataSeriesValues2) - 1), // plotOrder |
|
156 | + $dataSeriesLabels3, // plotLabel |
|
157 | + NULL, // plotCategory |
|
158 | 158 | $dataSeriesValues3 // plotValues |
159 | 159 | ); |
160 | 160 | |
@@ -169,13 +169,13 @@ discard block |
||
169 | 169 | |
170 | 170 | // Create the chart |
171 | 171 | $chart = new \PHPExcel\Chart( |
172 | - 'chart1', // name |
|
173 | - $title, // title |
|
174 | - $legend, // legend |
|
175 | - $plotArea, // plotArea |
|
176 | - true, // plotVisibleOnly |
|
177 | - 0, // displayBlanksAs |
|
178 | - NULL, // xAxisLabel |
|
172 | + 'chart1', // name |
|
173 | + $title, // title |
|
174 | + $legend, // legend |
|
175 | + $plotArea, // plotArea |
|
176 | + true, // plotVisibleOnly |
|
177 | + 0, // displayBlanksAs |
|
178 | + NULL, // xAxisLabel |
|
179 | 179 | NULL // yAxisLabel |
180 | 180 | ); |
181 | 181 | |
@@ -188,16 +188,16 @@ discard block |
||
188 | 188 | |
189 | 189 | |
190 | 190 | // Save Excel 2007 file |
191 | -echo date('H:i:s') , " Write to Excel2007 format" , EOL; |
|
191 | +echo date('H:i:s'), " Write to Excel2007 format", EOL; |
|
192 | 192 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007'); |
193 | 193 | $objWriter->setIncludeCharts(TRUE); |
194 | 194 | $objWriter->save(str_replace('.php', '.xlsx', __FILE__)); |
195 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
195 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
196 | 196 | |
197 | 197 | |
198 | 198 | // Echo memory peak usage |
199 | -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
199 | +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; |
|
200 | 200 | |
201 | 201 | // Echo done |
202 | -echo date('H:i:s') , " Done writing file" , EOL; |
|
203 | -echo 'File has been created in ' , getcwd() , EOL; |
|
202 | +echo date('H:i:s'), " Done writing file", EOL; |
|
203 | +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 2007 file |
117 | -echo date('H:i:s') , " Write to Excel2007 format" , EOL; |
|
117 | +echo date('H:i:s'), " Write to Excel2007 format", EOL; |
|
118 | 118 | $callStartTime = microtime(true); |
119 | 119 | |
120 | 120 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007'); |
@@ -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', '.xlsx', 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', '.xlsx', 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 |
@@ -45,37 +45,37 @@ |
||
45 | 45 | // Set document properties |
46 | 46 | echo date('H:i:s') , " Set document properties" , EOL; |
47 | 47 | $objPHPExcel->getProperties()->setCreator("Maarten Balliauw") |
48 | - ->setLastModifiedBy("Maarten Balliauw") |
|
49 | - ->setTitle("Office 2007 XLSX Test Document") |
|
50 | - ->setSubject("Office 2007 XLSX Test Document") |
|
51 | - ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.") |
|
52 | - ->setKeywords("office 2007 openxml php") |
|
53 | - ->setCategory("Test result file"); |
|
48 | + ->setLastModifiedBy("Maarten Balliauw") |
|
49 | + ->setTitle("Office 2007 XLSX Test Document") |
|
50 | + ->setSubject("Office 2007 XLSX Test Document") |
|
51 | + ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.") |
|
52 | + ->setKeywords("office 2007 openxml php") |
|
53 | + ->setCategory("Test result file"); |
|
54 | 54 | |
55 | 55 | |
56 | 56 | // Create a first sheet |
57 | 57 | echo date('H:i:s') , " Add data and page breaks" , EOL; |
58 | 58 | $objPHPExcel->setActiveSheetIndex(0); |
59 | 59 | $objPHPExcel->getActiveSheet()->setCellValue('A1', "Firstname") |
60 | - ->setCellValue('B1', "Lastname") |
|
61 | - ->setCellValue('C1', "Phone") |
|
62 | - ->setCellValue('D1', "Fax") |
|
63 | - ->setCellValue('E1', "Is Client ?"); |
|
60 | + ->setCellValue('B1', "Lastname") |
|
61 | + ->setCellValue('C1', "Phone") |
|
62 | + ->setCellValue('D1', "Fax") |
|
63 | + ->setCellValue('E1', "Is Client ?"); |
|
64 | 64 | |
65 | 65 | |
66 | 66 | // Add data |
67 | 67 | for ($i = 2; $i <= 50; $i++) { |
68 | - $objPHPExcel->getActiveSheet()->setCellValue('A' . $i, "FName $i"); |
|
69 | - $objPHPExcel->getActiveSheet()->setCellValue('B' . $i, "LName $i"); |
|
70 | - $objPHPExcel->getActiveSheet()->setCellValue('C' . $i, "PhoneNo $i"); |
|
71 | - $objPHPExcel->getActiveSheet()->setCellValue('D' . $i, "FaxNo $i"); |
|
72 | - $objPHPExcel->getActiveSheet()->setCellValue('E' . $i, true); |
|
73 | - |
|
74 | - // Add page breaks every 10 rows |
|
75 | - if ($i % 10 == 0) { |
|
76 | - // Add a page break |
|
77 | - $objPHPExcel->getActiveSheet()->setBreak( 'A' . $i, \PHPExcel\Worksheet::BREAK_ROW ); |
|
78 | - } |
|
68 | + $objPHPExcel->getActiveSheet()->setCellValue('A' . $i, "FName $i"); |
|
69 | + $objPHPExcel->getActiveSheet()->setCellValue('B' . $i, "LName $i"); |
|
70 | + $objPHPExcel->getActiveSheet()->setCellValue('C' . $i, "PhoneNo $i"); |
|
71 | + $objPHPExcel->getActiveSheet()->setCellValue('D' . $i, "FaxNo $i"); |
|
72 | + $objPHPExcel->getActiveSheet()->setCellValue('E' . $i, true); |
|
73 | + |
|
74 | + // Add page breaks every 10 rows |
|
75 | + if ($i % 10 == 0) { |
|
76 | + // Add a page break |
|
77 | + $objPHPExcel->getActiveSheet()->setBreak( 'A' . $i, \PHPExcel\Worksheet::BREAK_ROW ); |
|
78 | + } |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | // Set active sheet index to the first sheet, so Excel opens this as the first sheet |
@@ -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("Maarten Balliauw") |
48 | 48 | ->setLastModifiedBy("Maarten Balliauw") |
49 | 49 | ->setTitle("Office 2007 XLSX Test Document") |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | |
56 | 56 | // Create a first sheet |
57 | -echo date('H:i:s') , " Add data and page breaks" , EOL; |
|
57 | +echo date('H:i:s'), " Add data and page breaks", EOL; |
|
58 | 58 | $objPHPExcel->setActiveSheetIndex(0); |
59 | 59 | $objPHPExcel->getActiveSheet()->setCellValue('A1', "Firstname") |
60 | 60 | ->setCellValue('B1', "Lastname") |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | // Add page breaks every 10 rows |
75 | 75 | if ($i % 10 == 0) { |
76 | 76 | // Add a page break |
77 | - $objPHPExcel->getActiveSheet()->setBreak( 'A' . $i, \PHPExcel\Worksheet::BREAK_ROW ); |
|
77 | + $objPHPExcel->getActiveSheet()->setBreak('A' . $i, \PHPExcel\Worksheet::BREAK_ROW); |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | |
98 | 98 | |
99 | 99 | // Save Excel 2007 file |
100 | -echo date('H:i:s') , " Write to Excel2007 format" , EOL; |
|
100 | +echo date('H:i:s'), " Write to Excel2007 format", EOL; |
|
101 | 101 | $callStartTime = microtime(true); |
102 | 102 | |
103 | 103 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007'); |
@@ -105,14 +105,14 @@ discard block |
||
105 | 105 | $callEndTime = microtime(true); |
106 | 106 | $callTime = $callEndTime - $callStartTime; |
107 | 107 | |
108 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
109 | -echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL; |
|
108 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
109 | +echo 'Call time to write Workbook was ', sprintf('%.4f', $callTime), " seconds", EOL; |
|
110 | 110 | // Echo memory usage |
111 | -echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
111 | +echo date('H:i:s'), ' Current memory usage: ', (memory_get_usage(true) / 1024 / 1024), " MB", EOL; |
|
112 | 112 | |
113 | 113 | |
114 | 114 | // Save Excel 95 file |
115 | -echo date('H:i:s') , " Write to Excel5 format" , EOL; |
|
115 | +echo date('H:i:s'), " Write to Excel5 format", EOL; |
|
116 | 116 | $callStartTime = microtime(true); |
117 | 117 | |
118 | 118 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5'); |
@@ -120,15 +120,15 @@ discard block |
||
120 | 120 | $callEndTime = microtime(true); |
121 | 121 | $callTime = $callEndTime - $callStartTime; |
122 | 122 | |
123 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
124 | -echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL; |
|
123 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
124 | +echo 'Call time to write Workbook was ', sprintf('%.4f', $callTime), " seconds", EOL; |
|
125 | 125 | // Echo memory usage |
126 | -echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
126 | +echo date('H:i:s'), ' Current memory usage: ', (memory_get_usage(true) / 1024 / 1024), " MB", EOL; |
|
127 | 127 | |
128 | 128 | |
129 | 129 | // Echo memory peak usage |
130 | -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
130 | +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; |
|
131 | 131 | |
132 | 132 | // Echo done |
133 | -echo date('H:i:s') , " Done writing files" , EOL; |
|
134 | -echo 'Files have been created in ' , getcwd() , EOL; |
|
133 | +echo date('H:i:s'), " Done writing files", EOL; |
|
134 | +echo 'Files have been created in ', getcwd(), EOL; |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />'); |
35 | 35 | |
36 | 36 | /** Include PHPExcel */ |
37 | - require_once dirname(__FILE__) . '/../src/Bootstrap.php'; |
|
37 | + require_once dirname(__FILE__) . '/../src/Bootstrap.php'; |
|
38 | 38 | |
39 | 39 | |
40 | 40 | // Create new PHPExcel object |
@@ -44,70 +44,70 @@ discard block |
||
44 | 44 | // Set document properties |
45 | 45 | echo date('H:i:s') , " Set document properties" , EOL; |
46 | 46 | $objPHPExcel->getProperties()->setCreator("Maarten Balliauw") |
47 | - ->setLastModifiedBy("Maarten Balliauw") |
|
48 | - ->setTitle("Office 2007 XLSX Test Document") |
|
49 | - ->setSubject("Office 2007 XLSX Test Document") |
|
50 | - ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.") |
|
51 | - ->setKeywords("office 2007 openxml php") |
|
52 | - ->setCategory("Test result file"); |
|
47 | + ->setLastModifiedBy("Maarten Balliauw") |
|
48 | + ->setTitle("Office 2007 XLSX Test Document") |
|
49 | + ->setSubject("Office 2007 XLSX Test Document") |
|
50 | + ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.") |
|
51 | + ->setKeywords("office 2007 openxml php") |
|
52 | + ->setCategory("Test result file"); |
|
53 | 53 | |
54 | 54 | // Set default font |
55 | 55 | echo date('H:i:s') , " Set default font" , EOL; |
56 | 56 | $objPHPExcel->getDefaultStyle()->getFont()->setName('Arial') |
57 | - ->setSize(10); |
|
57 | + ->setSize(10); |
|
58 | 58 | |
59 | 59 | // Add some data, resembling some different data types |
60 | 60 | echo date('H:i:s') , " Add some data" , EOL; |
61 | 61 | $objPHPExcel->getActiveSheet()->setCellValue('A1', 'String') |
62 | - ->setCellValue('B1', 'Simple') |
|
63 | - ->setCellValue('C1', 'PHPExcel'); |
|
62 | + ->setCellValue('B1', 'Simple') |
|
63 | + ->setCellValue('C1', 'PHPExcel'); |
|
64 | 64 | |
65 | 65 | $objPHPExcel->getActiveSheet()->setCellValue('A2', 'String') |
66 | - ->setCellValue('B2', 'Symbols') |
|
67 | - ->setCellValue('C2', '!+&=()~§±æþ'); |
|
66 | + ->setCellValue('B2', 'Symbols') |
|
67 | + ->setCellValue('C2', '!+&=()~§±æþ'); |
|
68 | 68 | |
69 | 69 | $objPHPExcel->getActiveSheet()->setCellValue('A3', 'String') |
70 | - ->setCellValue('B3', 'UTF-8') |
|
71 | - ->setCellValue('C3', 'Создать MS Excel Книги из PHP скриптов'); |
|
70 | + ->setCellValue('B3', 'UTF-8') |
|
71 | + ->setCellValue('C3', 'Создать MS Excel Книги из PHP скриптов'); |
|
72 | 72 | |
73 | 73 | $objPHPExcel->getActiveSheet()->setCellValue('A4', 'Number') |
74 | - ->setCellValue('B4', 'Integer') |
|
75 | - ->setCellValue('C4', 12); |
|
74 | + ->setCellValue('B4', 'Integer') |
|
75 | + ->setCellValue('C4', 12); |
|
76 | 76 | |
77 | 77 | $objPHPExcel->getActiveSheet()->setCellValue('A5', 'Number') |
78 | - ->setCellValue('B5', 'Float') |
|
79 | - ->setCellValue('C5', 34.56); |
|
78 | + ->setCellValue('B5', 'Float') |
|
79 | + ->setCellValue('C5', 34.56); |
|
80 | 80 | |
81 | 81 | $objPHPExcel->getActiveSheet()->setCellValue('A6', 'Number') |
82 | - ->setCellValue('B6', 'Negative') |
|
83 | - ->setCellValue('C6', -7.89); |
|
82 | + ->setCellValue('B6', 'Negative') |
|
83 | + ->setCellValue('C6', -7.89); |
|
84 | 84 | |
85 | 85 | $objPHPExcel->getActiveSheet()->setCellValue('A7', 'Boolean') |
86 | - ->setCellValue('B7', 'True') |
|
87 | - ->setCellValue('C7', true); |
|
86 | + ->setCellValue('B7', 'True') |
|
87 | + ->setCellValue('C7', true); |
|
88 | 88 | |
89 | 89 | $objPHPExcel->getActiveSheet()->setCellValue('A8', 'Boolean') |
90 | - ->setCellValue('B8', 'False') |
|
91 | - ->setCellValue('C8', false); |
|
90 | + ->setCellValue('B8', 'False') |
|
91 | + ->setCellValue('C8', false); |
|
92 | 92 | |
93 | 93 | $dateTimeNow = time(); |
94 | 94 | $objPHPExcel->getActiveSheet()->setCellValue('A9', 'Date/Time') |
95 | - ->setCellValue('B9', 'Date') |
|
96 | - ->setCellValue('C9', \PHPExcel\Shared\Date::PHPToExcel( $dateTimeNow )); |
|
95 | + ->setCellValue('B9', 'Date') |
|
96 | + ->setCellValue('C9', \PHPExcel\Shared\Date::PHPToExcel( $dateTimeNow )); |
|
97 | 97 | $objPHPExcel->getActiveSheet()->getStyle('C9')->getNumberFormat()->setFormatCode(\PHPExcel\Style\NumberFormat::FORMAT_DATE_YYYYMMDD2); |
98 | 98 | |
99 | 99 | $objPHPExcel->getActiveSheet()->setCellValue('A10', 'Date/Time') |
100 | - ->setCellValue('B10', 'Time') |
|
101 | - ->setCellValue('C10', \PHPExcel\Shared\Date::PHPToExcel( $dateTimeNow )); |
|
100 | + ->setCellValue('B10', 'Time') |
|
101 | + ->setCellValue('C10', \PHPExcel\Shared\Date::PHPToExcel( $dateTimeNow )); |
|
102 | 102 | $objPHPExcel->getActiveSheet()->getStyle('C10')->getNumberFormat()->setFormatCode(\PHPExcel\Style\NumberFormat::FORMAT_DATE_TIME4); |
103 | 103 | |
104 | 104 | $objPHPExcel->getActiveSheet()->setCellValue('A11', 'Date/Time') |
105 | - ->setCellValue('B11', 'Date and Time') |
|
106 | - ->setCellValue('C11', \PHPExcel\Shared\Date::PHPToExcel( $dateTimeNow )); |
|
105 | + ->setCellValue('B11', 'Date and Time') |
|
106 | + ->setCellValue('C11', \PHPExcel\Shared\Date::PHPToExcel( $dateTimeNow )); |
|
107 | 107 | $objPHPExcel->getActiveSheet()->getStyle('C11')->getNumberFormat()->setFormatCode(\PHPExcel\Style\NumberFormat::FORMAT_DATE_DATETIME); |
108 | 108 | |
109 | 109 | $objPHPExcel->getActiveSheet()->setCellValue('A12', 'NULL') |
110 | - ->setCellValue('C12', NULL); |
|
110 | + ->setCellValue('C12', NULL); |
|
111 | 111 | |
112 | 112 | $objRichText = new \PHPExcel\RichText(); |
113 | 113 | $objRichText->createText('你好 '); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $objRichText->createText(', unless specified otherwise on the invoice.'); |
120 | 120 | |
121 | 121 | $objPHPExcel->getActiveSheet()->setCellValue('A13', 'Rich Text') |
122 | - ->setCellValue('C13', $objRichText); |
|
122 | + ->setCellValue('C13', $objRichText); |
|
123 | 123 | |
124 | 124 | |
125 | 125 | $objRichText2 = new \PHPExcel\RichText(); |
@@ -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("Office 2007 XLSX Test Document") |
@@ -52,12 +52,12 @@ discard block |
||
52 | 52 | ->setCategory("Test result file"); |
53 | 53 | |
54 | 54 | // Set default font |
55 | -echo date('H:i:s') , " Set default font" , EOL; |
|
55 | +echo date('H:i:s'), " Set default font", EOL; |
|
56 | 56 | $objPHPExcel->getDefaultStyle()->getFont()->setName('Arial') |
57 | 57 | ->setSize(10); |
58 | 58 | |
59 | 59 | // Add some data, resembling some different data types |
60 | -echo date('H:i:s') , " Add some data" , EOL; |
|
60 | +echo date('H:i:s'), " Add some data", EOL; |
|
61 | 61 | $objPHPExcel->getActiveSheet()->setCellValue('A1', 'String') |
62 | 62 | ->setCellValue('B1', 'Simple') |
63 | 63 | ->setCellValue('C1', 'PHPExcel'); |
@@ -93,17 +93,17 @@ discard block |
||
93 | 93 | $dateTimeNow = time(); |
94 | 94 | $objPHPExcel->getActiveSheet()->setCellValue('A9', 'Date/Time') |
95 | 95 | ->setCellValue('B9', 'Date') |
96 | - ->setCellValue('C9', \PHPExcel\Shared\Date::PHPToExcel( $dateTimeNow )); |
|
96 | + ->setCellValue('C9', \PHPExcel\Shared\Date::PHPToExcel($dateTimeNow)); |
|
97 | 97 | $objPHPExcel->getActiveSheet()->getStyle('C9')->getNumberFormat()->setFormatCode(\PHPExcel\Style\NumberFormat::FORMAT_DATE_YYYYMMDD2); |
98 | 98 | |
99 | 99 | $objPHPExcel->getActiveSheet()->setCellValue('A10', 'Date/Time') |
100 | 100 | ->setCellValue('B10', 'Time') |
101 | - ->setCellValue('C10', \PHPExcel\Shared\Date::PHPToExcel( $dateTimeNow )); |
|
101 | + ->setCellValue('C10', \PHPExcel\Shared\Date::PHPToExcel($dateTimeNow)); |
|
102 | 102 | $objPHPExcel->getActiveSheet()->getStyle('C10')->getNumberFormat()->setFormatCode(\PHPExcel\Style\NumberFormat::FORMAT_DATE_TIME4); |
103 | 103 | |
104 | 104 | $objPHPExcel->getActiveSheet()->setCellValue('A11', 'Date/Time') |
105 | 105 | ->setCellValue('B11', 'Date and Time') |
106 | - ->setCellValue('C11', \PHPExcel\Shared\Date::PHPToExcel( $dateTimeNow )); |
|
106 | + ->setCellValue('C11', \PHPExcel\Shared\Date::PHPToExcel($dateTimeNow)); |
|
107 | 107 | $objPHPExcel->getActiveSheet()->getStyle('C11')->getNumberFormat()->setFormatCode(\PHPExcel\Style\NumberFormat::FORMAT_DATE_DATETIME); |
108 | 108 | |
109 | 109 | $objPHPExcel->getActiveSheet()->setCellValue('A12', 'NULL') |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | $objRichText2->createText("black text\n"); |
127 | 127 | |
128 | 128 | $objRed = $objRichText2->createTextRun("red text"); |
129 | -$objRed->getFont()->setColor(new \PHPExcel\Style\Color(\PHPExcel\Style\Color::COLOR_RED )); |
|
129 | +$objRed->getFont()->setColor(new \PHPExcel\Style\Color(\PHPExcel\Style\Color::COLOR_RED)); |
|
130 | 130 | |
131 | 131 | $objPHPExcel->getActiveSheet()->getCell("C14")->setValue($objRichText2); |
132 | 132 | $objPHPExcel->getActiveSheet()->getStyle("C14")->getAlignment()->setWrapText(true); |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setAutoSize(true); |
137 | 137 | |
138 | 138 | // Rename worksheet |
139 | -echo date('H:i:s') , " Rename worksheet" , EOL; |
|
139 | +echo date('H:i:s'), " Rename worksheet", EOL; |
|
140 | 140 | $objPHPExcel->getActiveSheet()->setTitle('Datatypes'); |
141 | 141 | |
142 | 142 | |
@@ -145,39 +145,39 @@ discard block |
||
145 | 145 | |
146 | 146 | |
147 | 147 | // Save Excel 95 file |
148 | -echo date('H:i:s') , " Write to Excel5 format" , EOL; |
|
148 | +echo date('H:i:s'), " Write to Excel5 format", EOL; |
|
149 | 149 | $callStartTime = microtime(true); |
150 | 150 | |
151 | 151 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5'); |
152 | 152 | $objWriter->save(str_replace('.php', '.xls', __FILE__)); |
153 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
153 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
154 | 154 | $callEndTime = microtime(true); |
155 | 155 | $callTime = $callEndTime - $callStartTime; |
156 | 156 | |
157 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
158 | -echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL; |
|
157 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
158 | +echo 'Call time to write Workbook was ', sprintf('%.4f', $callTime), " seconds", EOL; |
|
159 | 159 | // Echo memory usage |
160 | -echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
160 | +echo date('H:i:s'), ' Current memory usage: ', (memory_get_usage(true) / 1024 / 1024), " MB", EOL; |
|
161 | 161 | |
162 | 162 | |
163 | -echo date('H:i:s') , " Reload workbook from saved file" , EOL; |
|
163 | +echo date('H:i:s'), " Reload workbook from saved file", EOL; |
|
164 | 164 | $callStartTime = microtime(true); |
165 | 165 | |
166 | 166 | $objPHPExcel = \PHPExcel\IOFactory::load(str_replace('.php', '.xls', __FILE__)); |
167 | 167 | |
168 | 168 | $callEndTime = microtime(true); |
169 | 169 | $callTime = $callEndTime - $callStartTime; |
170 | -echo 'Call time to reload Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL; |
|
170 | +echo 'Call time to reload Workbook was ', sprintf('%.4f', $callTime), " seconds", EOL; |
|
171 | 171 | // Echo memory usage |
172 | -echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
172 | +echo date('H:i:s'), ' Current memory usage: ', (memory_get_usage(true) / 1024 / 1024), " MB", EOL; |
|
173 | 173 | |
174 | 174 | |
175 | 175 | var_dump($objPHPExcel->getActiveSheet()->toArray()); |
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 testing file" , EOL; |
|
183 | -echo 'File has been created in ' , getcwd() , EOL; |
|
182 | +echo date('H:i:s'), " Done testing file", EOL; |
|
183 | +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() |
47 | 47 | ->setCreator("Maarten Balliauw") |
48 | 48 | ->setLastModifiedBy("Maarten Balliauw") |
@@ -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 | ->setCellValue('A1', 'Hello') |
60 | 60 | ->setCellValue('B2', 'world!') |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | |
69 | 69 | |
70 | 70 | $objPHPExcel->getActiveSheet() |
71 | - ->setCellValue('A8',"Hello\nWorld"); |
|
71 | + ->setCellValue('A8', "Hello\nWorld"); |
|
72 | 72 | $objPHPExcel->getActiveSheet() |
73 | 73 | ->getRowDimension(8) |
74 | 74 | ->setRowHeight(-1); |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | |
95 | 95 | |
96 | 96 | // Rename worksheet |
97 | -echo date('H:i:s') , " Rename worksheet" , EOL; |
|
97 | +echo date('H:i:s'), " Rename worksheet", EOL; |
|
98 | 98 | $objPHPExcel->getActiveSheet() |
99 | 99 | ->setTitle('Simple'); |
100 | 100 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | |
105 | 105 | |
106 | 106 | // Save Excel 2007 file |
107 | -echo date('H:i:s') , " Write to Excel2007 format" , EOL; |
|
107 | +echo date('H:i:s'), " Write to Excel2007 format", EOL; |
|
108 | 108 | $callStartTime = microtime(true); |
109 | 109 | |
110 | 110 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007'); |
@@ -112,14 +112,14 @@ discard block |
||
112 | 112 | $callEndTime = microtime(true); |
113 | 113 | $callTime = $callEndTime - $callStartTime; |
114 | 114 | |
115 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
116 | -echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL; |
|
115 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
116 | +echo 'Call time to write Workbook was ', sprintf('%.4f', $callTime), " seconds", EOL; |
|
117 | 117 | // Echo memory usage |
118 | -echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
118 | +echo date('H:i:s'), ' Current memory usage: ', (memory_get_usage(true) / 1024 / 1024), " MB", EOL; |
|
119 | 119 | |
120 | 120 | |
121 | 121 | // Save Excel 95 file |
122 | -echo date('H:i:s') , " Write to Excel5 format" , EOL; |
|
122 | +echo date('H:i:s'), " Write to Excel5 format", EOL; |
|
123 | 123 | $callStartTime = microtime(true); |
124 | 124 | |
125 | 125 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5'); |
@@ -127,15 +127,15 @@ discard block |
||
127 | 127 | $callEndTime = microtime(true); |
128 | 128 | $callTime = $callEndTime - $callStartTime; |
129 | 129 | |
130 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
131 | -echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL; |
|
130 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
131 | +echo 'Call time to write Workbook was ', sprintf('%.4f', $callTime), " seconds", EOL; |
|
132 | 132 | // Echo memory usage |
133 | -echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
133 | +echo date('H:i:s'), ' Current memory usage: ', (memory_get_usage(true) / 1024 / 1024), " MB", EOL; |
|
134 | 134 | |
135 | 135 | |
136 | 136 | // Echo memory peak usage |
137 | -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
137 | +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; |
|
138 | 138 | |
139 | 139 | // Echo done |
140 | -echo date('H:i:s') , " Done writing files" , EOL; |
|
141 | -echo 'Files have been created in ' , getcwd() , EOL; |
|
140 | +echo date('H:i:s'), " Done writing files", EOL; |
|
141 | +echo 'Files have been created in ', getcwd(), EOL; |
@@ -44,12 +44,12 @@ |
||
44 | 44 | // Set document properties |
45 | 45 | echo date('H:i:s') , " Set document properties" , EOL; |
46 | 46 | $objPHPExcel->getProperties()->setCreator("Maarten Balliauw") |
47 | - ->setLastModifiedBy("Maarten Balliauw") |
|
48 | - ->setTitle("PHPExcel Test Document") |
|
49 | - ->setSubject("PHPExcel Test Document") |
|
50 | - ->setDescription("Test document for PHPExcel, generated using PHP classes.") |
|
51 | - ->setKeywords("office PHPExcel php") |
|
52 | - ->setCategory("Test result file"); |
|
47 | + ->setLastModifiedBy("Maarten Balliauw") |
|
48 | + ->setTitle("PHPExcel Test Document") |
|
49 | + ->setSubject("PHPExcel Test Document") |
|
50 | + ->setDescription("Test document for PHPExcel, generated using PHP classes.") |
|
51 | + ->setKeywords("office PHPExcel php") |
|
52 | + ->setCategory("Test result file"); |
|
53 | 53 | |
54 | 54 | |
55 | 55 | // Add some data |
@@ -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_STACKED, // 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_STACKED, // 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_STACKED, // 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_STACKED, // 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; |
@@ -45,37 +45,37 @@ discard block |
||
45 | 45 | // Set document properties |
46 | 46 | echo date('H:i:s') , " Set document properties" , EOL; |
47 | 47 | $objPHPExcel->getProperties()->setCreator("Maarten Balliauw") |
48 | - ->setLastModifiedBy("Maarten Balliauw") |
|
49 | - ->setTitle("Office 2007 XLSX Test Document") |
|
50 | - ->setSubject("Office 2007 XLSX Test Document") |
|
51 | - ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.") |
|
52 | - ->setKeywords("office 2007 openxml php") |
|
53 | - ->setCategory("Test result file"); |
|
48 | + ->setLastModifiedBy("Maarten Balliauw") |
|
49 | + ->setTitle("Office 2007 XLSX Test Document") |
|
50 | + ->setSubject("Office 2007 XLSX Test Document") |
|
51 | + ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.") |
|
52 | + ->setKeywords("office 2007 openxml php") |
|
53 | + ->setCategory("Test result file"); |
|
54 | 54 | |
55 | 55 | |
56 | 56 | // Create a first sheet, representing sales data |
57 | 57 | echo date('H:i:s') , " Add some data" , EOL; |
58 | 58 | $objPHPExcel->setActiveSheetIndex(0); |
59 | 59 | $objPHPExcel->getActiveSheet()->setCellValue('A1', 'Description') |
60 | - ->setCellValue('B1', 'Amount'); |
|
60 | + ->setCellValue('B1', 'Amount'); |
|
61 | 61 | |
62 | 62 | $objPHPExcel->getActiveSheet()->setCellValue('A2', 'Paycheck received') |
63 | - ->setCellValue('B2', 100); |
|
63 | + ->setCellValue('B2', 100); |
|
64 | 64 | |
65 | 65 | $objPHPExcel->getActiveSheet()->setCellValue('A3', 'Cup of coffee bought') |
66 | - ->setCellValue('B3', -1.5); |
|
66 | + ->setCellValue('B3', -1.5); |
|
67 | 67 | |
68 | 68 | $objPHPExcel->getActiveSheet()->setCellValue('A4', 'Cup of coffee bought') |
69 | - ->setCellValue('B4', -1.5); |
|
69 | + ->setCellValue('B4', -1.5); |
|
70 | 70 | |
71 | 71 | $objPHPExcel->getActiveSheet()->setCellValue('A5', 'Cup of tea bought') |
72 | - ->setCellValue('B5', -1.2); |
|
72 | + ->setCellValue('B5', -1.2); |
|
73 | 73 | |
74 | 74 | $objPHPExcel->getActiveSheet()->setCellValue('A6', 'Found some money') |
75 | - ->setCellValue('B6', 8); |
|
75 | + ->setCellValue('B6', 8); |
|
76 | 76 | |
77 | 77 | $objPHPExcel->getActiveSheet()->setCellValue('A7', 'Total:') |
78 | - ->setCellValue('B7', '=SUM(B2:B6)'); |
|
78 | + ->setCellValue('B7', '=SUM(B2:B6)'); |
|
79 | 79 | |
80 | 80 | |
81 | 81 | // Set column widths |
@@ -121,9 +121,9 @@ discard block |
||
121 | 121 | // duplicate the conditional styles across a range of cells |
122 | 122 | echo date('H:i:s') , " Duplicate the conditional formatting across a range of cells" , EOL; |
123 | 123 | $objPHPExcel->getActiveSheet()->duplicateConditionalStyle( |
124 | - $objPHPExcel->getActiveSheet()->getStyle('B2')->getConditionalStyles(), |
|
125 | - 'B3:B7' |
|
126 | - ); |
|
124 | + $objPHPExcel->getActiveSheet()->getStyle('B2')->getConditionalStyles(), |
|
125 | + 'B3:B7' |
|
126 | + ); |
|
127 | 127 | |
128 | 128 | |
129 | 129 | // Set fonts |
@@ -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("Maarten Balliauw") |
48 | 48 | ->setLastModifiedBy("Maarten Balliauw") |
49 | 49 | ->setTitle("Office 2007 XLSX Test Document") |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | |
56 | 56 | // Create a first sheet, representing sales 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', 'Description') |
60 | 60 | ->setCellValue('B1', 'Amount'); |
@@ -79,13 +79,13 @@ discard block |
||
79 | 79 | |
80 | 80 | |
81 | 81 | // Set column widths |
82 | -echo date('H:i:s') , " Set column widths" , EOL; |
|
82 | +echo date('H:i:s'), " Set column widths", EOL; |
|
83 | 83 | $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(30); |
84 | 84 | $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(12); |
85 | 85 | |
86 | 86 | |
87 | 87 | // Add conditional formatting |
88 | -echo date('H:i:s') , " Add conditional formatting" , EOL; |
|
88 | +echo date('H:i:s'), " Add conditional formatting", EOL; |
|
89 | 89 | $objConditional1 = new \PHPExcel\Style\Conditional(); |
90 | 90 | $objConditional1->setConditionType(\PHPExcel\Style\Conditional::CONDITION_CELLIS) |
91 | 91 | ->setOperatorType(\PHPExcel\Style\Conditional::OPERATOR_BETWEEN) |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | |
120 | 120 | |
121 | 121 | // duplicate the conditional styles across a range of cells |
122 | -echo date('H:i:s') , " Duplicate the conditional formatting across a range of cells" , EOL; |
|
122 | +echo date('H:i:s'), " Duplicate the conditional formatting across a range of cells", EOL; |
|
123 | 123 | $objPHPExcel->getActiveSheet()->duplicateConditionalStyle( |
124 | 124 | $objPHPExcel->getActiveSheet()->getStyle('B2')->getConditionalStyles(), |
125 | 125 | 'B3:B7' |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | |
128 | 128 | |
129 | 129 | // Set fonts |
130 | -echo date('H:i:s') , " Set fonts" , EOL; |
|
130 | +echo date('H:i:s'), " Set fonts", EOL; |
|
131 | 131 | $objPHPExcel->getActiveSheet()->getStyle('A1:B1')->getFont()->setBold(true); |
132 | 132 | //$objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setBold(true); |
133 | 133 | $objPHPExcel->getActiveSheet()->getStyle('A7:B7')->getFont()->setBold(true); |
@@ -135,19 +135,19 @@ discard block |
||
135 | 135 | |
136 | 136 | |
137 | 137 | // Set header and footer. When no different headers for odd/even are used, odd header is assumed. |
138 | -echo date('H:i:s') , " Set header/footer" , EOL; |
|
138 | +echo date('H:i:s'), " Set header/footer", EOL; |
|
139 | 139 | $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&L&BPersonal cash register&RPrinted on &D'); |
140 | 140 | $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&L&B' . $objPHPExcel->getProperties()->getTitle() . '&RPage &P of &N'); |
141 | 141 | |
142 | 142 | |
143 | 143 | // Set page orientation and size |
144 | -echo date('H:i:s') , " Set page orientation and size" , EOL; |
|
144 | +echo date('H:i:s'), " Set page orientation and size", EOL; |
|
145 | 145 | $objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(\PHPExcel\Worksheet\PageSetup::ORIENTATION_PORTRAIT); |
146 | 146 | $objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(\PHPExcel\Worksheet\PageSetup::PAPERSIZE_A4); |
147 | 147 | |
148 | 148 | |
149 | 149 | // Rename worksheet |
150 | -echo date('H:i:s') , " Rename worksheet" , EOL; |
|
150 | +echo date('H:i:s'), " Rename worksheet", EOL; |
|
151 | 151 | $objPHPExcel->getActiveSheet()->setTitle('Invoice'); |
152 | 152 | |
153 | 153 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | |
157 | 157 | |
158 | 158 | // Save Excel 2007 file |
159 | -echo date('H:i:s') , " Write to Excel2007 format" , EOL; |
|
159 | +echo date('H:i:s'), " Write to Excel2007 format", EOL; |
|
160 | 160 | $callStartTime = microtime(true); |
161 | 161 | |
162 | 162 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007'); |
@@ -164,10 +164,10 @@ discard block |
||
164 | 164 | $callEndTime = microtime(true); |
165 | 165 | $callTime = $callEndTime - $callStartTime; |
166 | 166 | |
167 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
168 | -echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL; |
|
167 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
168 | +echo 'Call time to write Workbook was ', sprintf('%.4f', $callTime), " seconds", EOL; |
|
169 | 169 | // Save Excel5 file |
170 | -echo date('H:i:s') , " Write to Excel5 format" , EOL; |
|
170 | +echo date('H:i:s'), " Write to Excel5 format", EOL; |
|
171 | 171 | $callStartTime = microtime(true); |
172 | 172 | |
173 | 173 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5'); |
@@ -175,15 +175,15 @@ discard block |
||
175 | 175 | $callEndTime = microtime(true); |
176 | 176 | $callTime = $callEndTime - $callStartTime; |
177 | 177 | |
178 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
179 | -echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL; |
|
178 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
179 | +echo 'Call time to write Workbook was ', sprintf('%.4f', $callTime), " seconds", EOL; |
|
180 | 180 | // Echo memory usage |
181 | -echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
181 | +echo date('H:i:s'), ' Current memory usage: ', (memory_get_usage(true) / 1024 / 1024), " MB", EOL; |
|
182 | 182 | |
183 | 183 | |
184 | 184 | // Echo memory peak usage |
185 | -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
185 | +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; |
|
186 | 186 | |
187 | 187 | // Echo done |
188 | -echo date('H:i:s') , " Done writing file" , EOL; |
|
189 | -echo 'File has been created in ' , getcwd() , EOL; |
|
188 | +echo date('H:i:s'), " Done writing file", EOL; |
|
189 | +echo 'File has been created in ', getcwd(), EOL; |
@@ -44,23 +44,23 @@ discard block |
||
44 | 44 | // Set document properties |
45 | 45 | echo date('H:i:s').' Set document properties'.EOL; |
46 | 46 | $objPHPExcel->getProperties()->setCreator('Maarten Balliauw') |
47 | - ->setLastModifiedBy('Maarten Balliauw') |
|
48 | - ->setTitle('PHPExcel Test Document') |
|
49 | - ->setSubject('PHPExcel Test Document') |
|
50 | - ->setDescription('Test document for PHPExcel, generated using PHP classes.') |
|
51 | - ->setKeywords('office PHPExcel php') |
|
52 | - ->setCategory('Test result file'); |
|
47 | + ->setLastModifiedBy('Maarten Balliauw') |
|
48 | + ->setTitle('PHPExcel Test Document') |
|
49 | + ->setSubject('PHPExcel Test Document') |
|
50 | + ->setDescription('Test document for PHPExcel, generated using PHP classes.') |
|
51 | + ->setKeywords('office PHPExcel php') |
|
52 | + ->setCategory('Test result file'); |
|
53 | 53 | |
54 | 54 | // Create the worksheet |
55 | 55 | echo date('H:i:s').' Add data'.EOL; |
56 | 56 | $objPHPExcel->setActiveSheetIndex(0); |
57 | 57 | $objPHPExcel->getActiveSheet()->setCellValue('A1', 'Financial Year') |
58 | - ->setCellValue('B1', 'Financial Period') |
|
59 | - ->setCellValue('C1', 'Country') |
|
60 | - ->setCellValue('D1', 'Date') |
|
61 | - ->setCellValue('E1', 'Sales Value') |
|
62 | - ->setCellValue('F1', 'Expenditure') |
|
63 | - ; |
|
58 | + ->setCellValue('B1', 'Financial Period') |
|
59 | + ->setCellValue('C1', 'Country') |
|
60 | + ->setCellValue('D1', 'Date') |
|
61 | + ->setCellValue('E1', 'Sales Value') |
|
62 | + ->setCellValue('F1', 'Expenditure') |
|
63 | + ; |
|
64 | 64 | $startYear = $endYear = $currentYear = date('Y'); |
65 | 65 | $startYear--; |
66 | 66 | $endYear++; |
@@ -68,44 +68,44 @@ discard block |
||
68 | 68 | $years = range($startYear,$endYear); |
69 | 69 | $periods = range(1,12); |
70 | 70 | $countries = array( 'United States', 'UK', 'France', 'Germany', |
71 | - 'Italy', 'Spain', 'Portugal', 'Japan' |
|
72 | - ); |
|
71 | + 'Italy', 'Spain', 'Portugal', 'Japan' |
|
72 | + ); |
|
73 | 73 | |
74 | 74 | $row = 2; |
75 | 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 | - $eDate = \PHPExcel\Shared\Date::formattedPHPToExcel( |
|
81 | - $year, |
|
82 | - $period, |
|
83 | - $i |
|
84 | - ); |
|
85 | - $value = rand(500,1000) * (1 + rand(-0.25,+0.25)); |
|
86 | - $salesValue = $invoiceValue = NULL; |
|
87 | - $incomeOrExpenditure = rand(-1,1); |
|
88 | - if ($incomeOrExpenditure == -1) { |
|
89 | - $expenditure = rand(-500,-1000) * (1 + rand(-0.25,+0.25)); |
|
90 | - $income = NULL; |
|
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));; |
|
94 | - } else { |
|
95 | - $expenditure = NULL; |
|
96 | - $income = rand(500,1000) * (1 + rand(-0.25,+0.25));; |
|
97 | - } |
|
98 | - $dataArray = array( $year, |
|
99 | - $period, |
|
100 | - $country, |
|
101 | - $eDate, |
|
102 | - $income, |
|
103 | - $expenditure, |
|
104 | - ); |
|
105 | - $objPHPExcel->getActiveSheet()->fromArray($dataArray, NULL, 'A'.$row++); |
|
106 | - } |
|
107 | - } |
|
108 | - } |
|
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 | + $eDate = \PHPExcel\Shared\Date::formattedPHPToExcel( |
|
81 | + $year, |
|
82 | + $period, |
|
83 | + $i |
|
84 | + ); |
|
85 | + $value = rand(500,1000) * (1 + rand(-0.25,+0.25)); |
|
86 | + $salesValue = $invoiceValue = NULL; |
|
87 | + $incomeOrExpenditure = rand(-1,1); |
|
88 | + if ($incomeOrExpenditure == -1) { |
|
89 | + $expenditure = rand(-500,-1000) * (1 + rand(-0.25,+0.25)); |
|
90 | + $income = NULL; |
|
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));; |
|
94 | + } else { |
|
95 | + $expenditure = NULL; |
|
96 | + $income = rand(500,1000) * (1 + rand(-0.25,+0.25));; |
|
97 | + } |
|
98 | + $dataArray = array( $year, |
|
99 | + $period, |
|
100 | + $country, |
|
101 | + $eDate, |
|
102 | + $income, |
|
103 | + $expenditure, |
|
104 | + ); |
|
105 | + $objPHPExcel->getActiveSheet()->fromArray($dataArray, NULL, 'A'.$row++); |
|
106 | + } |
|
107 | + } |
|
108 | + } |
|
109 | 109 | } |
110 | 110 | $row--; |
111 | 111 | |
@@ -138,45 +138,45 @@ discard block |
||
138 | 138 | $autoFilter->getColumn('C') |
139 | 139 | ->setFilterType(\PHPExcel\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER) |
140 | 140 | ->createRule() |
141 | - ->setRule( |
|
142 | - \PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL, |
|
143 | - 'u*' |
|
144 | - ) |
|
145 | - ->setRuleType(\PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER); |
|
141 | + ->setRule( |
|
142 | + \PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL, |
|
143 | + 'u*' |
|
144 | + ) |
|
145 | + ->setRuleType(\PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER); |
|
146 | 146 | $autoFilter->getColumn('C') |
147 | 147 | ->createRule() |
148 | - ->setRule( |
|
149 | - \PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL, |
|
150 | - 'japan' |
|
151 | - ) |
|
152 | - ->setRuleType(\PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER); |
|
148 | + ->setRule( |
|
149 | + \PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL, |
|
150 | + 'japan' |
|
151 | + ) |
|
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 | 155 | foreach($periods as $period) { |
156 | - $endDate = date('t',mktime(0,0,0,$period,1,$currentYear)); |
|
157 | - |
|
158 | - $autoFilter->getColumn('D') |
|
159 | - ->setFilterType(\PHPExcel\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_FILTER) |
|
160 | - ->createRule() |
|
161 | - ->setRule( |
|
162 | - \PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL, |
|
163 | - array( |
|
164 | - 'year' => $currentYear, |
|
165 | - 'month' => $period, |
|
166 | - 'day' => $endDate |
|
167 | - ) |
|
168 | - ) |
|
169 | - ->setRuleType(\PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP); |
|
156 | + $endDate = date('t',mktime(0,0,0,$period,1,$currentYear)); |
|
157 | + |
|
158 | + $autoFilter->getColumn('D') |
|
159 | + ->setFilterType(\PHPExcel\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_FILTER) |
|
160 | + ->createRule() |
|
161 | + ->setRule( |
|
162 | + \PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL, |
|
163 | + array( |
|
164 | + 'year' => $currentYear, |
|
165 | + 'month' => $period, |
|
166 | + 'day' => $endDate |
|
167 | + ) |
|
168 | + ) |
|
169 | + ->setRuleType(\PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP); |
|
170 | 170 | } |
171 | 171 | // Display only sales values that are blank |
172 | 172 | // Standard filter, operator equals, and value of NULL |
173 | 173 | $autoFilter->getColumn('E') |
174 | 174 | ->setFilterType(\PHPExcel\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_FILTER) |
175 | 175 | ->createRule() |
176 | - ->setRule( |
|
177 | - \PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL, |
|
178 | - '' |
|
179 | - ); |
|
176 | + ->setRule( |
|
177 | + \PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL, |
|
178 | + '' |
|
179 | + ); |
|
180 | 180 | |
181 | 181 | // Execute filtering |
182 | 182 | echo date('H:i:s').' Execute filtering'.EOL; |
@@ -189,10 +189,10 @@ discard block |
||
189 | 189 | // Display Results of filtering |
190 | 190 | echo date('H:i:s').' Display filtered rows'.EOL; |
191 | 191 | foreach ($objPHPExcel->getActiveSheet()->getRowIterator() as $row) { |
192 | - if ($objPHPExcel->getActiveSheet()->getRowDimension($row->getRowIndex())->getVisible()) { |
|
193 | - echo ' Row number - ' , $row->getRowIndex() , ' '; |
|
194 | - echo $objPHPExcel->getActiveSheet()->getCell('C'.$row->getRowIndex())->getValue(), ' '; |
|
195 | - echo $objPHPExcel->getActiveSheet()->getCell('D'.$row->getRowIndex())->getFormattedValue(), ' '; |
|
196 | - echo EOL; |
|
197 | - } |
|
192 | + if ($objPHPExcel->getActiveSheet()->getRowDimension($row->getRowIndex())->getVisible()) { |
|
193 | + echo ' Row number - ' , $row->getRowIndex() , ' '; |
|
194 | + echo $objPHPExcel->getActiveSheet()->getCell('C'.$row->getRowIndex())->getValue(), ' '; |
|
195 | + echo $objPHPExcel->getActiveSheet()->getCell('D'.$row->getRowIndex())->getFormattedValue(), ' '; |
|
196 | + echo EOL; |
|
197 | + } |
|
198 | 198 | } |
@@ -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) |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | ); |
180 | 180 | |
181 | 181 | // Execute filtering |
182 | -echo date('H:i:s').' Execute filtering'.EOL; |
|
182 | +echo date('H:i:s') . ' Execute filtering' . EOL; |
|
183 | 183 | $autoFilter->showHideRows(); |
184 | 184 | |
185 | 185 | // Set active sheet index to the first sheet, so Excel opens this as the first sheet |
@@ -187,12 +187,12 @@ discard block |
||
187 | 187 | |
188 | 188 | |
189 | 189 | // Display Results of filtering |
190 | -echo date('H:i:s').' Display filtered rows'.EOL; |
|
190 | +echo date('H:i:s') . ' Display filtered rows' . EOL; |
|
191 | 191 | foreach ($objPHPExcel->getActiveSheet()->getRowIterator() as $row) { |
192 | 192 | if ($objPHPExcel->getActiveSheet()->getRowDimension($row->getRowIndex())->getVisible()) { |
193 | - echo ' Row number - ' , $row->getRowIndex() , ' '; |
|
194 | - echo $objPHPExcel->getActiveSheet()->getCell('C'.$row->getRowIndex())->getValue(), ' '; |
|
195 | - echo $objPHPExcel->getActiveSheet()->getCell('D'.$row->getRowIndex())->getFormattedValue(), ' '; |
|
193 | + echo ' Row number - ', $row->getRowIndex(), ' '; |
|
194 | + echo $objPHPExcel->getActiveSheet()->getCell('C' . $row->getRowIndex())->getValue(), ' '; |
|
195 | + echo $objPHPExcel->getActiveSheet()->getCell('D' . $row->getRowIndex())->getFormattedValue(), ' '; |
|
196 | 196 | echo EOL; |
197 | 197 | } |
198 | 198 | } |