@@ -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_AREACHART, // plotType |
|
93 | - \PHPExcel\Chart\DataSeries::GROUPING_PERCENT_STACKED, // plotGrouping |
|
94 | - range(0, count($dataSeriesValues)-1), // plotOrder |
|
95 | - $dataSeriesLabels, // plotLabel |
|
96 | - $xAxisTickValues, // plotCategory |
|
97 | - $dataSeriesValues // plotValues |
|
92 | + \PHPExcel\Chart\DataSeries::TYPE_AREACHART, // plotType |
|
93 | + \PHPExcel\Chart\DataSeries::GROUPING_PERCENT_STACKED, // plotGrouping |
|
94 | + range(0, count($dataSeriesValues)-1), // plotOrder |
|
95 | + $dataSeriesLabels, // plotLabel |
|
96 | + $xAxisTickValues, // plotCategory |
|
97 | + $dataSeriesValues // plotValues |
|
98 | 98 | ); |
99 | 99 | |
100 | 100 | // Set the series in the plot area |
@@ -108,14 +108,14 @@ discard block |
||
108 | 108 | |
109 | 109 | // Create the chart |
110 | 110 | $chart = new \PHPExcel\Chart( |
111 | - 'chart1', // name |
|
112 | - $title, // title |
|
113 | - $legend, // legend |
|
114 | - $plotArea, // plotArea |
|
115 | - true, // plotVisibleOnly |
|
116 | - 0, // displayBlanksAs |
|
117 | - NULL, // xAxisLabel |
|
118 | - $yAxisLabel // yAxisLabel |
|
111 | + 'chart1', // name |
|
112 | + $title, // title |
|
113 | + $legend, // legend |
|
114 | + $plotArea, // plotArea |
|
115 | + true, // plotVisibleOnly |
|
116 | + 0, // displayBlanksAs |
|
117 | + NULL, // xAxisLabel |
|
118 | + $yAxisLabel // yAxisLabel |
|
119 | 119 | ); |
120 | 120 | |
121 | 121 | // Set the position where the chart should appear in the worksheet |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | ini_set('display_startup_errors', TRUE); |
7 | 7 | date_default_timezone_set('Europe/London'); |
8 | 8 | |
9 | -define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />'); |
|
9 | +define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '<br />'); |
|
10 | 10 | |
11 | 11 | date_default_timezone_set('Europe/London'); |
12 | 12 | |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | $objWorksheet = $objPHPExcel->getActiveSheet(); |
45 | 45 | $objWorksheet->fromArray( |
46 | 46 | array( |
47 | - array('', 2010, 2011, 2012), |
|
48 | - array('Q1', 12, 15, 21), |
|
49 | - array('Q2', 56, 73, 86), |
|
50 | - array('Q3', 52, 61, 69), |
|
51 | - array('Q4', 30, 32, 0), |
|
47 | + array('', 2010, 2011, 2012), |
|
48 | + array('Q1', 12, 15, 21), |
|
49 | + array('Q2', 56, 73, 86), |
|
50 | + array('Q3', 52, 61, 69), |
|
51 | + array('Q4', 30, 32, 0), |
|
52 | 52 | ) |
53 | 53 | ); |
54 | 54 | |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | // Data values |
61 | 61 | // Data Marker |
62 | 62 | $dataSeriesLabels = array( |
63 | - new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // 2010 |
|
64 | - new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011 |
|
65 | - new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 2012 |
|
63 | + new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // 2010 |
|
64 | + new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011 |
|
65 | + new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 2012 |
|
66 | 66 | ); |
67 | 67 | // Set the X-Axis Labels |
68 | 68 | // Datatype |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | // Data values |
73 | 73 | // Data Marker |
74 | 74 | $xAxisTickValues = array( |
75 | - new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', NULL, 4), // Q1 to Q4 |
|
75 | + new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', NULL, 4), // Q1 to Q4 |
|
76 | 76 | ); |
77 | 77 | // Set the Data values for each data series we want to plot |
78 | 78 | // Datatype |
@@ -89,11 +89,11 @@ discard block |
||
89 | 89 | |
90 | 90 | // Build the dataseries |
91 | 91 | $series = new \PHPExcel\Chart\DataSeries( |
92 | - \PHPExcel\Chart\DataSeries::TYPE_AREACHART, // plotType |
|
93 | - \PHPExcel\Chart\DataSeries::GROUPING_PERCENT_STACKED, // plotGrouping |
|
94 | - range(0, count($dataSeriesValues)-1), // plotOrder |
|
95 | - $dataSeriesLabels, // plotLabel |
|
96 | - $xAxisTickValues, // plotCategory |
|
92 | + \PHPExcel\Chart\DataSeries::TYPE_AREACHART, // plotType |
|
93 | + \PHPExcel\Chart\DataSeries::GROUPING_PERCENT_STACKED, // plotGrouping |
|
94 | + range(0, count($dataSeriesValues) - 1), // plotOrder |
|
95 | + $dataSeriesLabels, // plotLabel |
|
96 | + $xAxisTickValues, // plotCategory |
|
97 | 97 | $dataSeriesValues // plotValues |
98 | 98 | ); |
99 | 99 | |
@@ -108,13 +108,13 @@ discard block |
||
108 | 108 | |
109 | 109 | // Create the chart |
110 | 110 | $chart = new \PHPExcel\Chart( |
111 | - 'chart1', // name |
|
112 | - $title, // title |
|
113 | - $legend, // legend |
|
114 | - $plotArea, // plotArea |
|
115 | - true, // plotVisibleOnly |
|
116 | - 0, // displayBlanksAs |
|
117 | - NULL, // xAxisLabel |
|
111 | + 'chart1', // name |
|
112 | + $title, // title |
|
113 | + $legend, // legend |
|
114 | + $plotArea, // plotArea |
|
115 | + true, // plotVisibleOnly |
|
116 | + 0, // displayBlanksAs |
|
117 | + NULL, // xAxisLabel |
|
118 | 118 | $yAxisLabel // yAxisLabel |
119 | 119 | ); |
120 | 120 | |
@@ -127,16 +127,16 @@ discard block |
||
127 | 127 | |
128 | 128 | |
129 | 129 | // Save Excel 2007 file |
130 | -echo date('H:i:s') , " Write to Excel2007 format" , EOL; |
|
130 | +echo date('H:i:s'), " Write to Excel2007 format", EOL; |
|
131 | 131 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007'); |
132 | 132 | $objWriter->setIncludeCharts(TRUE); |
133 | 133 | $objWriter->save(str_replace('.php', '.xlsx', __FILE__)); |
134 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
134 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
135 | 135 | |
136 | 136 | |
137 | 137 | // Echo memory peak usage |
138 | -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
138 | +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; |
|
139 | 139 | |
140 | 140 | // Echo done |
141 | -echo date('H:i:s') , " Done writing file" , EOL; |
|
142 | -echo 'File has been created in ' , getcwd() , EOL; |
|
141 | +echo date('H:i:s'), " Done writing file", EOL; |
|
142 | +echo 'File has been created in ', getcwd(), EOL; |
@@ -77,23 +77,23 @@ |
||
77 | 77 | // Export to PDF (.pdf) |
78 | 78 | echo date('H:i:s') , " Write to PDF format" , EOL; |
79 | 79 | try { |
80 | - if (!\PHPExcel\Settings::setPdfRenderer( |
|
81 | - $rendererName, |
|
82 | - $rendererLibraryPath |
|
83 | - )) { |
|
84 | - echo ( |
|
85 | - 'NOTICE: Please set the $rendererName and $rendererLibraryPath values' . |
|
86 | - EOL . |
|
87 | - 'at the top of this script as appropriate for your directory structure' . |
|
88 | - EOL |
|
89 | - ); |
|
90 | - } else { |
|
91 | - $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'PDF'); |
|
92 | - $objWriter->save(str_replace('.php', '.pdf', __FILE__)); |
|
93 | - echo date('H:i:s') , " File written to " , str_replace('.php', '.pdf', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
94 | - } |
|
80 | + if (!\PHPExcel\Settings::setPdfRenderer( |
|
81 | + $rendererName, |
|
82 | + $rendererLibraryPath |
|
83 | + )) { |
|
84 | + echo ( |
|
85 | + 'NOTICE: Please set the $rendererName and $rendererLibraryPath values' . |
|
86 | + EOL . |
|
87 | + 'at the top of this script as appropriate for your directory structure' . |
|
88 | + EOL |
|
89 | + ); |
|
90 | + } else { |
|
91 | + $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'PDF'); |
|
92 | + $objWriter->save(str_replace('.php', '.pdf', __FILE__)); |
|
93 | + echo date('H:i:s') , " File written to " , str_replace('.php', '.pdf', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
94 | + } |
|
95 | 95 | } catch (Exception $e) { |
96 | - echo date('H:i:s') , ' EXCEPTION: ', $e->getMessage() , EOL; |
|
96 | + echo date('H:i:s') , ' EXCEPTION: ', $e->getMessage() , EOL; |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | // Remove first two rows with field headers before exporting to CSV |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | ini_set('display_errors', TRUE); |
31 | 31 | ini_set('display_startup_errors', TRUE); |
32 | 32 | |
33 | -define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />'); |
|
33 | +define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '<br />'); |
|
34 | 34 | |
35 | 35 | date_default_timezone_set('Europe/London'); |
36 | 36 | |
@@ -50,32 +50,32 @@ discard block |
||
50 | 50 | |
51 | 51 | |
52 | 52 | // Read from Excel2007 (.xlsx) template |
53 | -echo date('H:i:s') , " Load Excel2007 template file" , EOL; |
|
53 | +echo date('H:i:s'), " Load Excel2007 template file", EOL; |
|
54 | 54 | $objReader = \PHPExcel\IOFactory::createReader('Excel2007'); |
55 | 55 | $objPHPExcel = $objReader->load("templates/26template.xlsx"); |
56 | 56 | |
57 | 57 | /** at this point, we could do some manipulations with the template, but we skip this step */ |
58 | 58 | |
59 | 59 | // Export to Excel2007 (.xlsx) |
60 | -echo date('H:i:s') , " Write to Excel5 format" , EOL; |
|
60 | +echo date('H:i:s'), " Write to Excel5 format", EOL; |
|
61 | 61 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007'); |
62 | 62 | $objWriter->save(str_replace('.php', '.xlsx', __FILE__)); |
63 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
63 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
64 | 64 | |
65 | 65 | // Export to Excel5 (.xls) |
66 | -echo date('H:i:s') , " Write to Excel5 format" , EOL; |
|
66 | +echo date('H:i:s'), " Write to Excel5 format", EOL; |
|
67 | 67 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5'); |
68 | 68 | $objWriter->save(str_replace('.php', '.xls', __FILE__)); |
69 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
69 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
70 | 70 | |
71 | 71 | // Export to HTML (.html) |
72 | -echo date('H:i:s') , " Write to HTML format" , EOL; |
|
72 | +echo date('H:i:s'), " Write to HTML format", EOL; |
|
73 | 73 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'HTML'); |
74 | 74 | $objWriter->save(str_replace('.php', '.htm', __FILE__)); |
75 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.htm', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
75 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.htm', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
76 | 76 | |
77 | 77 | // Export to PDF (.pdf) |
78 | -echo date('H:i:s') , " Write to PDF format" , EOL; |
|
78 | +echo date('H:i:s'), " Write to PDF format", EOL; |
|
79 | 79 | try { |
80 | 80 | if (!\PHPExcel\Settings::setPdfRenderer( |
81 | 81 | $rendererName, |
@@ -90,33 +90,33 @@ discard block |
||
90 | 90 | } else { |
91 | 91 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'PDF'); |
92 | 92 | $objWriter->save(str_replace('.php', '.pdf', __FILE__)); |
93 | - echo date('H:i:s') , " File written to " , str_replace('.php', '.pdf', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
93 | + echo date('H:i:s'), " File written to ", str_replace('.php', '.pdf', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
94 | 94 | } |
95 | 95 | } catch (Exception $e) { |
96 | - echo date('H:i:s') , ' EXCEPTION: ', $e->getMessage() , EOL; |
|
96 | + echo date('H:i:s'), ' EXCEPTION: ', $e->getMessage(), EOL; |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | // Remove first two rows with field headers before exporting to CSV |
100 | -echo date('H:i:s') , " Removing first two heading rows for CSV export" , EOL; |
|
100 | +echo date('H:i:s'), " Removing first two heading rows for CSV export", EOL; |
|
101 | 101 | $objWorksheet = $objPHPExcel->getActiveSheet(); |
102 | 102 | $objWorksheet->removeRow(1, 2); |
103 | 103 | |
104 | 104 | // Export to CSV (.csv) |
105 | -echo date('H:i:s') , " Write to CSV format" , EOL; |
|
105 | +echo date('H:i:s'), " Write to CSV format", EOL; |
|
106 | 106 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'CSV'); |
107 | 107 | $objWriter->save(str_replace('.php', '.csv', __FILE__)); |
108 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.csv', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
108 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.csv', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
109 | 109 | |
110 | 110 | // Export to CSV with BOM (.csv) |
111 | -echo date('H:i:s') , " Write to CSV format (with BOM)" , EOL; |
|
111 | +echo date('H:i:s'), " Write to CSV format (with BOM)", EOL; |
|
112 | 112 | $objWriter->setUseBOM(true); |
113 | 113 | $objWriter->save(str_replace('.php', '-bom.csv', __FILE__)); |
114 | -echo date('H:i:s') , " File written to " , str_replace('.php', '-bom.csv', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
114 | +echo date('H:i:s'), " File written to ", str_replace('.php', '-bom.csv', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
115 | 115 | |
116 | 116 | |
117 | 117 | // Echo memory peak usage |
118 | -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
118 | +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; |
|
119 | 119 | |
120 | 120 | // Echo done |
121 | -echo date('H:i:s') , " Done writing files" , EOL; |
|
122 | -echo 'Files have been created in ' , getcwd() , EOL; |
|
121 | +echo date('H:i:s'), " Done writing files", EOL; |
|
122 | +echo 'Files have been created in ', getcwd(), EOL; |
@@ -52,12 +52,12 @@ discard block |
||
52 | 52 | // Set document properties |
53 | 53 | echo date('H:i:s') , " Set properties" , EOL; |
54 | 54 | $objPHPExcel->getProperties()->setCreator("Maarten Balliauw") |
55 | - ->setLastModifiedBy("Maarten Balliauw") |
|
56 | - ->setTitle("Office 2007 XLSX Test Document") |
|
57 | - ->setSubject("Office 2007 XLSX Test Document") |
|
58 | - ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.") |
|
59 | - ->setKeywords("office 2007 openxml php") |
|
60 | - ->setCategory("Test result file"); |
|
55 | + ->setLastModifiedBy("Maarten Balliauw") |
|
56 | + ->setTitle("Office 2007 XLSX Test Document") |
|
57 | + ->setSubject("Office 2007 XLSX Test Document") |
|
58 | + ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.") |
|
59 | + ->setKeywords("office 2007 openxml php") |
|
60 | + ->setCategory("Test result file"); |
|
61 | 61 | |
62 | 62 | |
63 | 63 | // Create a first sheet |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | // Set outline levels |
80 | 80 | echo date('H:i:s') , " Set outline levels" , EOL; |
81 | 81 | $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setOutlineLevel(1) |
82 | - ->setVisible(false) |
|
83 | - ->setCollapsed(true); |
|
82 | + ->setVisible(false) |
|
83 | + ->setCollapsed(true); |
|
84 | 84 | |
85 | 85 | // Freeze panes |
86 | 86 | echo date('H:i:s') , " Freeze panes" , EOL; |
@@ -94,11 +94,11 @@ discard block |
||
94 | 94 | |
95 | 95 | // Add data |
96 | 96 | for ($i = 2; $i <= 5000; $i++) { |
97 | - $objPHPExcel->getActiveSheet()->setCellValue('A' . $i, "FName $i") |
|
98 | - ->setCellValue('B' . $i, "LName $i") |
|
99 | - ->setCellValue('C' . $i, "PhoneNo $i") |
|
100 | - ->setCellValue('D' . $i, "FaxNo $i") |
|
101 | - ->setCellValue('E' . $i, true); |
|
97 | + $objPHPExcel->getActiveSheet()->setCellValue('A' . $i, "FName $i") |
|
98 | + ->setCellValue('B' . $i, "LName $i") |
|
99 | + ->setCellValue('C' . $i, "PhoneNo $i") |
|
100 | + ->setCellValue('D' . $i, "FaxNo $i") |
|
101 | + ->setCellValue('E' . $i, true); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | ini_set('display_errors', TRUE); |
31 | 31 | ini_set('display_startup_errors', TRUE); |
32 | 32 | |
33 | -define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />'); |
|
33 | +define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '<br />'); |
|
34 | 34 | |
35 | 35 | date_default_timezone_set('Europe/London'); |
36 | 36 | |
@@ -39,18 +39,18 @@ discard block |
||
39 | 39 | |
40 | 40 | $cacheMethod = \PHPExcel\CachedObjectStorageFactory::CACHE_TO_SQLITE; |
41 | 41 | if (\PHPExcel\Settings::setCacheStorageMethod($cacheMethod)) { |
42 | - echo date('H:i:s') , " Enable Cell Caching using " , $cacheMethod , " method" , EOL; |
|
42 | + echo date('H:i:s'), " Enable Cell Caching using ", $cacheMethod, " method", EOL; |
|
43 | 43 | } else { |
44 | - echo date('H:i:s') , " Unable to set Cell Caching using " , $cacheMethod , " method, reverting to memory" , EOL; |
|
44 | + echo date('H:i:s'), " Unable to set Cell Caching using ", $cacheMethod, " method, reverting to memory", EOL; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | |
48 | 48 | // Create new PHPExcel object |
49 | -echo date('H:i:s') , " Create new PHPExcel object" , EOL; |
|
49 | +echo date('H:i:s'), " Create new PHPExcel object", EOL; |
|
50 | 50 | $objPHPExcel = new \PHPExcel\Spreadsheet(); |
51 | 51 | |
52 | 52 | // Set document properties |
53 | -echo date('H:i:s') , " Set properties" , EOL; |
|
53 | +echo date('H:i:s'), " Set properties", EOL; |
|
54 | 54 | $objPHPExcel->getProperties()->setCreator("Maarten Balliauw") |
55 | 55 | ->setLastModifiedBy("Maarten Balliauw") |
56 | 56 | ->setTitle("Office 2007 XLSX Test Document") |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | |
63 | 63 | // Create a first sheet |
64 | -echo date('H:i:s') , " Add data" , EOL; |
|
64 | +echo date('H:i:s'), " Add data", EOL; |
|
65 | 65 | $objPHPExcel->setActiveSheetIndex(0); |
66 | 66 | $objPHPExcel->getActiveSheet()->setCellValue('A1', "Firstname"); |
67 | 67 | $objPHPExcel->getActiveSheet()->setCellValue('B1', "Lastname"); |
@@ -71,24 +71,24 @@ discard block |
||
71 | 71 | |
72 | 72 | |
73 | 73 | // Hide "Phone" and "fax" column |
74 | -echo date('H:i:s') , " Hide 'Phone' and 'fax' columns" , EOL; |
|
74 | +echo date('H:i:s'), " Hide 'Phone' and 'fax' columns", EOL; |
|
75 | 75 | $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setVisible(false); |
76 | 76 | $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setVisible(false); |
77 | 77 | |
78 | 78 | |
79 | 79 | // Set outline levels |
80 | -echo date('H:i:s') , " Set outline levels" , EOL; |
|
80 | +echo date('H:i:s'), " Set outline levels", EOL; |
|
81 | 81 | $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setOutlineLevel(1) |
82 | 82 | ->setVisible(false) |
83 | 83 | ->setCollapsed(true); |
84 | 84 | |
85 | 85 | // Freeze panes |
86 | -echo date('H:i:s') , " Freeze panes" , EOL; |
|
86 | +echo date('H:i:s'), " Freeze panes", EOL; |
|
87 | 87 | $objPHPExcel->getActiveSheet()->freezePane('A2'); |
88 | 88 | |
89 | 89 | |
90 | 90 | // Rows to repeat at top |
91 | -echo date('H:i:s') , " Rows to repeat at top" , EOL; |
|
91 | +echo date('H:i:s'), " Rows to repeat at top", EOL; |
|
92 | 92 | $objPHPExcel->getActiveSheet()->getPageSetup()->setRowsToRepeatAtTopByStartAndEnd(1, 1); |
93 | 93 | |
94 | 94 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | |
108 | 108 | |
109 | 109 | // Save Excel 2007 file |
110 | -echo date('H:i:s') , " Write to Excel2007 format" , EOL; |
|
110 | +echo date('H:i:s'), " Write to Excel2007 format", EOL; |
|
111 | 111 | $callStartTime = microtime(true); |
112 | 112 | |
113 | 113 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007'); |
@@ -115,15 +115,15 @@ discard block |
||
115 | 115 | $callEndTime = microtime(true); |
116 | 116 | $callTime = $callEndTime - $callStartTime; |
117 | 117 | |
118 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
119 | -echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL; |
|
118 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
119 | +echo 'Call time to write Workbook was ', sprintf('%.4f', $callTime), " seconds", EOL; |
|
120 | 120 | // Echo memory usage |
121 | -echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
121 | +echo date('H:i:s'), ' Current memory usage: ', (memory_get_usage(true) / 1024 / 1024), " MB", EOL; |
|
122 | 122 | |
123 | 123 | |
124 | 124 | // Echo memory peak usage |
125 | -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
125 | +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; |
|
126 | 126 | |
127 | 127 | // Echo done |
128 | -echo date('H:i:s') , " Done writing file" , EOL; |
|
129 | -echo 'File has been created in ' , getcwd() , EOL; |
|
128 | +echo date('H:i:s'), " Done writing file", EOL; |
|
129 | +echo 'File has been created in ', getcwd(), EOL; |
@@ -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_CLUSTERED, // 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_CLUSTERED, // plotGrouping |
|
94 | + range(0, count($dataSeriesValues)-1), // plotOrder |
|
95 | + $dataSeriesLabels, // plotLabel |
|
96 | + $xAxisTickValues, // plotCategory |
|
97 | + $dataSeriesValues // plotValues |
|
98 | 98 | ); |
99 | 99 | // Set additional dataseries parameters |
100 | 100 | // Make it a horizontal bar rather than a vertical column graph |
@@ -111,14 +111,14 @@ discard block |
||
111 | 111 | |
112 | 112 | // Create the chart |
113 | 113 | $chart = new \PHPExcel\Chart( |
114 | - 'chart1', // name |
|
115 | - $title, // title |
|
116 | - $legend, // legend |
|
117 | - $plotArea, // plotArea |
|
118 | - true, // plotVisibleOnly |
|
119 | - 0, // displayBlanksAs |
|
120 | - NULL, // xAxisLabel |
|
121 | - $yAxisLabel // yAxisLabel |
|
114 | + 'chart1', // name |
|
115 | + $title, // title |
|
116 | + $legend, // legend |
|
117 | + $plotArea, // plotArea |
|
118 | + true, // plotVisibleOnly |
|
119 | + 0, // displayBlanksAs |
|
120 | + NULL, // xAxisLabel |
|
121 | + $yAxisLabel // yAxisLabel |
|
122 | 122 | ); |
123 | 123 | |
124 | 124 | // Set the position where the chart should appear in the worksheet |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | ini_set('display_startup_errors', TRUE); |
7 | 7 | date_default_timezone_set('Europe/London'); |
8 | 8 | |
9 | -define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />'); |
|
9 | +define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '<br />'); |
|
10 | 10 | |
11 | 11 | date_default_timezone_set('Europe/London'); |
12 | 12 | |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | $objWorksheet = $objPHPExcel->getActiveSheet(); |
45 | 45 | $objWorksheet->fromArray( |
46 | 46 | array( |
47 | - array('', 2010, 2011, 2012), |
|
48 | - array('Q1', 12, 15, 21), |
|
49 | - array('Q2', 56, 73, 86), |
|
50 | - array('Q3', 52, 61, 69), |
|
51 | - array('Q4', 30, 32, 0), |
|
47 | + array('', 2010, 2011, 2012), |
|
48 | + array('Q1', 12, 15, 21), |
|
49 | + array('Q2', 56, 73, 86), |
|
50 | + array('Q3', 52, 61, 69), |
|
51 | + array('Q4', 30, 32, 0), |
|
52 | 52 | ) |
53 | 53 | ); |
54 | 54 | |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | // Data values |
61 | 61 | // Data Marker |
62 | 62 | $dataSeriesLabels = array( |
63 | - new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // 2010 |
|
64 | - new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011 |
|
65 | - new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 2012 |
|
63 | + new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // 2010 |
|
64 | + new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011 |
|
65 | + new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 2012 |
|
66 | 66 | ); |
67 | 67 | // Set the X-Axis Labels |
68 | 68 | // Datatype |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | // Data values |
73 | 73 | // Data Marker |
74 | 74 | $xAxisTickValues = array( |
75 | - new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', NULL, 4), // Q1 to Q4 |
|
75 | + new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', NULL, 4), // Q1 to Q4 |
|
76 | 76 | ); |
77 | 77 | // Set the Data values for each data series we want to plot |
78 | 78 | // Datatype |
@@ -89,11 +89,11 @@ discard block |
||
89 | 89 | |
90 | 90 | // Build the dataseries |
91 | 91 | $series = new \PHPExcel\Chart\DataSeries( |
92 | - \PHPExcel\Chart\DataSeries::TYPE_BARCHART, // plotType |
|
93 | - \PHPExcel\Chart\DataSeries::GROUPING_CLUSTERED, // plotGrouping |
|
94 | - range(0, count($dataSeriesValues)-1), // plotOrder |
|
95 | - $dataSeriesLabels, // plotLabel |
|
96 | - $xAxisTickValues, // plotCategory |
|
92 | + \PHPExcel\Chart\DataSeries::TYPE_BARCHART, // plotType |
|
93 | + \PHPExcel\Chart\DataSeries::GROUPING_CLUSTERED, // plotGrouping |
|
94 | + range(0, count($dataSeriesValues) - 1), // plotOrder |
|
95 | + $dataSeriesLabels, // plotLabel |
|
96 | + $xAxisTickValues, // plotCategory |
|
97 | 97 | $dataSeriesValues // plotValues |
98 | 98 | ); |
99 | 99 | // Set additional dataseries parameters |
@@ -111,13 +111,13 @@ discard block |
||
111 | 111 | |
112 | 112 | // Create the chart |
113 | 113 | $chart = new \PHPExcel\Chart( |
114 | - 'chart1', // name |
|
115 | - $title, // title |
|
116 | - $legend, // legend |
|
117 | - $plotArea, // plotArea |
|
118 | - true, // plotVisibleOnly |
|
119 | - 0, // displayBlanksAs |
|
120 | - NULL, // xAxisLabel |
|
114 | + 'chart1', // name |
|
115 | + $title, // title |
|
116 | + $legend, // legend |
|
117 | + $plotArea, // plotArea |
|
118 | + true, // plotVisibleOnly |
|
119 | + 0, // displayBlanksAs |
|
120 | + NULL, // xAxisLabel |
|
121 | 121 | $yAxisLabel // yAxisLabel |
122 | 122 | ); |
123 | 123 | |
@@ -130,16 +130,16 @@ discard block |
||
130 | 130 | |
131 | 131 | |
132 | 132 | // Save Excel 2007 file |
133 | -echo date('H:i:s') , " Write to Excel2007 format" , EOL; |
|
133 | +echo date('H:i:s'), " Write to Excel2007 format", EOL; |
|
134 | 134 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007'); |
135 | 135 | $objWriter->setIncludeCharts(TRUE); |
136 | 136 | $objWriter->save(str_replace('.php', '.xlsx', __FILE__)); |
137 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
137 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
138 | 138 | |
139 | 139 | |
140 | 140 | // Echo memory peak usage |
141 | -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
141 | +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; |
|
142 | 142 | |
143 | 143 | // Echo done |
144 | -echo date('H:i:s') , " Done writing file" , EOL; |
|
145 | -echo 'File has been created in ' , getcwd() , EOL; |
|
144 | +echo date('H:i:s'), " Done writing file", EOL; |
|
145 | +echo 'File has been created in ', getcwd(), EOL; |
@@ -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("PHPOffice") |
47 | - ->setLastModifiedBy("PHPOffice") |
|
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("PHPOffice") |
|
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 |
@@ -31,18 +31,18 @@ discard block |
||
31 | 31 | ini_set('display_startup_errors', TRUE); |
32 | 32 | date_default_timezone_set('Europe/London'); |
33 | 33 | |
34 | -define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />'); |
|
34 | +define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '<br />'); |
|
35 | 35 | |
36 | 36 | /** Include PHPExcel */ |
37 | 37 | require_once dirname(__FILE__) . '/../src/Bootstrap.php'; |
38 | 38 | |
39 | 39 | |
40 | 40 | // Create new PHPExcel object |
41 | -echo date('H:i:s') , " Create new PHPExcel object" , EOL; |
|
41 | +echo date('H:i:s'), " Create new PHPExcel object", EOL; |
|
42 | 42 | $objPHPExcel = new \PHPExcel\Spreadsheet(); |
43 | 43 | |
44 | 44 | // Set document properties |
45 | -echo date('H:i:s') , " Set document properties" , EOL; |
|
45 | +echo date('H:i:s'), " Set document properties", EOL; |
|
46 | 46 | $objPHPExcel->getProperties()->setCreator("PHPOffice") |
47 | 47 | ->setLastModifiedBy("PHPOffice") |
48 | 48 | ->setTitle("PHPExcel Test Document") |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | |
54 | 54 | |
55 | 55 | // Add some data |
56 | -echo date('H:i:s') , " Add some data" , EOL; |
|
56 | +echo date('H:i:s'), " Add some data", EOL; |
|
57 | 57 | $objPHPExcel->setActiveSheetIndex(0) |
58 | 58 | ->setCellValue('A1', 'Hello') |
59 | 59 | ->setCellValue('B2', 'world!'); |
@@ -65,19 +65,19 @@ discard block |
||
65 | 65 | $objPHPExcel->getActiveSheet()->getSheetView()->setView(PHPExcel\Worksheet\SheetView::SHEETVIEW_PAGE_LAYOUT); |
66 | 66 | |
67 | 67 | // Save Excel 2007 file |
68 | -echo date('H:i:s') , " Write to Excel2007 format" , EOL; |
|
68 | +echo date('H:i:s'), " Write to Excel2007 format", EOL; |
|
69 | 69 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007'); |
70 | 70 | $objWriter->save(str_replace('.php', '.xlsx', __FILE__)); |
71 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
71 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
72 | 72 | // Save Excel5 file |
73 | -echo date('H:i:s') , " Write to Excel5 format" , EOL; |
|
73 | +echo date('H:i:s'), " Write to Excel5 format", EOL; |
|
74 | 74 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5'); |
75 | 75 | $objWriter->save(str_replace('.php', '.xls', __FILE__)); |
76 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
76 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
77 | 77 | |
78 | 78 | // Echo memory peak usage |
79 | -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
79 | +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; |
|
80 | 80 | |
81 | 81 | // Echo done |
82 | -echo date('H:i:s') , " Done writing files" , EOL; |
|
83 | -echo 'Files have been created in ' , getcwd() , EOL; |
|
82 | +echo date('H:i:s'), " Done writing files", EOL; |
|
83 | +echo 'Files have been created in ', getcwd(), EOL; |
@@ -44,12 +44,12 @@ |
||
44 | 44 | // Set document properties |
45 | 45 | echo date('H:i:s') , " Set document properties" , EOL; |
46 | 46 | $objPHPExcel->getProperties()->setCreator("Maarten Balliauw") |
47 | - ->setLastModifiedBy("Maarten Balliauw") |
|
48 | - ->setTitle("PHPExcel Test Document") |
|
49 | - ->setSubject("PHPExcel Test Document") |
|
50 | - ->setDescription("Test document for PHPExcel, generated using PHP classes.") |
|
51 | - ->setKeywords("office PHPExcel php") |
|
52 | - ->setCategory("Test result file"); |
|
47 | + ->setLastModifiedBy("Maarten Balliauw") |
|
48 | + ->setTitle("PHPExcel Test Document") |
|
49 | + ->setSubject("PHPExcel Test Document") |
|
50 | + ->setDescription("Test document for PHPExcel, generated using PHP classes.") |
|
51 | + ->setKeywords("office PHPExcel php") |
|
52 | + ->setCategory("Test result file"); |
|
53 | 53 | |
54 | 54 | |
55 | 55 | // Add some data |
@@ -31,18 +31,18 @@ discard block |
||
31 | 31 | ini_set('display_startup_errors', TRUE); |
32 | 32 | date_default_timezone_set('Europe/London'); |
33 | 33 | |
34 | -define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />'); |
|
34 | +define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '<br />'); |
|
35 | 35 | |
36 | 36 | /** Include PHPExcel */ |
37 | 37 | require_once dirname(__FILE__) . '/../src/Bootstrap.php'; |
38 | 38 | |
39 | 39 | |
40 | 40 | // Create new PHPExcel object |
41 | -echo date('H:i:s') , " Create new PHPExcel object" , EOL; |
|
41 | +echo date('H:i:s'), " Create new PHPExcel object", EOL; |
|
42 | 42 | $objPHPExcel = new \PHPExcel\Spreadsheet(); |
43 | 43 | |
44 | 44 | // Set document properties |
45 | -echo date('H:i:s') , " Set document properties" , EOL; |
|
45 | +echo date('H:i:s'), " Set document properties", EOL; |
|
46 | 46 | $objPHPExcel->getProperties()->setCreator("Maarten Balliauw") |
47 | 47 | ->setLastModifiedBy("Maarten Balliauw") |
48 | 48 | ->setTitle("PHPExcel Test Document") |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | |
54 | 54 | |
55 | 55 | // Add some data |
56 | -echo date('H:i:s') , " Add some data" , EOL; |
|
56 | +echo date('H:i:s'), " Add some data", EOL; |
|
57 | 57 | |
58 | 58 | $html1 = '<font color="#0000ff"> |
59 | 59 | <h1 align="center">My very first example of rich text<br />generated from html markup</h1> |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | |
126 | 126 | // Rename worksheet |
127 | -echo date('H:i:s') , " Rename worksheet" , EOL; |
|
127 | +echo date('H:i:s'), " Rename worksheet", EOL; |
|
128 | 128 | $objPHPExcel->getActiveSheet() |
129 | 129 | ->setTitle('Rich Text Examples'); |
130 | 130 | |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | |
135 | 135 | |
136 | 136 | // Save Excel 2007 file |
137 | -echo date('H:i:s') , " Write to Excel2007 format" , EOL; |
|
137 | +echo date('H:i:s'), " Write to Excel2007 format", EOL; |
|
138 | 138 | $callStartTime = microtime(true); |
139 | 139 | |
140 | 140 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007'); |
@@ -142,14 +142,14 @@ discard block |
||
142 | 142 | $callEndTime = microtime(true); |
143 | 143 | $callTime = $callEndTime - $callStartTime; |
144 | 144 | |
145 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
146 | -echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL; |
|
145 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
146 | +echo 'Call time to write Workbook was ', sprintf('%.4f', $callTime), " seconds", EOL; |
|
147 | 147 | // Echo memory usage |
148 | -echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
148 | +echo date('H:i:s'), ' Current memory usage: ', (memory_get_usage(true) / 1024 / 1024), " MB", EOL; |
|
149 | 149 | |
150 | 150 | |
151 | 151 | // Save Excel 95 file |
152 | -echo date('H:i:s') , " Write to Excel5 format" , EOL; |
|
152 | +echo date('H:i:s'), " Write to Excel5 format", EOL; |
|
153 | 153 | $callStartTime = microtime(true); |
154 | 154 | |
155 | 155 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5'); |
@@ -157,15 +157,15 @@ discard block |
||
157 | 157 | $callEndTime = microtime(true); |
158 | 158 | $callTime = $callEndTime - $callStartTime; |
159 | 159 | |
160 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
161 | -echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL; |
|
160 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
161 | +echo 'Call time to write Workbook was ', sprintf('%.4f', $callTime), " seconds", EOL; |
|
162 | 162 | // Echo memory usage |
163 | -echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
163 | +echo date('H:i:s'), ' Current memory usage: ', (memory_get_usage(true) / 1024 / 1024), " MB", EOL; |
|
164 | 164 | |
165 | 165 | |
166 | 166 | // Echo memory peak usage |
167 | -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
167 | +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; |
|
168 | 168 | |
169 | 169 | // Echo done |
170 | -echo date('H:i:s') , " Done writing files" , EOL; |
|
171 | -echo 'Files have been created in ' , getcwd() , EOL; |
|
170 | +echo date('H:i:s'), " Done writing files", EOL; |
|
171 | +echo 'Files have been created in ', getcwd(), EOL; |
@@ -45,12 +45,12 @@ |
||
45 | 45 | echo date('H:i:s') , " Set document properties" , EOL; |
46 | 46 | $objPHPExcel->getProperties() |
47 | 47 | ->setCreator("PHPOffice") |
48 | - ->setLastModifiedBy("PHPOffice") |
|
49 | - ->setTitle("PHPExcel Test Document") |
|
50 | - ->setSubject("PHPExcel Test Document") |
|
51 | - ->setDescription("Test document for PHPExcel, generated using PHP classes.") |
|
52 | - ->setKeywords("Office PHPExcel php") |
|
53 | - ->setCategory("Test result file"); |
|
48 | + ->setLastModifiedBy("PHPOffice") |
|
49 | + ->setTitle("PHPExcel Test Document") |
|
50 | + ->setSubject("PHPExcel Test Document") |
|
51 | + ->setDescription("Test document for PHPExcel, generated using PHP classes.") |
|
52 | + ->setKeywords("Office PHPExcel php") |
|
53 | + ->setCategory("Test result file"); |
|
54 | 54 | |
55 | 55 | |
56 | 56 | function transpose($value) { |
@@ -31,18 +31,18 @@ discard block |
||
31 | 31 | ini_set('display_startup_errors', TRUE); |
32 | 32 | date_default_timezone_set('Europe/London'); |
33 | 33 | |
34 | -define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />'); |
|
34 | +define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '<br />'); |
|
35 | 35 | |
36 | 36 | /** Include PHPExcel */ |
37 | 37 | require_once dirname(__FILE__) . '/../src/Bootstrap.php'; |
38 | 38 | |
39 | 39 | |
40 | 40 | // Create new PHPExcel object |
41 | -echo date('H:i:s') , " Create new PHPExcel object" , EOL; |
|
41 | +echo date('H:i:s'), " Create new PHPExcel object", EOL; |
|
42 | 42 | $objPHPExcel = new \PHPExcel\Spreadsheet(); |
43 | 43 | |
44 | 44 | // Set document properties |
45 | -echo date('H:i:s') , " Set document properties" , EOL; |
|
45 | +echo date('H:i:s'), " Set document properties", EOL; |
|
46 | 46 | $objPHPExcel->getProperties() |
47 | 47 | ->setCreator("PHPOffice") |
48 | 48 | ->setLastModifiedBy("PHPOffice") |
@@ -62,10 +62,10 @@ discard block |
||
62 | 62 | $column = 'F'; |
63 | 63 | |
64 | 64 | // Set data for dropdowns |
65 | -foreach(glob('./data/continents/*') as $key => $filename) { |
|
65 | +foreach (glob('./data/continents/*') as $key => $filename) { |
|
66 | 66 | $continent = pathinfo($filename, PATHINFO_FILENAME); |
67 | 67 | echo "Loading $continent", EOL; |
68 | - $continent = str_replace(' ','_',$continent); |
|
68 | + $continent = str_replace(' ', '_', $continent); |
|
69 | 69 | $countries = file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
70 | 70 | $countryCount = count($countries); |
71 | 71 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | ->setVisible(false); |
85 | 85 | |
86 | 86 | $objPHPExcel->getActiveSheet() |
87 | - ->setCellValue($continentColumn . ($key+1), $continent); |
|
87 | + ->setCellValue($continentColumn . ($key + 1), $continent); |
|
88 | 88 | |
89 | 89 | ++$column; |
90 | 90 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | $objPHPExcel->addNamedRange( |
98 | 98 | new PHPExcel\NamedRange( |
99 | 99 | 'Continents', |
100 | - $objPHPExcel->getActiveSheet(), $continentColumn . '1:' . $continentColumn . ($key+1) |
|
100 | + $objPHPExcel->getActiveSheet(), $continentColumn . '1:' . $continentColumn . ($key + 1) |
|
101 | 101 | ) |
102 | 102 | ); |
103 | 103 | |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | $objValidation = $objPHPExcel->getActiveSheet() |
120 | 120 | ->getCell('B1') |
121 | 121 | ->getDataValidation(); |
122 | -$objValidation->setType( PHPExcel\Cell\DataValidation::TYPE_LIST ) |
|
123 | - ->setErrorStyle( PHPExcel\Cell\DataValidation::STYLE_INFORMATION ) |
|
122 | +$objValidation->setType(PHPExcel\Cell\DataValidation::TYPE_LIST) |
|
123 | + ->setErrorStyle(PHPExcel\Cell\DataValidation::STYLE_INFORMATION) |
|
124 | 124 | ->setAllowBlank(false) |
125 | 125 | ->setShowInputMessage(true) |
126 | 126 | ->setShowErrorMessage(true) |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | $objValidation = $objPHPExcel->getActiveSheet() |
141 | 141 | ->getCell('B3') |
142 | 142 | ->getDataValidation(); |
143 | -$objValidation->setType( PHPExcel\Cell\DataValidation::TYPE_LIST ) |
|
144 | - ->setErrorStyle( PHPExcel\Cell\DataValidation::STYLE_INFORMATION ) |
|
143 | +$objValidation->setType(PHPExcel\Cell\DataValidation::TYPE_LIST) |
|
144 | + ->setErrorStyle(PHPExcel\Cell\DataValidation::STYLE_INFORMATION) |
|
145 | 145 | ->setAllowBlank(false) |
146 | 146 | ->setShowInputMessage(true) |
147 | 147 | ->setShowErrorMessage(true) |
@@ -162,14 +162,14 @@ discard block |
||
162 | 162 | |
163 | 163 | // Save Excel 2007 file |
164 | 164 | // This linked validation list method only seems to work for Excel2007, not for Excel5 |
165 | -echo date('H:i:s') , " Write to Excel2007 format" , EOL; |
|
165 | +echo date('H:i:s'), " Write to Excel2007 format", EOL; |
|
166 | 166 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007'); |
167 | 167 | $objWriter->save(str_replace('.php', '.xlsx', __FILE__)); |
168 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; |
|
168 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL; |
|
169 | 169 | |
170 | 170 | // Echo memory peak usage |
171 | -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; |
|
171 | +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; |
|
172 | 172 | |
173 | 173 | // Echo done |
174 | -echo date('H:i:s') , " Done writing files" , EOL; |
|
175 | -echo 'Files have been created in ' , getcwd() , EOL; |
|
174 | +echo date('H:i:s'), " Done writing files", EOL; |
|
175 | +echo 'Files have been created in ', getcwd(), EOL; |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | /** \PHPExcel\IOFactory */ |
34 | 34 | require_once dirname(__FILE__) . '/../Classes/PHPExcel/IOFactory.php'; |
35 | 35 | |
36 | -echo date('H:i:s') , " Load from Gnumeric file" , PHP_EOL; |
|
36 | +echo date('H:i:s'), " Load from Gnumeric file", PHP_EOL; |
|
37 | 37 | $callStartTime = microtime(true); |
38 | 38 | |
39 | 39 | $objReader = \PHPExcel\IOFactory::createReader('Gnumeric'); |
@@ -42,19 +42,19 @@ discard block |
||
42 | 42 | |
43 | 43 | $callEndTime = microtime(true); |
44 | 44 | $callTime = $callEndTime - $callStartTime; |
45 | -echo 'Call time to read Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , PHP_EOL; |
|
45 | +echo 'Call time to read Workbook was ', sprintf('%.4f', $callTime), " seconds", PHP_EOL; |
|
46 | 46 | // Echo memory usage |
47 | -echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , PHP_EOL; |
|
47 | +echo date('H:i:s'), ' Current memory usage: ', (memory_get_usage(true) / 1024 / 1024), " MB", PHP_EOL; |
|
48 | 48 | |
49 | 49 | |
50 | -echo date('H:i:s') , " Write to Excel2007 format" , PHP_EOL; |
|
50 | +echo date('H:i:s'), " Write to Excel2007 format", PHP_EOL; |
|
51 | 51 | $objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007'); |
52 | 52 | $objWriter->save(str_replace('.php', '.xlsx', __FILE__)); |
53 | -echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', __FILE__) , PHP_EOL; |
|
53 | +echo date('H:i:s'), " File written to ", str_replace('.php', '.xlsx', __FILE__), PHP_EOL; |
|
54 | 54 | |
55 | 55 | |
56 | 56 | // Echo memory peak usage |
57 | -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL; |
|
57 | +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", PHP_EOL; |
|
58 | 58 | |
59 | 59 | // Echo done |
60 | -echo date('H:i:s') , " Done writing file" , PHP_EOL; |
|
60 | +echo date('H:i:s'), " Done writing file", PHP_EOL; |
@@ -33,33 +33,33 @@ |
||
33 | 33 | <?php |
34 | 34 | /** If the user has submitted the form, then we need to execute a calculation **/ |
35 | 35 | if (isset($_POST['submit'])) { |
36 | - if ($_POST['A'] == 0) { |
|
37 | - echo 'The equation is not quadratic'; |
|
38 | - } else { |
|
39 | - /** So we include PHPExcel to perform the calculations **/ |
|
40 | - include 'PHPExcel/IOFactory.php'; |
|
36 | + if ($_POST['A'] == 0) { |
|
37 | + echo 'The equation is not quadratic'; |
|
38 | + } else { |
|
39 | + /** So we include PHPExcel to perform the calculations **/ |
|
40 | + include 'PHPExcel/IOFactory.php'; |
|
41 | 41 | |
42 | - /** Load the quadratic equation solver worksheet into memory **/ |
|
43 | - $objPHPExcel = \PHPExcel\IOFactory::load('./Quadratic.xlsx'); |
|
42 | + /** Load the quadratic equation solver worksheet into memory **/ |
|
43 | + $objPHPExcel = \PHPExcel\IOFactory::load('./Quadratic.xlsx'); |
|
44 | 44 | |
45 | - /** Set our A, B and C values **/ |
|
46 | - $objPHPExcel->getActiveSheet()->setCellValue('A1', $_POST['A']); |
|
47 | - $objPHPExcel->getActiveSheet()->setCellValue('B1', $_POST['B']); |
|
48 | - $objPHPExcel->getActiveSheet()->setCellValue('C1', $_POST['C']); |
|
45 | + /** Set our A, B and C values **/ |
|
46 | + $objPHPExcel->getActiveSheet()->setCellValue('A1', $_POST['A']); |
|
47 | + $objPHPExcel->getActiveSheet()->setCellValue('B1', $_POST['B']); |
|
48 | + $objPHPExcel->getActiveSheet()->setCellValue('C1', $_POST['C']); |
|
49 | 49 | |
50 | 50 | |
51 | - /** Calculate and Display the results **/ |
|
52 | - echo '<hr /><b>Roots:</b><br />'; |
|
51 | + /** Calculate and Display the results **/ |
|
52 | + echo '<hr /><b>Roots:</b><br />'; |
|
53 | 53 | |
54 | - $callStartTime = microtime(true); |
|
55 | - echo $objPHPExcel->getActiveSheet()->getCell('B5')->getCalculatedValue().'<br />'; |
|
56 | - echo $objPHPExcel->getActiveSheet()->getCell('B6')->getCalculatedValue().'<br />'; |
|
57 | - $callEndTime = microtime(true); |
|
58 | - $callTime = $callEndTime - $callStartTime; |
|
54 | + $callStartTime = microtime(true); |
|
55 | + echo $objPHPExcel->getActiveSheet()->getCell('B5')->getCalculatedValue().'<br />'; |
|
56 | + echo $objPHPExcel->getActiveSheet()->getCell('B6')->getCalculatedValue().'<br />'; |
|
57 | + $callEndTime = microtime(true); |
|
58 | + $callTime = $callEndTime - $callStartTime; |
|
59 | 59 | |
60 | - echo '<hr />Call time for Quadratic Equation Solution was '.sprintf('%.4f',$callTime).' seconds<br /><hr />'; |
|
61 | - echo ' Peak memory usage: '.(memory_get_peak_usage(true) / 1024 / 1024).' MB<br />'; |
|
62 | - } |
|
60 | + echo '<hr />Call time for Quadratic Equation Solution was '.sprintf('%.4f',$callTime).' seconds<br /><hr />'; |
|
61 | + echo ' Peak memory usage: '.(memory_get_peak_usage(true) / 1024 / 1024).' MB<br />'; |
|
62 | + } |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | ?> |
@@ -52,13 +52,13 @@ |
||
52 | 52 | echo '<hr /><b>Roots:</b><br />'; |
53 | 53 | |
54 | 54 | $callStartTime = microtime(true); |
55 | - echo $objPHPExcel->getActiveSheet()->getCell('B5')->getCalculatedValue().'<br />'; |
|
56 | - echo $objPHPExcel->getActiveSheet()->getCell('B6')->getCalculatedValue().'<br />'; |
|
55 | + echo $objPHPExcel->getActiveSheet()->getCell('B5')->getCalculatedValue() . '<br />'; |
|
56 | + echo $objPHPExcel->getActiveSheet()->getCell('B6')->getCalculatedValue() . '<br />'; |
|
57 | 57 | $callEndTime = microtime(true); |
58 | 58 | $callTime = $callEndTime - $callStartTime; |
59 | 59 | |
60 | - echo '<hr />Call time for Quadratic Equation Solution was '.sprintf('%.4f',$callTime).' seconds<br /><hr />'; |
|
61 | - echo ' Peak memory usage: '.(memory_get_peak_usage(true) / 1024 / 1024).' MB<br />'; |
|
60 | + echo '<hr />Call time for Quadratic Equation Solution was ' . sprintf('%.4f', $callTime) . ' seconds<br /><hr />'; |
|
61 | + echo ' Peak memory usage: ' . (memory_get_peak_usage(true) / 1024 / 1024) . ' MB<br />'; |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 |