2012-02-15 13:11:26 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/** Error reporting */
|
|
|
|
error_reporting(E_ALL);
|
2012-08-05 22:03:45 +00:00
|
|
|
ini_set('display_errors', TRUE);
|
|
|
|
ini_set('display_startup_errors', TRUE);
|
|
|
|
date_default_timezone_set('Europe/London');
|
|
|
|
|
|
|
|
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
2012-02-15 13:11:26 +00:00
|
|
|
|
|
|
|
date_default_timezone_set('Europe/London');
|
|
|
|
|
2016-03-22 13:25:49 +00:00
|
|
|
/** Include PHPExcel */
|
|
|
|
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
2012-02-15 13:11:26 +00:00
|
|
|
|
|
|
|
$inputFileType = 'Excel2007';
|
2012-02-20 20:46:56 +00:00
|
|
|
$inputFileNames = 'templates/32readwrite*[0-9].xlsx';
|
2012-02-15 13:11:26 +00:00
|
|
|
|
2012-02-20 20:46:56 +00:00
|
|
|
if ((isset($argc)) && ($argc > 1)) {
|
|
|
|
$inputFileNames = array();
|
|
|
|
for($i = 1; $i < $argc; ++$i) {
|
2012-11-24 08:44:56 +00:00
|
|
|
$inputFileNames[] = dirname(__FILE__) . '/templates/' . $argv[$i];
|
2012-02-20 20:46:56 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$inputFileNames = glob($inputFileNames);
|
|
|
|
}
|
|
|
|
foreach($inputFileNames as $inputFileName) {
|
|
|
|
$inputFileNameShort = basename($inputFileName);
|
2012-02-15 13:11:26 +00:00
|
|
|
|
2012-02-20 20:46:56 +00:00
|
|
|
if (!file_exists($inputFileName)) {
|
2012-08-05 22:03:45 +00:00
|
|
|
echo date('H:i:s') , " File " , $inputFileNameShort , ' does not exist' , EOL;
|
2012-02-20 20:46:56 +00:00
|
|
|
continue;
|
|
|
|
}
|
2012-02-15 13:11:26 +00:00
|
|
|
|
2012-08-05 22:03:45 +00:00
|
|
|
echo date('H:i:s') , " Load Test from $inputFileType file " , $inputFileNameShort , EOL;
|
2012-02-15 13:11:26 +00:00
|
|
|
|
2016-03-22 13:25:49 +00:00
|
|
|
$objReader = \PHPExcel\IOFactory::createReader($inputFileType);
|
2012-02-20 20:46:56 +00:00
|
|
|
$objReader->setIncludeCharts(TRUE);
|
|
|
|
$objPHPExcel = $objReader->load($inputFileName);
|
2012-02-15 13:11:26 +00:00
|
|
|
|
|
|
|
|
2012-08-05 22:03:45 +00:00
|
|
|
echo date('H:i:s') , " Iterate worksheets looking at the charts" , EOL;
|
2012-02-20 20:46:56 +00:00
|
|
|
foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
|
|
|
|
$sheetName = $worksheet->getTitle();
|
2012-08-05 22:03:45 +00:00
|
|
|
echo 'Worksheet: ' , $sheetName , EOL;
|
2012-02-20 20:46:56 +00:00
|
|
|
|
|
|
|
$chartNames = $worksheet->getChartNames();
|
|
|
|
if(empty($chartNames)) {
|
2012-08-05 22:03:45 +00:00
|
|
|
echo ' There are no charts in this worksheet' , EOL;
|
2012-02-20 20:46:56 +00:00
|
|
|
} 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';
|
2012-02-15 13:11:26 +00:00
|
|
|
}
|
2012-08-05 22:03:45 +00:00
|
|
|
echo ' ' , $chartName , ' - ' , $caption , EOL;
|
2012-02-20 20:46:56 +00:00
|
|
|
echo str_repeat(' ',strlen($chartName)+3);
|
|
|
|
$groupCount = $chart->getPlotArea()->getPlotGroupCount();
|
|
|
|
if ($groupCount == 1) {
|
|
|
|
$chartType = $chart->getPlotArea()->getPlotGroupByIndex(0)->getPlotType();
|
2012-08-05 22:03:45 +00:00
|
|
|
echo ' ' , $chartType , EOL;
|
2012-02-15 13:11:26 +00:00
|
|
|
} else {
|
2012-02-20 20:46:56 +00:00
|
|
|
$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);
|
2012-08-05 22:03:45 +00:00
|
|
|
echo ' ' , $chartType , EOL;
|
2012-02-20 20:46:56 +00:00
|
|
|
} elseif (count($chartTypes) == 0) {
|
2012-08-05 22:03:45 +00:00
|
|
|
echo ' *** Type not yet implemented' , EOL;
|
2012-02-20 20:46:56 +00:00
|
|
|
} else {
|
2012-08-05 22:03:45 +00:00
|
|
|
echo ' Combination Chart' , EOL;
|
2012-02-20 20:46:56 +00:00
|
|
|
}
|
2012-02-15 13:11:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-20 20:46:56 +00:00
|
|
|
$outputFileName = basename($inputFileName);
|
|
|
|
|
2012-08-05 22:03:45 +00:00
|
|
|
echo date('H:i:s') , " Write Tests to Excel2007 file " , EOL;
|
2016-03-22 13:25:49 +00:00
|
|
|
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
2012-02-25 15:54:20 +00:00
|
|
|
$objWriter->setIncludeCharts(TRUE);
|
2012-02-20 20:46:56 +00:00
|
|
|
$objWriter->save($outputFileName);
|
2012-08-05 22:03:45 +00:00
|
|
|
echo date('H:i:s') , " File written to " , $outputFileName , EOL;
|
2012-02-20 20:46:56 +00:00
|
|
|
|
|
|
|
$objPHPExcel->disconnectWorksheets();
|
|
|
|
unset($objPHPExcel);
|
|
|
|
}
|
2012-02-15 13:11:26 +00:00
|
|
|
|
|
|
|
// Echo memory peak usage
|
2012-08-05 22:03:45 +00:00
|
|
|
echo date('H:i:s') , ' Peak memory usage: ' , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
2012-02-15 13:11:26 +00:00
|
|
|
|
|
|
|
// Echo done
|
2012-08-05 22:03:45 +00:00
|
|
|
echo date('H:i:s') , " Done writing files" , EOL;
|
|
|
|
echo 'Files have been created in ' , getcwd() , EOL;
|