PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.9.4
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.9.4
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 3.10.4 All 148 releases
visualizer / vendor / phpoffice / phpspreadsheet / samples / Chart / 32_Chart_read_write.php

32_Chart_read_write.php in Visualizer – Tables & Charts Manager with Built-in AI Generator 3.9.4, at vendor/phpoffice/phpspreadsheet/samples/Chart/32_Chart_read_write.php

84 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 use PhpOffice\PhpSpreadsheet\IOFactory;
4
5 require __DIR__ . '/../Header.php';
6
7 $inputFileType = 'Xlsx';
8 $inputFileNames = __DIR__ . '/../templates/32readwrite*[0-9].xlsx';
9
10 if ((isset($argc)) && ($argc > 1)) {
11 $inputFileNames = [];
12 for ($i = 1; $i < $argc; ++$i) {
13 $inputFileNames[] = __DIR__ . '/../templates/' . $argv[$i];
14 }
15 } else {
16 $inputFileNames = glob($inputFileNames);
17 }
18 foreach ($inputFileNames as $inputFileName) {
19 $inputFileNameShort = basename($inputFileName);
20
21 if (!file_exists($inputFileName)) {
22 $helper->log('File ' . $inputFileNameShort . ' does not exist');
23
24 continue;
25 }
26 $reader = IOFactory::createReader($inputFileType);
27 $reader->setIncludeCharts(true);
28 $callStartTime = microtime(true);
29 $spreadsheet = $reader->load($inputFileName);
30 $helper->logRead($inputFileType, $inputFileName, $callStartTime);
31
32 $helper->log('Iterate worksheets looking at the charts');
33 foreach ($spreadsheet->getWorksheetIterator() as $worksheet) {
34 $sheetName = $worksheet->getTitle();
35 $helper->log('Worksheet: ' . $sheetName);
36
37 $chartNames = $worksheet->getChartNames();
38 if (empty($chartNames)) {
39 $helper->log(' There are no charts in this worksheet');
40 } else {
41 natsort($chartNames);
42 foreach ($chartNames as $i => $chartName) {
43 $chart = $worksheet->getChartByName($chartName);
44 if ($chart->getTitle() !== null) {
45 $caption = '"' . implode(' ', $chart->getTitle()->getCaption()) . '"';
46 } else {
47 $caption = 'Untitled';
48 }
49 $helper->log(' ' . $chartName . ' - ' . $caption);
50 $indentation = str_repeat(' ', strlen($chartName) + 3);
51 $groupCount = $chart->getPlotArea()->getPlotGroupCount();
52 if ($groupCount == 1) {
53 $chartType = $chart->getPlotArea()->getPlotGroupByIndex(0)->getPlotType();
54 $helper->log($indentation . ' ' . $chartType);
55 } else {
56 $chartTypes = [];
57 for ($i = 0; $i < $groupCount; ++$i) {
58 $chartTypes[] = $chart->getPlotArea()->getPlotGroupByIndex($i)->getPlotType();
59 }
60 $chartTypes = array_unique($chartTypes);
61 if (count($chartTypes) == 1) {
62 $chartType = 'Multiple Plot ' . array_pop($chartTypes);
63 $helper->log($indentation . ' ' . $chartType);
64 } elseif (count($chartTypes) == 0) {
65 $helper->log($indentation . ' *** Type not yet implemented');
66 } else {
67 $helper->log($indentation . ' Combination Chart');
68 }
69 }
70 }
71 }
72 }
73
74 $outputFileName = $helper->getFilename($inputFileName);
75 $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
76 $writer->setIncludeCharts(true);
77 $callStartTime = microtime(true);
78 $writer->save($outputFileName);
79 $helper->logWrite($writer, $outputFileName, $callStartTime);
80
81 $spreadsheet->disconnectWorksheets();
82 unset($spreadsheet);
83 }
84