@@ -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 |
@@ -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 |
@@ -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 |
@@ -44,22 +44,22 @@ 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'); |
|
58 | + ->setCellValue('B1', 'Financial Period') |
|
59 | + ->setCellValue('C1', 'Country') |
|
60 | + ->setCellValue('D1', 'Date') |
|
61 | + ->setCellValue('E1', 'Sales Value') |
|
62 | + ->setCellValue('F1', 'Expenditure'); |
|
63 | 63 | $startYear = $endYear = $currentYear = date('Y'); |
64 | 64 | $startYear--; |
65 | 65 | $endYear++; |
@@ -67,44 +67,44 @@ discard block |
||
67 | 67 | $years = range($startYear,$endYear); |
68 | 68 | $periods = range(1,12); |
69 | 69 | $countries = array( 'United States', 'UK', 'France', 'Germany', |
70 | - 'Italy', 'Spain', 'Portugal', 'Japan' |
|
71 | - ); |
|
70 | + 'Italy', 'Spain', 'Portugal', 'Japan' |
|
71 | + ); |
|
72 | 72 | |
73 | 73 | $row = 2; |
74 | 74 | foreach($years as $year) { |
75 | - foreach($periods as $period) { |
|
76 | - foreach($countries as $country) { |
|
77 | - $endDays = date('t',mktime(0,0,0,$period,1,$year)); |
|
78 | - for($i = 1; $i <= $endDays; ++$i) { |
|
79 | - $eDate = \PHPExcel\Shared\Date::formattedPHPToExcel( |
|
80 | - $year, |
|
81 | - $period, |
|
82 | - $i |
|
83 | - ); |
|
84 | - $value = rand(500,1000) * (1 + rand(-0.25,+0.25)); |
|
85 | - $salesValue = $invoiceValue = NULL; |
|
86 | - $incomeOrExpenditure = rand(-1,1); |
|
87 | - if ($incomeOrExpenditure == -1) { |
|
88 | - $expenditure = rand(-500,-1000) * (1 + rand(-0.25,+0.25)); |
|
89 | - $income = NULL; |
|
90 | - } elseif ($incomeOrExpenditure == 1) { |
|
91 | - $expenditure = rand(-500,-1000) * (1 + rand(-0.25,+0.25)); |
|
92 | - $income = rand(500,1000) * (1 + rand(-0.25,+0.25));; |
|
93 | - } else { |
|
94 | - $expenditure = NULL; |
|
95 | - $income = rand(500,1000) * (1 + rand(-0.25,+0.25));; |
|
96 | - } |
|
97 | - $dataArray = array( $year, |
|
98 | - $period, |
|
99 | - $country, |
|
100 | - $eDate, |
|
101 | - $income, |
|
102 | - $expenditure, |
|
103 | - ); |
|
104 | - $objPHPExcel->getActiveSheet()->fromArray($dataArray, NULL, 'A'.$row++); |
|
105 | - } |
|
106 | - } |
|
107 | - } |
|
75 | + foreach($periods as $period) { |
|
76 | + foreach($countries as $country) { |
|
77 | + $endDays = date('t',mktime(0,0,0,$period,1,$year)); |
|
78 | + for($i = 1; $i <= $endDays; ++$i) { |
|
79 | + $eDate = \PHPExcel\Shared\Date::formattedPHPToExcel( |
|
80 | + $year, |
|
81 | + $period, |
|
82 | + $i |
|
83 | + ); |
|
84 | + $value = rand(500,1000) * (1 + rand(-0.25,+0.25)); |
|
85 | + $salesValue = $invoiceValue = NULL; |
|
86 | + $incomeOrExpenditure = rand(-1,1); |
|
87 | + if ($incomeOrExpenditure == -1) { |
|
88 | + $expenditure = rand(-500,-1000) * (1 + rand(-0.25,+0.25)); |
|
89 | + $income = NULL; |
|
90 | + } elseif ($incomeOrExpenditure == 1) { |
|
91 | + $expenditure = rand(-500,-1000) * (1 + rand(-0.25,+0.25)); |
|
92 | + $income = rand(500,1000) * (1 + rand(-0.25,+0.25));; |
|
93 | + } else { |
|
94 | + $expenditure = NULL; |
|
95 | + $income = rand(500,1000) * (1 + rand(-0.25,+0.25));; |
|
96 | + } |
|
97 | + $dataArray = array( $year, |
|
98 | + $period, |
|
99 | + $country, |
|
100 | + $eDate, |
|
101 | + $income, |
|
102 | + $expenditure, |
|
103 | + ); |
|
104 | + $objPHPExcel->getActiveSheet()->fromArray($dataArray, NULL, 'A'.$row++); |
|
105 | + } |
|
106 | + } |
|
107 | + } |
|
108 | 108 | } |
109 | 109 | $row--; |
110 | 110 | |
@@ -137,37 +137,37 @@ discard block |
||
137 | 137 | $autoFilter->getColumn('C') |
138 | 138 | ->setFilterType(\PHPExcel\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_FILTER) |
139 | 139 | ->createRule() |
140 | - ->setRule( |
|
141 | - \PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL, |
|
142 | - 'Germany' |
|
143 | - ); |
|
140 | + ->setRule( |
|
141 | + \PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL, |
|
142 | + 'Germany' |
|
143 | + ); |
|
144 | 144 | // Filter the Date column on a filter value of the year to date |
145 | 145 | $autoFilter->getColumn('D') |
146 | - ->setFilterType(\PHPExcel\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER) |
|
147 | - ->createRule() |
|
148 | - ->setRule( |
|
149 | - \PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL, |
|
150 | - NULL, |
|
151 | - \PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_YEARTODATE |
|
152 | - ) |
|
153 | - ->setRuleType(\PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMICFILTER); |
|
146 | + ->setFilterType(\PHPExcel\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER) |
|
147 | + ->createRule() |
|
148 | + ->setRule( |
|
149 | + \PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL, |
|
150 | + NULL, |
|
151 | + \PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_YEARTODATE |
|
152 | + ) |
|
153 | + ->setRuleType(\PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMICFILTER); |
|
154 | 154 | // Display only sales values that are between 400 and 600 |
155 | 155 | $autoFilter->getColumn('E') |
156 | 156 | ->setFilterType(\PHPExcel\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER) |
157 | 157 | ->createRule() |
158 | - ->setRule( |
|
159 | - \PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_GREATERTHANOREQUAL, |
|
160 | - 400 |
|
161 | - ) |
|
162 | - ->setRuleType(\PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER); |
|
158 | + ->setRule( |
|
159 | + \PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_GREATERTHANOREQUAL, |
|
160 | + 400 |
|
161 | + ) |
|
162 | + ->setRuleType(\PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER); |
|
163 | 163 | $autoFilter->getColumn('E') |
164 | 164 | ->setJoin(\PHPExcel\Worksheet\AutoFilter\Column::AUTOFILTER_COLUMN_JOIN_AND) |
165 | 165 | ->createRule() |
166 | - ->setRule( |
|
167 | - \PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_LESSTHANOREQUAL, |
|
168 | - 600 |
|
169 | - ) |
|
170 | - ->setRuleType(\PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER); |
|
166 | + ->setRule( |
|
167 | + \PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_LESSTHANOREQUAL, |
|
168 | + 600 |
|
169 | + ) |
|
170 | + ->setRuleType(\PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER); |
|
171 | 171 | |
172 | 172 | |
173 | 173 | // Set active sheet index to the first sheet, so Excel opens this as the first sheet |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | date_default_timezone_set('Europe/London'); |
33 | 33 | |
34 | 34 | if (PHP_SAPI == 'cli') |
35 | - die('This example should only be run from a Web Browser'); |
|
35 | + die('This example should only be run from a Web Browser'); |
|
36 | 36 | |
37 | 37 | /** Include PHPExcel */ |
38 | 38 | require_once dirname(__FILE__) . '/../src/Bootstrap.php'; |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | |
44 | 44 | // Set document properties |
45 | 45 | $objPHPExcel->getProperties()->setCreator("Maarten Balliauw") |
46 | - ->setLastModifiedBy("Maarten Balliauw") |
|
47 | - ->setTitle("Office 2007 XLSX Test Document") |
|
48 | - ->setSubject("Office 2007 XLSX Test Document") |
|
49 | - ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.") |
|
50 | - ->setKeywords("office 2007 openxml php") |
|
51 | - ->setCategory("Test result file"); |
|
46 | + ->setLastModifiedBy("Maarten Balliauw") |
|
47 | + ->setTitle("Office 2007 XLSX Test Document") |
|
48 | + ->setSubject("Office 2007 XLSX Test Document") |
|
49 | + ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.") |
|
50 | + ->setKeywords("office 2007 openxml php") |
|
51 | + ->setCategory("Test result file"); |
|
52 | 52 | |
53 | 53 | |
54 | 54 | // Add some data |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | date_default_timezone_set('Europe/London'); |
33 | 33 | |
34 | 34 | if (PHP_SAPI == 'cli') |
35 | - die('This example should only be run from a Web Browser'); |
|
35 | + die('This example should only be run from a Web Browser'); |
|
36 | 36 | |
37 | 37 | /** Include PHPExcel */ |
38 | 38 | require_once dirname(__FILE__) . '/../src/Bootstrap.php'; |
@@ -54,12 +54,12 @@ discard block |
||
54 | 54 | |
55 | 55 | // Set document properties |
56 | 56 | $objPHPExcel->getProperties()->setCreator("Maarten Balliauw") |
57 | - ->setLastModifiedBy("Maarten Balliauw") |
|
58 | - ->setTitle("PDF Test Document") |
|
59 | - ->setSubject("PDF Test Document") |
|
60 | - ->setDescription("Test document for PDF, generated using PHP classes.") |
|
61 | - ->setKeywords("pdf php") |
|
62 | - ->setCategory("Test result file"); |
|
57 | + ->setLastModifiedBy("Maarten Balliauw") |
|
58 | + ->setTitle("PDF Test Document") |
|
59 | + ->setSubject("PDF Test Document") |
|
60 | + ->setDescription("Test document for PDF, generated using PHP classes.") |
|
61 | + ->setKeywords("pdf php") |
|
62 | + ->setCategory("Test result file"); |
|
63 | 63 | |
64 | 64 | |
65 | 65 | // Add some data |
@@ -83,14 +83,14 @@ discard block |
||
83 | 83 | |
84 | 84 | |
85 | 85 | if (!PHPExcel\Settings::setPdfRenderer( |
86 | - $rendererName, |
|
87 | - $rendererLibraryPath |
|
88 | - )) { |
|
89 | - die( |
|
90 | - 'NOTICE: Please set the $rendererName and $rendererLibraryPath values' . |
|
91 | - '<br />' . |
|
92 | - 'at the top of this script as appropriate for your directory structure' |
|
93 | - ); |
|
86 | + $rendererName, |
|
87 | + $rendererLibraryPath |
|
88 | + )) { |
|
89 | + die( |
|
90 | + 'NOTICE: Please set the $rendererName and $rendererLibraryPath values' . |
|
91 | + '<br />' . |
|
92 | + 'at the top of this script as appropriate for your directory structure' |
|
93 | + ); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 |
@@ -22,79 +22,79 @@ |
||
22 | 22 | |
23 | 23 | |
24 | 24 | if (!PHPExcel\Settings::setChartRenderer( |
25 | - $rendererName, |
|
26 | - $rendererLibraryPath |
|
27 | - )) { |
|
28 | - die( |
|
29 | - 'NOTICE: Please set the $rendererName and $rendererLibraryPath values' . |
|
30 | - EOL . |
|
31 | - 'at the top of this script as appropriate for your directory structure' |
|
32 | - ); |
|
25 | + $rendererName, |
|
26 | + $rendererLibraryPath |
|
27 | + )) { |
|
28 | + die( |
|
29 | + 'NOTICE: Please set the $rendererName and $rendererLibraryPath values' . |
|
30 | + EOL . |
|
31 | + 'at the top of this script as appropriate for your directory structure' |
|
32 | + ); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | |
36 | 36 | $inputFileType = 'Excel2007'; |
37 | 37 | $inputFileNames = 'templates/32readwrite*[0-9].xlsx'; |
38 | 38 | |
39 | - if ((isset($argc)) && ($argc > 1)) { |
|
40 | - $inputFileNames = array(); |
|
41 | - for($i = 1; $i < $argc; ++$i) { |
|
42 | - $inputFileNames[] = dirname(__FILE__) . '/templates/' . $argv[$i]; |
|
43 | - } |
|
39 | + if ((isset($argc)) && ($argc > 1)) { |
|
40 | + $inputFileNames = array(); |
|
41 | + for($i = 1; $i < $argc; ++$i) { |
|
42 | + $inputFileNames[] = dirname(__FILE__) . '/templates/' . $argv[$i]; |
|
43 | + } |
|
44 | 44 | } else { |
45 | - $inputFileNames = glob($inputFileNames); |
|
45 | + $inputFileNames = glob($inputFileNames); |
|
46 | 46 | } |
47 | 47 | foreach($inputFileNames as $inputFileName) { |
48 | - $inputFileNameShort = basename($inputFileName); |
|
49 | - |
|
50 | - if (!file_exists($inputFileName)) { |
|
51 | - echo date('H:i:s') , " File " , $inputFileNameShort , ' does not exist' , EOL; |
|
52 | - continue; |
|
53 | - } |
|
54 | - |
|
55 | - echo date('H:i:s') , " Load Test from $inputFileType file " , $inputFileNameShort , EOL; |
|
56 | - |
|
57 | - $objReader = \PHPExcel\IOFactory::createReader($inputFileType); |
|
58 | - $objReader->setIncludeCharts(TRUE); |
|
59 | - $objPHPExcel = $objReader->load($inputFileName); |
|
60 | - |
|
61 | - |
|
62 | - echo date('H:i:s') , " Iterate worksheets looking at the charts" , EOL; |
|
63 | - foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) { |
|
64 | - $sheetName = $worksheet->getTitle(); |
|
65 | - echo 'Worksheet: ' , $sheetName , EOL; |
|
66 | - |
|
67 | - $chartNames = $worksheet->getChartNames(); |
|
68 | - if(empty($chartNames)) { |
|
69 | - echo ' There are no charts in this worksheet' , EOL; |
|
70 | - } else { |
|
71 | - natsort($chartNames); |
|
72 | - foreach($chartNames as $i => $chartName) { |
|
73 | - $chart = $worksheet->getChartByName($chartName); |
|
74 | - if (!is_null($chart->getTitle())) { |
|
75 | - $caption = '"' . implode(' ',$chart->getTitle()->getCaption()) . '"'; |
|
76 | - } else { |
|
77 | - $caption = 'Untitled'; |
|
78 | - } |
|
79 | - echo ' ' , $chartName , ' - ' , $caption , EOL; |
|
80 | - echo str_repeat(' ',strlen($chartName)+3); |
|
81 | - |
|
82 | - $jpegFile = '35'.str_replace('.xlsx', '.jpg', substr($inputFileNameShort,2)); |
|
83 | - if (file_exists($jpegFile)) { |
|
84 | - unlink($jpegFile); |
|
85 | - } |
|
86 | - try { |
|
87 | - $chart->render($jpegFile); |
|
88 | - } catch (Exception $e) { |
|
89 | - echo 'Error rendering chart: ',$e->getMessage(); |
|
90 | - } |
|
91 | - } |
|
92 | - } |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - $objPHPExcel->disconnectWorksheets(); |
|
97 | - unset($objPHPExcel); |
|
48 | + $inputFileNameShort = basename($inputFileName); |
|
49 | + |
|
50 | + if (!file_exists($inputFileName)) { |
|
51 | + echo date('H:i:s') , " File " , $inputFileNameShort , ' does not exist' , EOL; |
|
52 | + continue; |
|
53 | + } |
|
54 | + |
|
55 | + echo date('H:i:s') , " Load Test from $inputFileType file " , $inputFileNameShort , EOL; |
|
56 | + |
|
57 | + $objReader = \PHPExcel\IOFactory::createReader($inputFileType); |
|
58 | + $objReader->setIncludeCharts(TRUE); |
|
59 | + $objPHPExcel = $objReader->load($inputFileName); |
|
60 | + |
|
61 | + |
|
62 | + echo date('H:i:s') , " Iterate worksheets looking at the charts" , EOL; |
|
63 | + foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) { |
|
64 | + $sheetName = $worksheet->getTitle(); |
|
65 | + echo 'Worksheet: ' , $sheetName , EOL; |
|
66 | + |
|
67 | + $chartNames = $worksheet->getChartNames(); |
|
68 | + if(empty($chartNames)) { |
|
69 | + echo ' There are no charts in this worksheet' , EOL; |
|
70 | + } else { |
|
71 | + natsort($chartNames); |
|
72 | + foreach($chartNames as $i => $chartName) { |
|
73 | + $chart = $worksheet->getChartByName($chartName); |
|
74 | + if (!is_null($chart->getTitle())) { |
|
75 | + $caption = '"' . implode(' ',$chart->getTitle()->getCaption()) . '"'; |
|
76 | + } else { |
|
77 | + $caption = 'Untitled'; |
|
78 | + } |
|
79 | + echo ' ' , $chartName , ' - ' , $caption , EOL; |
|
80 | + echo str_repeat(' ',strlen($chartName)+3); |
|
81 | + |
|
82 | + $jpegFile = '35'.str_replace('.xlsx', '.jpg', substr($inputFileNameShort,2)); |
|
83 | + if (file_exists($jpegFile)) { |
|
84 | + unlink($jpegFile); |
|
85 | + } |
|
86 | + try { |
|
87 | + $chart->render($jpegFile); |
|
88 | + } catch (Exception $e) { |
|
89 | + echo 'Error rendering chart: ',$e->getMessage(); |
|
90 | + } |
|
91 | + } |
|
92 | + } |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + $objPHPExcel->disconnectWorksheets(); |
|
97 | + unset($objPHPExcel); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | // Echo memory peak usage |
@@ -43,13 +43,13 @@ discard block |
||
43 | 43 | $objPHPExcel = new \PHPExcel\Spreadsheet(); |
44 | 44 | $objWorksheet = $objPHPExcel->getActiveSheet(); |
45 | 45 | $objWorksheet->fromArray( |
46 | - array( |
|
47 | - array('', 2010, 2011, 2012), |
|
48 | - array('Q1', 12, 15, 21), |
|
49 | - array('Q2', 56, 73, 86), |
|
50 | - array('Q3', 52, 61, 69), |
|
51 | - array('Q4', 30, 32, 0), |
|
52 | - ) |
|
46 | + array( |
|
47 | + array('', 2010, 2011, 2012), |
|
48 | + array('Q1', 12, 15, 21), |
|
49 | + array('Q2', 56, 73, 86), |
|
50 | + array('Q3', 52, 61, 69), |
|
51 | + array('Q4', 30, 32, 0), |
|
52 | + ) |
|
53 | 53 | ); |
54 | 54 | |
55 | 55 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | // Data values |
62 | 62 | // Data Marker |
63 | 63 | $dataSeriesLabels1 = array( |
64 | - new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011 |
|
64 | + new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011 |
|
65 | 65 | ); |
66 | 66 | // Set the X-Axis Labels |
67 | 67 | // Datatype |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | // Data values |
72 | 72 | // Data Marker |
73 | 73 | $xAxisTickValues1 = array( |
74 | - new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', NULL, 4), // Q1 to Q4 |
|
74 | + new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', NULL, 4), // Q1 to Q4 |
|
75 | 75 | ); |
76 | 76 | // Set the Data values for each data series we want to plot |
77 | 77 | // Datatype |
@@ -81,17 +81,17 @@ discard block |
||
81 | 81 | // Data values |
82 | 82 | // Data Marker |
83 | 83 | $dataSeriesValues1 = array( |
84 | - new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', NULL, 4), |
|
84 | + new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', NULL, 4), |
|
85 | 85 | ); |
86 | 86 | |
87 | 87 | // Build the dataseries |
88 | 88 | $series1 = new \PHPExcel\Chart\DataSeries( |
89 | - \PHPExcel\Chart\DataSeries::TYPE_PIECHART, // plotType |
|
90 | - NULL, // plotGrouping (Pie charts don't have any grouping) |
|
91 | - range(0, count($dataSeriesValues1)-1), // plotOrder |
|
92 | - $dataSeriesLabels1, // plotLabel |
|
93 | - $xAxisTickValues1, // plotCategory |
|
94 | - $dataSeriesValues1 // plotValues |
|
89 | + \PHPExcel\Chart\DataSeries::TYPE_PIECHART, // plotType |
|
90 | + NULL, // plotGrouping (Pie charts don't have any grouping) |
|
91 | + range(0, count($dataSeriesValues1)-1), // plotOrder |
|
92 | + $dataSeriesLabels1, // plotLabel |
|
93 | + $xAxisTickValues1, // plotCategory |
|
94 | + $dataSeriesValues1 // plotValues |
|
95 | 95 | ); |
96 | 96 | |
97 | 97 | // Set up a layout object for the Pie chart |
@@ -109,14 +109,14 @@ discard block |
||
109 | 109 | |
110 | 110 | // Create the chart |
111 | 111 | $chart1 = new \PHPExcel\Chart( |
112 | - 'chart1', // name |
|
113 | - $title1, // title |
|
114 | - $legend1, // legend |
|
115 | - $plotArea1, // plotArea |
|
116 | - true, // plotVisibleOnly |
|
117 | - 0, // displayBlanksAs |
|
118 | - NULL, // xAxisLabel |
|
119 | - NULL // yAxisLabel - Pie charts don't have a Y-Axis |
|
112 | + 'chart1', // name |
|
113 | + $title1, // title |
|
114 | + $legend1, // legend |
|
115 | + $plotArea1, // plotArea |
|
116 | + true, // plotVisibleOnly |
|
117 | + 0, // displayBlanksAs |
|
118 | + NULL, // xAxisLabel |
|
119 | + NULL // yAxisLabel - Pie charts don't have a Y-Axis |
|
120 | 120 | ); |
121 | 121 | |
122 | 122 | // Set the position where the chart should appear in the worksheet |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | // Data values |
136 | 136 | // Data Marker |
137 | 137 | $dataSeriesLabels2 = array( |
138 | - new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011 |
|
138 | + new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011 |
|
139 | 139 | ); |
140 | 140 | // Set the X-Axis Labels |
141 | 141 | // Datatype |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | // Data values |
146 | 146 | // Data Marker |
147 | 147 | $xAxisTickValues2 = array( |
148 | - new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', NULL, 4), // Q1 to Q4 |
|
148 | + new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', NULL, 4), // Q1 to Q4 |
|
149 | 149 | ); |
150 | 150 | // Set the Data values for each data series we want to plot |
151 | 151 | // Datatype |
@@ -155,17 +155,17 @@ discard block |
||
155 | 155 | // Data values |
156 | 156 | // Data Marker |
157 | 157 | $dataSeriesValues2 = array( |
158 | - new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', NULL, 4), |
|
158 | + new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', NULL, 4), |
|
159 | 159 | ); |
160 | 160 | |
161 | 161 | // Build the dataseries |
162 | 162 | $series2 = new \PHPExcel\Chart\DataSeries( |
163 | - \PHPExcel\Chart\DataSeries::TYPE_DONUTCHART, // plotType |
|
164 | - NULL, // plotGrouping (Donut charts don't have any grouping) |
|
165 | - range(0, count($dataSeriesValues2)-1), // plotOrder |
|
166 | - $dataSeriesLabels2, // plotLabel |
|
167 | - $xAxisTickValues2, // plotCategory |
|
168 | - $dataSeriesValues2 // plotValues |
|
163 | + \PHPExcel\Chart\DataSeries::TYPE_DONUTCHART, // plotType |
|
164 | + NULL, // plotGrouping (Donut charts don't have any grouping) |
|
165 | + range(0, count($dataSeriesValues2)-1), // plotOrder |
|
166 | + $dataSeriesLabels2, // plotLabel |
|
167 | + $xAxisTickValues2, // plotCategory |
|
168 | + $dataSeriesValues2 // plotValues |
|
169 | 169 | ); |
170 | 170 | |
171 | 171 | // Set up a layout object for the Pie chart |
@@ -181,14 +181,14 @@ discard block |
||
181 | 181 | |
182 | 182 | // Create the chart |
183 | 183 | $chart2 = new \PHPExcel\Chart( |
184 | - 'chart2', // name |
|
185 | - $title2, // title |
|
186 | - NULL, // legend |
|
187 | - $plotArea2, // plotArea |
|
188 | - true, // plotVisibleOnly |
|
189 | - 0, // displayBlanksAs |
|
190 | - NULL, // xAxisLabel |
|
191 | - NULL // yAxisLabel - Like Pie charts, Donut charts don't have a Y-Axis |
|
184 | + 'chart2', // name |
|
185 | + $title2, // title |
|
186 | + NULL, // legend |
|
187 | + $plotArea2, // plotArea |
|
188 | + true, // plotVisibleOnly |
|
189 | + 0, // displayBlanksAs |
|
190 | + NULL, // xAxisLabel |
|
191 | + NULL // yAxisLabel - Like Pie charts, Donut charts don't have a Y-Axis |
|
192 | 192 | ); |
193 | 193 | |
194 | 194 | // Set the position where the chart should appear in the worksheet |