PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 2.2.0
Visualizer – Tables & Charts Manager with Built-in AI Generator v2.2.0
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
visualizer / vendor / phpoffice / phpexcel / Examples / 32chartreadwrite.php

32chartreadwrite.php in Visualizer – Tables & Charts Manager with Built-in AI Generator 2.2.0, at vendor/phpoffice/phpexcel/Examples/32chartreadwrite.php

132 lines 4.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /** Error reporting */
4 error_reporting(E_ALL);
5 ini_set('display_errors', TRUE);
6 ini_set('display_startup_errors', TRUE);
7 date_default_timezone_set('Europe/London');
8
9 define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
10
11 date_default_timezone_set('Europe/London');
12
13 /**
14 * PHPExcel
15 *
16 * Copyright (C) 2006 - 2014 PHPExcel
17 *
18 * This library is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU Lesser General Public
20 * License as published by the Free Software Foundation; either
21 * version 2.1 of the License, or (at your option) any later version.
22 *
23 * This library is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26 * Lesser General Public License for more details.
27 *
28 * You should have received a copy of the GNU Lesser General Public
29 * License along with this library; if not, write to the Free Software
30 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
31 *
32 * @category PHPExcel
33 * @package PHPExcel
34 * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
35 * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
36 * @version ##VERSION##, ##DATE##
37 */
38
39 /** Include path **/
40 set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/../Classes/');
41
42 /** PHPExcel_IOFactory */
43 include 'PHPExcel/IOFactory.php';
44
45 $inputFileType = 'Excel2007';
46 $inputFileNames = 'templates/32readwrite*[0-9].xlsx';
47
48 if ((isset($argc)) && ($argc > 1)) {
49 $inputFileNames = array();
50 for($i = 1; $i < $argc; ++$i) {
51 $inputFileNames[] = dirname(__FILE__) . '/templates/' . $argv[$i];
52 }
53 } else {
54 $inputFileNames = glob($inputFileNames);
55 }
56 foreach($inputFileNames as $inputFileName) {
57 $inputFileNameShort = basename($inputFileName);
58
59 if (!file_exists($inputFileName)) {
60 echo date('H:i:s') , " File " , $inputFileNameShort , ' does not exist' , EOL;
61 continue;
62 }
63
64 echo date('H:i:s') , " Load Test from $inputFileType file " , $inputFileNameShort , EOL;
65
66 $objReader = PHPExcel_IOFactory::createReader($inputFileType);
67 $objReader->setIncludeCharts(TRUE);
68 $objPHPExcel = $objReader->load($inputFileName);
69
70
71 echo date('H:i:s') , " Iterate worksheets looking at the charts" , EOL;
72 foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
73 $sheetName = $worksheet->getTitle();
74 echo 'Worksheet: ' , $sheetName , EOL;
75
76 $chartNames = $worksheet->getChartNames();
77 if(empty($chartNames)) {
78 echo ' There are no charts in this worksheet' , EOL;
79 } else {
80 natsort($chartNames);
81 foreach($chartNames as $i => $chartName) {
82 $chart = $worksheet->getChartByName($chartName);
83 if (!is_null($chart->getTitle())) {
84 $caption = '"' . implode(' ',$chart->getTitle()->getCaption()) . '"';
85 } else {
86 $caption = 'Untitled';
87 }
88 echo ' ' , $chartName , ' - ' , $caption , EOL;
89 echo str_repeat(' ',strlen($chartName)+3);
90 $groupCount = $chart->getPlotArea()->getPlotGroupCount();
91 if ($groupCount == 1) {
92 $chartType = $chart->getPlotArea()->getPlotGroupByIndex(0)->getPlotType();
93 echo ' ' , $chartType , EOL;
94 } else {
95 $chartTypes = array();
96 for($i = 0; $i < $groupCount; ++$i) {
97 $chartTypes[] = $chart->getPlotArea()->getPlotGroupByIndex($i)->getPlotType();
98 }
99 $chartTypes = array_unique($chartTypes);
100 if (count($chartTypes) == 1) {
101 $chartType = 'Multiple Plot ' . array_pop($chartTypes);
102 echo ' ' , $chartType , EOL;
103 } elseif (count($chartTypes) == 0) {
104 echo ' *** Type not yet implemented' , EOL;
105 } else {
106 echo ' Combination Chart' , EOL;
107 }
108 }
109 }
110 }
111 }
112
113
114 $outputFileName = basename($inputFileName);
115
116 echo date('H:i:s') , " Write Tests to Excel2007 file " , EOL;
117 $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
118 $objWriter->setIncludeCharts(TRUE);
119 $objWriter->save($outputFileName);
120 echo date('H:i:s') , " File written to " , $outputFileName , EOL;
121
122 $objPHPExcel->disconnectWorksheets();
123 unset($objPHPExcel);
124 }
125
126 // Echo memory peak usage
127 echo date('H:i:s') , ' Peak memory usage: ' , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
128
129 // Echo done
130 echo date('H:i:s') , " Done writing files" , EOL;
131 echo 'Files have been created in ' , getcwd() , EOL;
132