ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
32chartreadwrite.php
Go to the documentation of this file.
1<?php
2
4error_reporting(E_ALL);
5ini_set('display_errors', TRUE);
6ini_set('display_startup_errors', TRUE);
7date_default_timezone_set('Europe/London');
8
9define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
10
11date_default_timezone_set('Europe/London');
12
40set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/../Classes/');
41
43include 'PHPExcel/IOFactory.php';
44
45$inputFileType = 'Excel2007';
46$inputFileNames = 'templates/32readwrite*[0-9].xlsx';
47
48if ((isset($argc)) && ($argc > 1)) {
49 $inputFileNames = array();
50 for($i = 1; $i < $argc; ++$i) {
51 $inputFileNames[] = dirname(__FILE__) . '/templates/' . $argv[$i];
52 }
53} else {
55}
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
67 $objReader->setIncludeCharts(TRUE);
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;
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
127echo date('H:i:s') , ' Peak memory usage: ' , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
128
129// Echo done
130echo date('H:i:s') , " Done writing files" , EOL;
131echo 'Files have been created in ' , getcwd() , EOL;
$objWriter
$objPHPExcel
$objReader
Definition: 16csv.php:62
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
$inputFileNames
memory_get_peak_usage(true)/1024/1024)
const EOL
$inputFileType
PHPExcel_IOFactory.
$worksheet
An exception for terminatinating execution or to throw for unit testing.
static createWriter(PHPExcel $phpExcel, $writerType='')
Create PHPExcel_Writer_IWriter.
Definition: IOFactory.php:132
static createReader($readerType='')
Create PHPExcel_Reader_IReader.
Definition: IOFactory.php:161
$argv