ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
32chartreadwrite.php
Go to the documentation of this file.
1 <?php
2 
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 
40 set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/../Classes/');
41 
43 include 'PHPExcel/IOFactory.php';
44 
45 $inputFileType = 'Excel2007';
46 $inputFileNames = 'templates/32readwrite*[0-9].xlsx';
47 
48 if ((isset($argc)) && ($argc > 1)) {
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);
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;
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;
$worksheet
global $argv
Definition: svg-scanner.php:41
$inputFileNames
const EOL
$objPHPExcel
$objWriter
$inputFileType
PHPExcel_IOFactory.
static createReader($readerType='')
Create PHPExcel_Reader_IReader.
Definition: IOFactory.php:161
static createWriter(PHPExcel $phpExcel, $writerType='')
Create PHPExcel_Writer_IWriter.
Definition: IOFactory.php:132
if($is_dev) echo "Review changes write something in WHATSNEW and and then commit with log PHP_EOL
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Create styles array
The data for the language used.
$i
Definition: disco.tpl.php:19
$objReader
Definition: 16csv.php:62