@@ -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 |
@@ -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 |
@@ -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(); |
@@ -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 |
@@ -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 |
@@ -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 | } |
@@ -48,31 +48,31 @@ |
||
48 | 48 | |
49 | 49 | echo date('H:i:s') , " Add new data to the template" , EOL; |
50 | 50 | $data = array(array('title' => 'Excel for dummies', |
51 | - 'price' => 17.99, |
|
52 | - 'quantity' => 2 |
|
53 | - ), |
|
54 | - array('title' => 'PHP for dummies', |
|
55 | - 'price' => 15.99, |
|
56 | - 'quantity' => 1 |
|
57 | - ), |
|
58 | - array('title' => 'Inside OOP', |
|
59 | - 'price' => 12.95, |
|
60 | - 'quantity' => 1 |
|
61 | - ) |
|
62 | - ); |
|
51 | + 'price' => 17.99, |
|
52 | + 'quantity' => 2 |
|
53 | + ), |
|
54 | + array('title' => 'PHP for dummies', |
|
55 | + 'price' => 15.99, |
|
56 | + 'quantity' => 1 |
|
57 | + ), |
|
58 | + array('title' => 'Inside OOP', |
|
59 | + 'price' => 12.95, |
|
60 | + 'quantity' => 1 |
|
61 | + ) |
|
62 | + ); |
|
63 | 63 | |
64 | 64 | $objPHPExcel->getActiveSheet()->setCellValue('D1', \PHPExcel\Shared\Date::PHPToExcel(time())); |
65 | 65 | |
66 | 66 | $baseRow = 5; |
67 | 67 | foreach($data as $r => $dataRow) { |
68 | - $row = $baseRow + $r; |
|
69 | - $objPHPExcel->getActiveSheet()->insertNewRowBefore($row,1); |
|
70 | - |
|
71 | - $objPHPExcel->getActiveSheet()->setCellValue('A'.$row, $r+1) |
|
72 | - ->setCellValue('B'.$row, $dataRow['title']) |
|
73 | - ->setCellValue('C'.$row, $dataRow['price']) |
|
74 | - ->setCellValue('D'.$row, $dataRow['quantity']) |
|
75 | - ->setCellValue('E'.$row, '=C'.$row.'*D'.$row); |
|
68 | + $row = $baseRow + $r; |
|
69 | + $objPHPExcel->getActiveSheet()->insertNewRowBefore($row,1); |
|
70 | + |
|
71 | + $objPHPExcel->getActiveSheet()->setCellValue('A'.$row, $r+1) |
|
72 | + ->setCellValue('B'.$row, $dataRow['title']) |
|
73 | + ->setCellValue('C'.$row, $dataRow['price']) |
|
74 | + ->setCellValue('D'.$row, $dataRow['quantity']) |
|
75 | + ->setCellValue('E'.$row, '=C'.$row.'*D'.$row); |
|
76 | 76 | } |
77 | 77 | $objPHPExcel->getActiveSheet()->removeRow($baseRow-1,1); |
78 | 78 |
@@ -17,81 +17,81 @@ |
||
17 | 17 | $inputFileNames = 'templates/32readwrite*[0-9].xlsx'; |
18 | 18 | |
19 | 19 | if ((isset($argc)) && ($argc > 1)) { |
20 | - $inputFileNames = array(); |
|
21 | - for($i = 1; $i < $argc; ++$i) { |
|
22 | - $inputFileNames[] = dirname(__FILE__) . '/templates/' . $argv[$i]; |
|
23 | - } |
|
20 | + $inputFileNames = array(); |
|
21 | + for($i = 1; $i < $argc; ++$i) { |
|
22 | + $inputFileNames[] = dirname(__FILE__) . '/templates/' . $argv[$i]; |
|
23 | + } |
|
24 | 24 | } else { |
25 | - $inputFileNames = glob($inputFileNames); |
|
25 | + $inputFileNames = glob($inputFileNames); |
|
26 | 26 | } |
27 | 27 | foreach($inputFileNames as $inputFileName) { |
28 | - $inputFileNameShort = basename($inputFileName); |
|
29 | - |
|
30 | - if (!file_exists($inputFileName)) { |
|
31 | - echo date('H:i:s') , " File " , $inputFileNameShort , ' does not exist' , EOL; |
|
32 | - continue; |
|
33 | - } |
|
34 | - |
|
35 | - echo date('H:i:s') , " Load Test from $inputFileType file " , $inputFileNameShort , EOL; |
|
36 | - |
|
37 | - $objReader = \PHPExcel\IOFactory::createReader($inputFileType); |
|
38 | - $objReader->setIncludeCharts(TRUE); |
|
39 | - $objPHPExcel = $objReader->load($inputFileName); |
|
40 | - |
|
41 | - |
|
42 | - echo date('H:i:s') , " Iterate worksheets looking at the charts" , EOL; |
|
43 | - foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) { |
|
44 | - $sheetName = $worksheet->getTitle(); |
|
45 | - echo 'Worksheet: ' , $sheetName , EOL; |
|
46 | - |
|
47 | - $chartNames = $worksheet->getChartNames(); |
|
48 | - if(empty($chartNames)) { |
|
49 | - echo ' There are no charts in this worksheet' , EOL; |
|
50 | - } else { |
|
51 | - natsort($chartNames); |
|
52 | - foreach($chartNames as $i => $chartName) { |
|
53 | - $chart = $worksheet->getChartByName($chartName); |
|
54 | - if (!is_null($chart->getTitle())) { |
|
55 | - $caption = '"' . implode(' ',$chart->getTitle()->getCaption()) . '"'; |
|
56 | - } else { |
|
57 | - $caption = 'Untitled'; |
|
58 | - } |
|
59 | - echo ' ' , $chartName , ' - ' , $caption , EOL; |
|
60 | - echo str_repeat(' ',strlen($chartName)+3); |
|
61 | - $groupCount = $chart->getPlotArea()->getPlotGroupCount(); |
|
62 | - if ($groupCount == 1) { |
|
63 | - $chartType = $chart->getPlotArea()->getPlotGroupByIndex(0)->getPlotType(); |
|
64 | - echo ' ' , $chartType , EOL; |
|
65 | - } else { |
|
66 | - $chartTypes = array(); |
|
67 | - for($i = 0; $i < $groupCount; ++$i) { |
|
68 | - $chartTypes[] = $chart->getPlotArea()->getPlotGroupByIndex($i)->getPlotType(); |
|
69 | - } |
|
70 | - $chartTypes = array_unique($chartTypes); |
|
71 | - if (count($chartTypes) == 1) { |
|
72 | - $chartType = 'Multiple Plot ' . array_pop($chartTypes); |
|
73 | - echo ' ' , $chartType , EOL; |
|
74 | - } elseif (count($chartTypes) == 0) { |
|
75 | - echo ' *** Type not yet implemented' , EOL; |
|
76 | - } else { |
|
77 | - echo ' Combination Chart' , EOL; |
|
78 | - } |
|
79 | - } |
|
80 | - } |
|
81 | - } |
|
82 | - } |
|
83 | - |
|
84 | - |
|
85 | - $outputFileName = basename($inputFileName); |
|
86 | - |
|
87 | - echo date('H:i:s') , " Write Tests to Excel2007 file " , EOL; |
|
88 | - $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007'); |
|
89 | - $objWriter->setIncludeCharts(TRUE); |
|
90 | - $objWriter->save($outputFileName); |
|
91 | - echo date('H:i:s') , " File written to " , $outputFileName , EOL; |
|
92 | - |
|
93 | - $objPHPExcel->disconnectWorksheets(); |
|
94 | - unset($objPHPExcel); |
|
28 | + $inputFileNameShort = basename($inputFileName); |
|
29 | + |
|
30 | + if (!file_exists($inputFileName)) { |
|
31 | + echo date('H:i:s') , " File " , $inputFileNameShort , ' does not exist' , EOL; |
|
32 | + continue; |
|
33 | + } |
|
34 | + |
|
35 | + echo date('H:i:s') , " Load Test from $inputFileType file " , $inputFileNameShort , EOL; |
|
36 | + |
|
37 | + $objReader = \PHPExcel\IOFactory::createReader($inputFileType); |
|
38 | + $objReader->setIncludeCharts(TRUE); |
|
39 | + $objPHPExcel = $objReader->load($inputFileName); |
|
40 | + |
|
41 | + |
|
42 | + echo date('H:i:s') , " Iterate worksheets looking at the charts" , EOL; |
|
43 | + foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) { |
|
44 | + $sheetName = $worksheet->getTitle(); |
|
45 | + echo 'Worksheet: ' , $sheetName , EOL; |
|
46 | + |
|
47 | + $chartNames = $worksheet->getChartNames(); |
|
48 | + if(empty($chartNames)) { |
|
49 | + echo ' There are no charts in this worksheet' , EOL; |
|
50 | + } else { |
|
51 | + natsort($chartNames); |
|
52 | + foreach($chartNames as $i => $chartName) { |
|
53 | + $chart = $worksheet->getChartByName($chartName); |
|
54 | + if (!is_null($chart->getTitle())) { |
|
55 | + $caption = '"' . implode(' ',$chart->getTitle()->getCaption()) . '"'; |
|
56 | + } else { |
|
57 | + $caption = 'Untitled'; |
|
58 | + } |
|
59 | + echo ' ' , $chartName , ' - ' , $caption , EOL; |
|
60 | + echo str_repeat(' ',strlen($chartName)+3); |
|
61 | + $groupCount = $chart->getPlotArea()->getPlotGroupCount(); |
|
62 | + if ($groupCount == 1) { |
|
63 | + $chartType = $chart->getPlotArea()->getPlotGroupByIndex(0)->getPlotType(); |
|
64 | + echo ' ' , $chartType , EOL; |
|
65 | + } else { |
|
66 | + $chartTypes = array(); |
|
67 | + for($i = 0; $i < $groupCount; ++$i) { |
|
68 | + $chartTypes[] = $chart->getPlotArea()->getPlotGroupByIndex($i)->getPlotType(); |
|
69 | + } |
|
70 | + $chartTypes = array_unique($chartTypes); |
|
71 | + if (count($chartTypes) == 1) { |
|
72 | + $chartType = 'Multiple Plot ' . array_pop($chartTypes); |
|
73 | + echo ' ' , $chartType , EOL; |
|
74 | + } elseif (count($chartTypes) == 0) { |
|
75 | + echo ' *** Type not yet implemented' , EOL; |
|
76 | + } else { |
|
77 | + echo ' Combination Chart' , EOL; |
|
78 | + } |
|
79 | + } |
|
80 | + } |
|
81 | + } |
|
82 | + } |
|
83 | + |
|
84 | + |
|
85 | + $outputFileName = basename($inputFileName); |
|
86 | + |
|
87 | + echo date('H:i:s') , " Write Tests to Excel2007 file " , EOL; |
|
88 | + $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007'); |
|
89 | + $objWriter->setIncludeCharts(TRUE); |
|
90 | + $objWriter->save($outputFileName); |
|
91 | + echo date('H:i:s') , " File written to " , $outputFileName , EOL; |
|
92 | + |
|
93 | + $objPHPExcel->disconnectWorksheets(); |
|
94 | + unset($objPHPExcel); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | // Echo memory peak usage |
@@ -45,9 +45,9 @@ |
||
45 | 45 | $callStartTime = microtime(true); |
46 | 46 | |
47 | 47 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'CSV')->setDelimiter(',') |
48 | - ->setEnclosure('"') |
|
49 | - ->setSheetIndex(0) |
|
50 | - ->save(str_replace('.php', '.csv', __FILE__)); |
|
48 | + ->setEnclosure('"') |
|
49 | + ->setSheetIndex(0) |
|
50 | + ->save(str_replace('.php', '.csv', __FILE__)); |
|
51 | 51 | $callEndTime = microtime(true); |
52 | 52 | $callTime = $callEndTime - $callStartTime; |
53 | 53 | echo date('H:i:s') , " File written to " , str_replace('.php', '.csv', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |