@@ -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'; |
@@ -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 |
@@ -52,142 +52,142 @@ discard block |
||
52 | 52 | // Add some data, we will use some formulas here |
53 | 53 | echo date('H:i:s') , " Add some data and formulas" , EOL; |
54 | 54 | $objPHPExcel->getActiveSheet()->setCellValue('A14', 'Count:') |
55 | - ->setCellValue('A15', 'Sum:') |
|
56 | - ->setCellValue('A16', 'Max:') |
|
57 | - ->setCellValue('A17', 'Min:') |
|
58 | - ->setCellValue('A18', 'Average:') |
|
59 | - ->setCellValue('A19', 'Median:') |
|
60 | - ->setCellValue('A20', 'Mode:'); |
|
55 | + ->setCellValue('A15', 'Sum:') |
|
56 | + ->setCellValue('A16', 'Max:') |
|
57 | + ->setCellValue('A17', 'Min:') |
|
58 | + ->setCellValue('A18', 'Average:') |
|
59 | + ->setCellValue('A19', 'Median:') |
|
60 | + ->setCellValue('A20', 'Mode:'); |
|
61 | 61 | |
62 | 62 | $objPHPExcel->getActiveSheet()->setCellValue('A22', 'CountA:') |
63 | - ->setCellValue('A23', 'MaxA:') |
|
64 | - ->setCellValue('A24', 'MinA:'); |
|
63 | + ->setCellValue('A23', 'MaxA:') |
|
64 | + ->setCellValue('A24', 'MinA:'); |
|
65 | 65 | |
66 | 66 | $objPHPExcel->getActiveSheet()->setCellValue('A26', 'StDev:') |
67 | - ->setCellValue('A27', 'StDevA:') |
|
68 | - ->setCellValue('A28', 'StDevP:') |
|
69 | - ->setCellValue('A29', 'StDevPA:'); |
|
67 | + ->setCellValue('A27', 'StDevA:') |
|
68 | + ->setCellValue('A28', 'StDevP:') |
|
69 | + ->setCellValue('A29', 'StDevPA:'); |
|
70 | 70 | |
71 | 71 | $objPHPExcel->getActiveSheet()->setCellValue('A31', 'DevSq:') |
72 | - ->setCellValue('A32', 'Var:') |
|
73 | - ->setCellValue('A33', 'VarA:') |
|
74 | - ->setCellValue('A34', 'VarP:') |
|
75 | - ->setCellValue('A35', 'VarPA:'); |
|
72 | + ->setCellValue('A32', 'Var:') |
|
73 | + ->setCellValue('A33', 'VarA:') |
|
74 | + ->setCellValue('A34', 'VarP:') |
|
75 | + ->setCellValue('A35', 'VarPA:'); |
|
76 | 76 | |
77 | 77 | $objPHPExcel->getActiveSheet()->setCellValue('A37', 'Date:'); |
78 | 78 | |
79 | 79 | |
80 | 80 | $objPHPExcel->getActiveSheet()->setCellValue('B1', 'Range 1') |
81 | - ->setCellValue('B2', 2) |
|
82 | - ->setCellValue('B3', 8) |
|
83 | - ->setCellValue('B4', 10) |
|
84 | - ->setCellValue('B5', True) |
|
85 | - ->setCellValue('B6', False) |
|
86 | - ->setCellValue('B7', 'Text String') |
|
87 | - ->setCellValue('B9', '22') |
|
88 | - ->setCellValue('B10', 4) |
|
89 | - ->setCellValue('B11', 6) |
|
90 | - ->setCellValue('B12', 12); |
|
81 | + ->setCellValue('B2', 2) |
|
82 | + ->setCellValue('B3', 8) |
|
83 | + ->setCellValue('B4', 10) |
|
84 | + ->setCellValue('B5', True) |
|
85 | + ->setCellValue('B6', False) |
|
86 | + ->setCellValue('B7', 'Text String') |
|
87 | + ->setCellValue('B9', '22') |
|
88 | + ->setCellValue('B10', 4) |
|
89 | + ->setCellValue('B11', 6) |
|
90 | + ->setCellValue('B12', 12); |
|
91 | 91 | |
92 | 92 | $objPHPExcel->getActiveSheet()->setCellValue('B14', '=COUNT(B2:B12)') |
93 | - ->setCellValue('B15', '=SUM(B2:B12)') |
|
94 | - ->setCellValue('B16', '=MAX(B2:B12)') |
|
95 | - ->setCellValue('B17', '=MIN(B2:B12)') |
|
96 | - ->setCellValue('B18', '=AVERAGE(B2:B12)') |
|
97 | - ->setCellValue('B19', '=MEDIAN(B2:B12)') |
|
98 | - ->setCellValue('B20', '=MODE(B2:B12)'); |
|
93 | + ->setCellValue('B15', '=SUM(B2:B12)') |
|
94 | + ->setCellValue('B16', '=MAX(B2:B12)') |
|
95 | + ->setCellValue('B17', '=MIN(B2:B12)') |
|
96 | + ->setCellValue('B18', '=AVERAGE(B2:B12)') |
|
97 | + ->setCellValue('B19', '=MEDIAN(B2:B12)') |
|
98 | + ->setCellValue('B20', '=MODE(B2:B12)'); |
|
99 | 99 | |
100 | 100 | $objPHPExcel->getActiveSheet()->setCellValue('B22', '=COUNTA(B2:B12)') |
101 | - ->setCellValue('B23', '=MAXA(B2:B12)') |
|
102 | - ->setCellValue('B24', '=MINA(B2:B12)'); |
|
101 | + ->setCellValue('B23', '=MAXA(B2:B12)') |
|
102 | + ->setCellValue('B24', '=MINA(B2:B12)'); |
|
103 | 103 | |
104 | 104 | $objPHPExcel->getActiveSheet()->setCellValue('B26', '=STDEV(B2:B12)') |
105 | - ->setCellValue('B27', '=STDEVA(B2:B12)') |
|
106 | - ->setCellValue('B28', '=STDEVP(B2:B12)') |
|
107 | - ->setCellValue('B29', '=STDEVPA(B2:B12)'); |
|
105 | + ->setCellValue('B27', '=STDEVA(B2:B12)') |
|
106 | + ->setCellValue('B28', '=STDEVP(B2:B12)') |
|
107 | + ->setCellValue('B29', '=STDEVPA(B2:B12)'); |
|
108 | 108 | |
109 | 109 | $objPHPExcel->getActiveSheet()->setCellValue('B31', '=DEVSQ(B2:B12)') |
110 | - ->setCellValue('B32', '=VAR(B2:B12)') |
|
111 | - ->setCellValue('B33', '=VARA(B2:B12)') |
|
112 | - ->setCellValue('B34', '=VARP(B2:B12)') |
|
113 | - ->setCellValue('B35', '=VARPA(B2:B12)'); |
|
110 | + ->setCellValue('B32', '=VAR(B2:B12)') |
|
111 | + ->setCellValue('B33', '=VARA(B2:B12)') |
|
112 | + ->setCellValue('B34', '=VARP(B2:B12)') |
|
113 | + ->setCellValue('B35', '=VARPA(B2:B12)'); |
|
114 | 114 | |
115 | 115 | $objPHPExcel->getActiveSheet()->setCellValue('B37', '=DATE(2007, 12, 21)') |
116 | - ->setCellValue('B38', '=DATEDIF( DATE(2007, 12, 21), DATE(2007, 12, 22), "D" )') |
|
117 | - ->setCellValue('B39', '=DATEVALUE("01-Feb-2006 10:06 AM")') |
|
118 | - ->setCellValue('B40', '=DAY( DATE(2006, 1, 2) )') |
|
119 | - ->setCellValue('B41', '=DAYS360( DATE(2002, 2, 3), DATE(2005, 5, 31) )'); |
|
116 | + ->setCellValue('B38', '=DATEDIF( DATE(2007, 12, 21), DATE(2007, 12, 22), "D" )') |
|
117 | + ->setCellValue('B39', '=DATEVALUE("01-Feb-2006 10:06 AM")') |
|
118 | + ->setCellValue('B40', '=DAY( DATE(2006, 1, 2) )') |
|
119 | + ->setCellValue('B41', '=DAYS360( DATE(2002, 2, 3), DATE(2005, 5, 31) )'); |
|
120 | 120 | |
121 | 121 | |
122 | 122 | $objPHPExcel->getActiveSheet()->setCellValue('C1', 'Range 2') |
123 | - ->setCellValue('C2', 1) |
|
124 | - ->setCellValue('C3', 2) |
|
125 | - ->setCellValue('C4', 2) |
|
126 | - ->setCellValue('C5', 3) |
|
127 | - ->setCellValue('C6', 3) |
|
128 | - ->setCellValue('C7', 3) |
|
129 | - ->setCellValue('C8', '0') |
|
130 | - ->setCellValue('C9', 4) |
|
131 | - ->setCellValue('C10', 4) |
|
132 | - ->setCellValue('C11', 4) |
|
133 | - ->setCellValue('C12', 4); |
|
123 | + ->setCellValue('C2', 1) |
|
124 | + ->setCellValue('C3', 2) |
|
125 | + ->setCellValue('C4', 2) |
|
126 | + ->setCellValue('C5', 3) |
|
127 | + ->setCellValue('C6', 3) |
|
128 | + ->setCellValue('C7', 3) |
|
129 | + ->setCellValue('C8', '0') |
|
130 | + ->setCellValue('C9', 4) |
|
131 | + ->setCellValue('C10', 4) |
|
132 | + ->setCellValue('C11', 4) |
|
133 | + ->setCellValue('C12', 4); |
|
134 | 134 | |
135 | 135 | $objPHPExcel->getActiveSheet()->setCellValue('C14', '=COUNT(C2:C12)') |
136 | - ->setCellValue('C15', '=SUM(C2:C12)') |
|
137 | - ->setCellValue('C16', '=MAX(C2:C12)') |
|
138 | - ->setCellValue('C17', '=MIN(C2:C12)') |
|
139 | - ->setCellValue('C18', '=AVERAGE(C2:C12)') |
|
140 | - ->setCellValue('C19', '=MEDIAN(C2:C12)') |
|
141 | - ->setCellValue('C20', '=MODE(C2:C12)'); |
|
136 | + ->setCellValue('C15', '=SUM(C2:C12)') |
|
137 | + ->setCellValue('C16', '=MAX(C2:C12)') |
|
138 | + ->setCellValue('C17', '=MIN(C2:C12)') |
|
139 | + ->setCellValue('C18', '=AVERAGE(C2:C12)') |
|
140 | + ->setCellValue('C19', '=MEDIAN(C2:C12)') |
|
141 | + ->setCellValue('C20', '=MODE(C2:C12)'); |
|
142 | 142 | |
143 | 143 | $objPHPExcel->getActiveSheet()->setCellValue('C22', '=COUNTA(C2:C12)') |
144 | - ->setCellValue('C23', '=MAXA(C2:C12)') |
|
145 | - ->setCellValue('C24', '=MINA(C2:C12)'); |
|
144 | + ->setCellValue('C23', '=MAXA(C2:C12)') |
|
145 | + ->setCellValue('C24', '=MINA(C2:C12)'); |
|
146 | 146 | |
147 | 147 | $objPHPExcel->getActiveSheet()->setCellValue('C26', '=STDEV(C2:C12)') |
148 | - ->setCellValue('C27', '=STDEVA(C2:C12)') |
|
149 | - ->setCellValue('C28', '=STDEVP(C2:C12)') |
|
150 | - ->setCellValue('C29', '=STDEVPA(C2:C12)'); |
|
148 | + ->setCellValue('C27', '=STDEVA(C2:C12)') |
|
149 | + ->setCellValue('C28', '=STDEVP(C2:C12)') |
|
150 | + ->setCellValue('C29', '=STDEVPA(C2:C12)'); |
|
151 | 151 | |
152 | 152 | $objPHPExcel->getActiveSheet()->setCellValue('C31', '=DEVSQ(C2:C12)') |
153 | - ->setCellValue('C32', '=VAR(C2:C12)') |
|
154 | - ->setCellValue('C33', '=VARA(C2:C12)') |
|
155 | - ->setCellValue('C34', '=VARP(C2:C12)') |
|
156 | - ->setCellValue('C35', '=VARPA(C2:C12)'); |
|
153 | + ->setCellValue('C32', '=VAR(C2:C12)') |
|
154 | + ->setCellValue('C33', '=VARA(C2:C12)') |
|
155 | + ->setCellValue('C34', '=VARP(C2:C12)') |
|
156 | + ->setCellValue('C35', '=VARPA(C2:C12)'); |
|
157 | 157 | |
158 | 158 | |
159 | 159 | $objPHPExcel->getActiveSheet()->setCellValue('D1', 'Range 3') |
160 | - ->setCellValue('D2', 2) |
|
161 | - ->setCellValue('D3', 3) |
|
162 | - ->setCellValue('D4', 4); |
|
160 | + ->setCellValue('D2', 2) |
|
161 | + ->setCellValue('D3', 3) |
|
162 | + ->setCellValue('D4', 4); |
|
163 | 163 | |
164 | 164 | $objPHPExcel->getActiveSheet()->setCellValue('D14', '=((D2 * D3) + D4) & " should be 10"'); |
165 | 165 | |
166 | 166 | $objPHPExcel->getActiveSheet()->setCellValue('E12', 'Other functions') |
167 | - ->setCellValue('E14', '=PI()') |
|
168 | - ->setCellValue('E15', '=RAND()') |
|
169 | - ->setCellValue('E16', '=RANDBETWEEN(5, 10)'); |
|
167 | + ->setCellValue('E14', '=PI()') |
|
168 | + ->setCellValue('E15', '=RAND()') |
|
169 | + ->setCellValue('E16', '=RANDBETWEEN(5, 10)'); |
|
170 | 170 | |
171 | 171 | $objPHPExcel->getActiveSheet()->setCellValue('E17', 'Count of both ranges:') |
172 | - ->setCellValue('F17', '=COUNT(B2:C12)'); |
|
172 | + ->setCellValue('F17', '=COUNT(B2:C12)'); |
|
173 | 173 | |
174 | 174 | $objPHPExcel->getActiveSheet()->setCellValue('E18', 'Total of both ranges:') |
175 | - ->setCellValue('F18', '=SUM(B2:C12)'); |
|
175 | + ->setCellValue('F18', '=SUM(B2:C12)'); |
|
176 | 176 | |
177 | 177 | $objPHPExcel->getActiveSheet()->setCellValue('E19', 'Maximum of both ranges:') |
178 | - ->setCellValue('F19', '=MAX(B2:C12)'); |
|
178 | + ->setCellValue('F19', '=MAX(B2:C12)'); |
|
179 | 179 | |
180 | 180 | $objPHPExcel->getActiveSheet()->setCellValue('E20', 'Minimum of both ranges:') |
181 | - ->setCellValue('F20', '=MIN(B2:C12)'); |
|
181 | + ->setCellValue('F20', '=MIN(B2:C12)'); |
|
182 | 182 | |
183 | 183 | $objPHPExcel->getActiveSheet()->setCellValue('E21', 'Average of both ranges:') |
184 | - ->setCellValue('F21', '=AVERAGE(B2:C12)'); |
|
184 | + ->setCellValue('F21', '=AVERAGE(B2:C12)'); |
|
185 | 185 | |
186 | 186 | $objPHPExcel->getActiveSheet()->setCellValue('E22', 'Median of both ranges:') |
187 | - ->setCellValue('F22', '=MEDIAN(B2:C12)'); |
|
187 | + ->setCellValue('F22', '=MEDIAN(B2:C12)'); |
|
188 | 188 | |
189 | 189 | $objPHPExcel->getActiveSheet()->setCellValue('E23', 'Mode of both ranges:') |
190 | - ->setCellValue('F23', '=MODE(B2:C12)'); |
|
190 | + ->setCellValue('F23', '=MODE(B2:C12)'); |
|
191 | 191 | |
192 | 192 | |
193 | 193 | // Calculated data |
@@ -195,9 +195,9 @@ discard block |
||
195 | 195 | for ($col = 'B'; $col != 'G'; ++$col) { |
196 | 196 | for($row = 14; $row <= 41; ++$row) { |
197 | 197 | if ((!is_null($formula = $objPHPExcel->getActiveSheet()->getCell($col.$row)->getValue())) && |
198 | - ($formula[0] == '=')) { |
|
198 | + ($formula[0] == '=')) { |
|
199 | 199 | echo 'Value of ' , $col , $row , ' [' , $formula , ']: ' , |
200 | - $objPHPExcel->getActiveSheet()->getCell($col.$row)->getCalculatedValue() . EOL; |
|
200 | + $objPHPExcel->getActiveSheet()->getCell($col.$row)->getCalculatedValue() . EOL; |
|
201 | 201 | } |
202 | 202 | } |
203 | 203 | } |
@@ -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 |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | $cacheMethod = \PHPExcel\CachedObjectStorageFactory::CACHE_IN_MEMORY_GZIP; |
41 | 41 | if (!\PHPExcel\Settings::setCacheStorageMethod($cacheMethod)) { |
42 | - die($cacheMethod . " caching method is not available" . EOL); |
|
42 | + die($cacheMethod . " caching method is not available" . EOL); |
|
43 | 43 | } |
44 | 44 | echo date('H:i:s') , " Enable Cell Caching using " , $cacheMethod , " method" , EOL; |
45 | 45 | |
@@ -51,12 +51,12 @@ discard block |
||
51 | 51 | // Set document properties |
52 | 52 | echo date('H:i:s') , " Set properties" , EOL; |
53 | 53 | $objPHPExcel->getProperties()->setCreator("Maarten Balliauw") |
54 | - ->setLastModifiedBy("Maarten Balliauw") |
|
55 | - ->setTitle("Office 2007 XLSX Test Document") |
|
56 | - ->setSubject("Office 2007 XLSX Test Document") |
|
57 | - ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.") |
|
58 | - ->setKeywords("office 2007 openxml php") |
|
59 | - ->setCategory("Test result file"); |
|
54 | + ->setLastModifiedBy("Maarten Balliauw") |
|
55 | + ->setTitle("Office 2007 XLSX Test Document") |
|
56 | + ->setSubject("Office 2007 XLSX Test Document") |
|
57 | + ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.") |
|
58 | + ->setKeywords("office 2007 openxml php") |
|
59 | + ->setCategory("Test result file"); |
|
60 | 60 | |
61 | 61 | |
62 | 62 | // Create a first sheet |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | // Set outline levels |
79 | 79 | echo date('H:i:s') , " Set outline levels" , EOL; |
80 | 80 | $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setOutlineLevel(1) |
81 | - ->setVisible(false) |
|
82 | - ->setCollapsed(true); |
|
81 | + ->setVisible(false) |
|
82 | + ->setCollapsed(true); |
|
83 | 83 | |
84 | 84 | // Freeze panes |
85 | 85 | echo date('H:i:s') , " Freeze panes" , EOL; |
@@ -93,11 +93,11 @@ discard block |
||
93 | 93 | |
94 | 94 | // Add data |
95 | 95 | for ($i = 2; $i <= 5000; $i++) { |
96 | - $objPHPExcel->getActiveSheet()->setCellValue('A' . $i, "FName $i") |
|
97 | - ->setCellValue('B' . $i, "LName $i") |
|
98 | - ->setCellValue('C' . $i, "PhoneNo $i") |
|
99 | - ->setCellValue('D' . $i, "FaxNo $i") |
|
100 | - ->setCellValue('E' . $i, true); |
|
96 | + $objPHPExcel->getActiveSheet()->setCellValue('A' . $i, "FName $i") |
|
97 | + ->setCellValue('B' . $i, "LName $i") |
|
98 | + ->setCellValue('C' . $i, "PhoneNo $i") |
|
99 | + ->setCellValue('D' . $i, "FaxNo $i") |
|
100 | + ->setCellValue('E' . $i, true); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 |