diff --git a/Tests/32chartreadwrite.php b/Tests/32chartreadwrite.php index 9ffd0d8..2042b74 100644 --- a/Tests/32chartreadwrite.php +++ b/Tests/32chartreadwrite.php @@ -8,7 +8,7 @@ date_default_timezone_set('Europe/London'); /** * PHPExcel * - * Copyright (C) 2006 - 2008 PHPExcel + * Copyright (C) 2006 - 2012 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -26,7 +26,7 @@ date_default_timezone_set('Europe/London'); * * @category PHPExcel * @package PHPExcel - * @copyright Copyright (c) 2006 - 2008 PHPExcel (http://www.codeplex.com/PHPExcel) + * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version ##VERSION##, ##DATE## */ @@ -38,65 +38,87 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../Classes/'); include 'PHPExcel/IOFactory.php'; $inputFileType = 'Excel2007'; -$inputFileName = 'templates/32chartreadwrite.xlsx'; +$inputFileNames = 'templates/32readwrite*[0-9].xlsx'; + +if ((isset($argc)) && ($argc > 1)) { + $inputFileNames = array(); + for($i = 1; $i < $argc; ++$i) { + $inputFileNames[] = __DIR__ . '/templates/' . $argv[$i]; + } +} else { + $inputFileNames = glob($inputFileNames); +} +foreach($inputFileNames as $inputFileName) { + $inputFileNameShort = basename($inputFileName); + + if (!file_exists($inputFileName)) { + echo date('H:i:s') , " File " , $inputFileNameShort , ' does not exist' , PHP_EOL; + continue; + } + + echo date('H:i:s') , " Load Test from $inputFileType file " , $inputFileNameShort , PHP_EOL; + + $objReader = PHPExcel_IOFactory::createReader($inputFileType); + $objReader->setIncludeCharts(TRUE); + $objPHPExcel = $objReader->load($inputFileName); -echo date('H:i:s')." Load Test from $inputFileType file" , PHP_EOL; + 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; -$objReader = PHPExcel_IOFactory::createReader($inputFileType); -$objPHPExcel = $objReader->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; + $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 { - echo ' Combination Chart' , PHP_EOL; + $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; + } } } } } + + + $outputFileName = basename($inputFileName); + + echo date('H:i:s') , " Write Tests to Excel2007 file " , PHP_EOL; + $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); + $objWriter->save($outputFileName); + echo date('H:i:s') , " File written to " , $outputFileName , PHP_EOL; + + $objPHPExcel->disconnectWorksheets(); + unset($objPHPExcel); } - -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 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; +echo date('H:i:s') , " Done writing files" , PHP_EOL; diff --git a/Tests/templates/32chartreadwrite.xlsx b/Tests/templates/32chartreadwrite.xlsx index dc1b654..70a9571 100644 Binary files a/Tests/templates/32chartreadwrite.xlsx and b/Tests/templates/32chartreadwrite.xlsx differ diff --git a/Tests/templates/32complexChartreadwrite.xlsx b/Tests/templates/32complexChartreadwrite.xlsx new file mode 100644 index 0000000..f9df941 Binary files /dev/null and b/Tests/templates/32complexChartreadwrite.xlsx differ diff --git a/Tests/templates/32readwriteAreaChart1.xlsx b/Tests/templates/32readwriteAreaChart1.xlsx new file mode 100644 index 0000000..d44ae53 Binary files /dev/null and b/Tests/templates/32readwriteAreaChart1.xlsx differ diff --git a/Tests/templates/32readwriteAreaChart2.xlsx b/Tests/templates/32readwriteAreaChart2.xlsx new file mode 100644 index 0000000..18c7be3 Binary files /dev/null and b/Tests/templates/32readwriteAreaChart2.xlsx differ diff --git a/Tests/templates/32readwriteAreaChart3.xlsx b/Tests/templates/32readwriteAreaChart3.xlsx new file mode 100644 index 0000000..4572326 Binary files /dev/null and b/Tests/templates/32readwriteAreaChart3.xlsx differ diff --git a/Tests/templates/32readwriteAreaPercentageChart1.xlsx b/Tests/templates/32readwriteAreaPercentageChart1.xlsx new file mode 100644 index 0000000..45d37b6 Binary files /dev/null and b/Tests/templates/32readwriteAreaPercentageChart1.xlsx differ diff --git a/Tests/templates/32readwriteAreaPercentageChart2.xlsx b/Tests/templates/32readwriteAreaPercentageChart2.xlsx new file mode 100644 index 0000000..653a28c Binary files /dev/null and b/Tests/templates/32readwriteAreaPercentageChart2.xlsx differ diff --git a/Tests/templates/32readwriteAreaStackedChart1.xlsx b/Tests/templates/32readwriteAreaStackedChart1.xlsx new file mode 100644 index 0000000..157fd05 Binary files /dev/null and b/Tests/templates/32readwriteAreaStackedChart1.xlsx differ diff --git a/Tests/templates/32readwriteAreaStackedChart2.xlsx b/Tests/templates/32readwriteAreaStackedChart2.xlsx new file mode 100644 index 0000000..e52b091 Binary files /dev/null and b/Tests/templates/32readwriteAreaStackedChart2.xlsx differ diff --git a/Tests/templates/32readwriteBarChart1.xlsx b/Tests/templates/32readwriteBarChart1.xlsx new file mode 100644 index 0000000..b0d6ea1 Binary files /dev/null and b/Tests/templates/32readwriteBarChart1.xlsx differ diff --git a/Tests/templates/32readwriteBarChart2.xlsx b/Tests/templates/32readwriteBarChart2.xlsx new file mode 100644 index 0000000..7eac33e Binary files /dev/null and b/Tests/templates/32readwriteBarChart2.xlsx differ diff --git a/Tests/templates/32readwriteBarChart3.xlsx b/Tests/templates/32readwriteBarChart3.xlsx new file mode 100644 index 0000000..d1fb401 Binary files /dev/null and b/Tests/templates/32readwriteBarChart3.xlsx differ diff --git a/Tests/templates/32readwriteBarPercentageChart1.xlsx b/Tests/templates/32readwriteBarPercentageChart1.xlsx new file mode 100644 index 0000000..7640b5b Binary files /dev/null and b/Tests/templates/32readwriteBarPercentageChart1.xlsx differ diff --git a/Tests/templates/32readwriteBarPercentageChart2.xlsx b/Tests/templates/32readwriteBarPercentageChart2.xlsx new file mode 100644 index 0000000..00b900c Binary files /dev/null and b/Tests/templates/32readwriteBarPercentageChart2.xlsx differ diff --git a/Tests/templates/32readwriteBarStackedChart1.xlsx b/Tests/templates/32readwriteBarStackedChart1.xlsx new file mode 100644 index 0000000..50d6594 Binary files /dev/null and b/Tests/templates/32readwriteBarStackedChart1.xlsx differ diff --git a/Tests/templates/32readwriteBarStackedChart2.xlsx b/Tests/templates/32readwriteBarStackedChart2.xlsx new file mode 100644 index 0000000..b82780c Binary files /dev/null and b/Tests/templates/32readwriteBarStackedChart2.xlsx differ diff --git a/Tests/templates/32readwriteChartLegends1.xlsx b/Tests/templates/32readwriteChartLegends1.xlsx new file mode 100644 index 0000000..140638c Binary files /dev/null and b/Tests/templates/32readwriteChartLegends1.xlsx differ diff --git a/Tests/templates/32readwriteChartTypes1.xlsx b/Tests/templates/32readwriteChartTypes1.xlsx new file mode 100644 index 0000000..14800c6 Binary files /dev/null and b/Tests/templates/32readwriteChartTypes1.xlsx differ diff --git a/Tests/templates/32readwriteChartWithImages1.xlsx b/Tests/templates/32readwriteChartWithImages1.xlsx new file mode 100644 index 0000000..51b2ab7 Binary files /dev/null and b/Tests/templates/32readwriteChartWithImages1.xlsx differ diff --git a/Tests/templates/32readwriteColumnChart1.xlsx b/Tests/templates/32readwriteColumnChart1.xlsx new file mode 100644 index 0000000..e83f00e Binary files /dev/null and b/Tests/templates/32readwriteColumnChart1.xlsx differ diff --git a/Tests/templates/32readwriteColumnChart2.xlsx b/Tests/templates/32readwriteColumnChart2.xlsx new file mode 100644 index 0000000..5e2d07e Binary files /dev/null and b/Tests/templates/32readwriteColumnChart2.xlsx differ diff --git a/Tests/templates/32readwriteColumnChart3.xlsx b/Tests/templates/32readwriteColumnChart3.xlsx new file mode 100644 index 0000000..d34029d Binary files /dev/null and b/Tests/templates/32readwriteColumnChart3.xlsx differ diff --git a/Tests/templates/32readwriteColumnPercentageChart1.xlsx b/Tests/templates/32readwriteColumnPercentageChart1.xlsx new file mode 100644 index 0000000..8032d09 Binary files /dev/null and b/Tests/templates/32readwriteColumnPercentageChart1.xlsx differ diff --git a/Tests/templates/32readwriteColumnPercentageChart2.xlsx b/Tests/templates/32readwriteColumnPercentageChart2.xlsx new file mode 100644 index 0000000..28a1758 Binary files /dev/null and b/Tests/templates/32readwriteColumnPercentageChart2.xlsx differ diff --git a/Tests/templates/32readwriteColumnStackedChart1.xlsx b/Tests/templates/32readwriteColumnStackedChart1.xlsx new file mode 100644 index 0000000..38ea2c7 Binary files /dev/null and b/Tests/templates/32readwriteColumnStackedChart1.xlsx differ diff --git a/Tests/templates/32readwriteColumnStackedChart2.xlsx b/Tests/templates/32readwriteColumnStackedChart2.xlsx new file mode 100644 index 0000000..3962823 Binary files /dev/null and b/Tests/templates/32readwriteColumnStackedChart2.xlsx differ diff --git a/Tests/templates/32readwriteDonutChart1.xlsx b/Tests/templates/32readwriteDonutChart1.xlsx new file mode 100644 index 0000000..56f5752 Binary files /dev/null and b/Tests/templates/32readwriteDonutChart1.xlsx differ diff --git a/Tests/templates/32readwriteDonutChart2.xlsx b/Tests/templates/32readwriteDonutChart2.xlsx new file mode 100644 index 0000000..613839b Binary files /dev/null and b/Tests/templates/32readwriteDonutChart2.xlsx differ diff --git a/Tests/templates/32readwriteDonutChart3.xlsx b/Tests/templates/32readwriteDonutChart3.xlsx new file mode 100644 index 0000000..e2798d9 Binary files /dev/null and b/Tests/templates/32readwriteDonutChart3.xlsx differ diff --git a/Tests/templates/32readwriteDonutChart4.xlsx b/Tests/templates/32readwriteDonutChart4.xlsx new file mode 100644 index 0000000..9854429 Binary files /dev/null and b/Tests/templates/32readwriteDonutChart4.xlsx differ diff --git a/Tests/templates/32readwriteLineChart1.xlsx b/Tests/templates/32readwriteLineChart1.xlsx new file mode 100644 index 0000000..ca2bccc Binary files /dev/null and b/Tests/templates/32readwriteLineChart1.xlsx differ diff --git a/Tests/templates/32readwriteLineChart2.xlsx b/Tests/templates/32readwriteLineChart2.xlsx new file mode 100644 index 0000000..93a0209 Binary files /dev/null and b/Tests/templates/32readwriteLineChart2.xlsx differ diff --git a/Tests/templates/32readwriteLineChart3.xlsx b/Tests/templates/32readwriteLineChart3.xlsx new file mode 100644 index 0000000..095199f Binary files /dev/null and b/Tests/templates/32readwriteLineChart3.xlsx differ diff --git a/Tests/templates/32readwriteLinePercentageChart1.xlsx b/Tests/templates/32readwriteLinePercentageChart1.xlsx new file mode 100644 index 0000000..e336da7 Binary files /dev/null and b/Tests/templates/32readwriteLinePercentageChart1.xlsx differ diff --git a/Tests/templates/32readwriteLinePercentageChart2.xlsx b/Tests/templates/32readwriteLinePercentageChart2.xlsx new file mode 100644 index 0000000..cacddd1 Binary files /dev/null and b/Tests/templates/32readwriteLinePercentageChart2.xlsx differ diff --git a/Tests/templates/32readwriteLineStackedChart1.xlsx b/Tests/templates/32readwriteLineStackedChart1.xlsx new file mode 100644 index 0000000..fe13e47 Binary files /dev/null and b/Tests/templates/32readwriteLineStackedChart1.xlsx differ diff --git a/Tests/templates/32readwriteLineStackedChart2.xlsx b/Tests/templates/32readwriteLineStackedChart2.xlsx new file mode 100644 index 0000000..5389774 Binary files /dev/null and b/Tests/templates/32readwriteLineStackedChart2.xlsx differ diff --git a/Tests/templates/32readwritePieChart1.xlsx b/Tests/templates/32readwritePieChart1.xlsx new file mode 100644 index 0000000..2101d63 Binary files /dev/null and b/Tests/templates/32readwritePieChart1.xlsx differ diff --git a/Tests/templates/32readwritePieChart2.xlsx b/Tests/templates/32readwritePieChart2.xlsx new file mode 100644 index 0000000..acd09e7 Binary files /dev/null and b/Tests/templates/32readwritePieChart2.xlsx differ diff --git a/Tests/templates/32readwritePieChart3.xlsx b/Tests/templates/32readwritePieChart3.xlsx new file mode 100644 index 0000000..4d617ff Binary files /dev/null and b/Tests/templates/32readwritePieChart3.xlsx differ diff --git a/Tests/templates/32readwritePieChart4.xlsx b/Tests/templates/32readwritePieChart4.xlsx new file mode 100644 index 0000000..03e4931 Binary files /dev/null and b/Tests/templates/32readwritePieChart4.xlsx differ