@@ -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 |
@@ -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; |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | |
58 | 58 | echo date('H:i:s') , " Adjust properties" , EOL; |
59 | 59 | $objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document") |
60 | - ->setSubject("Office 2007 XLSX Test Document") |
|
61 | - ->setDescription("Test XLSX document, generated using PHPExcel") |
|
62 | - ->setKeywords("office 2007 openxml php"); |
|
60 | + ->setSubject("Office 2007 XLSX Test Document") |
|
61 | + ->setDescription("Test XLSX document, generated using PHPExcel") |
|
62 | + ->setKeywords("office 2007 openxml php"); |
|
63 | 63 | |
64 | 64 | |
65 | 65 | // Save Excel 2007 file |
@@ -84,10 +84,10 @@ discard block |
||
84 | 84 | echo 'Core Properties:' , EOL; |
85 | 85 | echo ' Created by - ' , $objPHPExcel->getProperties()->getCreator() , EOL; |
86 | 86 | echo ' Created on - ' , date('d-M-Y',$objPHPExcel->getProperties()->getCreated()) , ' at ' , |
87 | - date('H:i:s',$objPHPExcel->getProperties()->getCreated()) , EOL; |
|
87 | + date('H:i:s',$objPHPExcel->getProperties()->getCreated()) , EOL; |
|
88 | 88 | echo ' Last Modified by - ' , $objPHPExcel->getProperties()->getLastModifiedBy() , EOL; |
89 | 89 | echo ' Last Modified on - ' , date('d-M-Y',$objPHPExcel->getProperties()->getModified()) , ' at ' , |
90 | - date('H:i:s',$objPHPExcel->getProperties()->getModified()) , EOL; |
|
90 | + date('H:i:s',$objPHPExcel->getProperties()->getModified()) , EOL; |
|
91 | 91 | echo ' Title - ' , $objPHPExcel->getProperties()->getTitle() , EOL; |
92 | 92 | echo ' Subject - ' , $objPHPExcel->getProperties()->getSubject() , EOL; |
93 | 93 | echo ' Description - ' , $objPHPExcel->getProperties()->getDescription() , EOL; |
@@ -103,16 +103,16 @@ discard block |
||
103 | 103 | echo 'Custom Properties:' , EOL; |
104 | 104 | $customProperties = $objPHPExcel->getProperties()->getCustomProperties(); |
105 | 105 | foreach($customProperties as $customProperty) { |
106 | - $propertyValue = $objPHPExcel->getProperties()->getCustomPropertyValue($customProperty); |
|
107 | - $propertyType = $objPHPExcel->getProperties()->getCustomPropertyType($customProperty); |
|
108 | - echo ' ' , $customProperty , ' - (' , $propertyType , ') - '; |
|
109 | - if ($propertyType == \PHPExcel\Document\Properties::PROPERTY_TYPE_DATE) { |
|
110 | - echo date('d-M-Y H:i:s',$propertyValue) , EOL; |
|
111 | - } elseif ($propertyType == \PHPExcel\Document\Properties::PROPERTY_TYPE_BOOLEAN) { |
|
112 | - echo (($propertyValue) ? 'TRUE' : 'FALSE') , EOL; |
|
113 | - } else { |
|
114 | - echo $propertyValue , EOL; |
|
115 | - } |
|
106 | + $propertyValue = $objPHPExcel->getProperties()->getCustomPropertyValue($customProperty); |
|
107 | + $propertyType = $objPHPExcel->getProperties()->getCustomPropertyType($customProperty); |
|
108 | + echo ' ' , $customProperty , ' - (' , $propertyType , ') - '; |
|
109 | + if ($propertyType == \PHPExcel\Document\Properties::PROPERTY_TYPE_DATE) { |
|
110 | + echo date('d-M-Y H:i:s',$propertyValue) , EOL; |
|
111 | + } elseif ($propertyType == \PHPExcel\Document\Properties::PROPERTY_TYPE_BOOLEAN) { |
|
112 | + echo (($propertyValue) ? 'TRUE' : 'FALSE') , EOL; |
|
113 | + } else { |
|
114 | + echo $propertyValue , EOL; |
|
115 | + } |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | // Echo memory peak usage |
@@ -45,12 +45,12 @@ |
||
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 | // Add some data |