diff --git a/Tests/32chartreadwrite.php b/Tests/32chartreadwrite.php new file mode 100644 index 0000000..9ffd0d8 --- /dev/null +++ b/Tests/32chartreadwrite.php @@ -0,0 +1,102 @@ +load($inputFileName); + + +echo date('H:i:s') , " Iterate worksheets looking at the charts" , PHP_EOL; +foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) { + $sheetName = $worksheet->getTitle(); + echo 'Worksheet: ' , $sheetName , PHP_EOL; + + $chartNames = $worksheet->getChartNames(); + if(empty($chartNames)) { + echo ' There are no charts in this worksheet' , PHP_EOL; + } else { + natsort($chartNames); + foreach($chartNames as $i => $chartName) { + $chart = $worksheet->getChartByName($chartName); + if (!is_null($chart->getTitle())) { + $caption = '"' . implode(' ',$chart->getTitle()->getCaption()) . '"'; + } else { + $caption = 'Untitled'; + } + echo ' ' , $chartName , ' - ' , $caption , PHP_EOL; + echo str_repeat(' ',strlen($chartName)+3); + $groupCount = $chart->getPlotArea()->getPlotGroupCount(); + if ($groupCount == 1) { + $chartType = $chart->getPlotArea()->getPlotGroupByIndex(0)->getPlotType(); + echo ' ' , $chartType , PHP_EOL; + } else { + $chartTypes = array(); + for($i = 0; $i < $groupCount; ++$i) { + $chartTypes[] = $chart->getPlotArea()->getPlotGroupByIndex($i)->getPlotType(); + } + $chartTypes = array_unique($chartTypes); + if (count($chartTypes) == 1) { + $chartType = 'Multiple Plot ' . array_pop($chartTypes); + echo ' ' , $chartType , PHP_EOL; + } elseif (count($chartTypes) == 0) { + echo ' *** Type not yet implemented' , PHP_EOL; + } else { + echo ' Combination Chart' , PHP_EOL; + } + } + } + } +} + + +echo date('H:i:s')." Write Tests to Excel2007 file" , PHP_EOL; +$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); +$objWriter->save(str_replace('.php', '.xlsx', __FILE__)); +echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', __FILE__) , PHP_EOL; + +// Echo memory peak usage +echo date('H:i:s').' Peak memory usage: '.(memory_get_peak_usage(true) / 1024 / 1024)." MB" , PHP_EOL; + +// Echo done +echo date('H:i:s')." Done writing files." , PHP_EOL; diff --git a/Tests/runall.php b/Tests/runall.php index 4a9c493..d421dcd 100644 --- a/Tests/runall.php +++ b/Tests/runall.php @@ -64,6 +64,7 @@ $aTests = array( , '29advancedvaluebinder.php' , '30template.php' , '31docproperties_write.php' + , '31docproperties_write-xls.php' , '32chartreadwrite.php' , 'OOCalcReader.php' , 'SylkReader.php' diff --git a/Tests/templates/32chartreadwrite.xlsx b/Tests/templates/32chartreadwrite.xlsx new file mode 100644 index 0000000..dc1b654 Binary files /dev/null and b/Tests/templates/32chartreadwrite.xlsx differ