| 
									
										
										
										
											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'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * PHPExcel | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2013-12-31 18:36:33 +00:00
										 |  |  |  * Copyright (C) 2006 - 2014 PHPExcel | 
					
						
							| 
									
										
										
										
											2012-02-15 13:11:26 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * This library is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  * modify it under the terms of the GNU Lesser General Public | 
					
						
							|  |  |  |  * License as published by the Free Software Foundation; either | 
					
						
							|  |  |  |  * version 2.1 of the License, or (at your option) any later version. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This library is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
					
						
							|  |  |  |  * Lesser General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU Lesser General Public | 
					
						
							|  |  |  |  * License along with this library; if not, write to the Free Software | 
					
						
							|  |  |  |  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @category   PHPExcel | 
					
						
							|  |  |  |  * @package    PHPExcel | 
					
						
							| 
									
										
										
										
											2013-12-31 18:36:33 +00:00
										 |  |  |  * @copyright  Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) | 
					
						
							| 
									
										
										
										
											2012-02-15 13:11:26 +00:00
										 |  |  |  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL | 
					
						
							|  |  |  |  * @version    ##VERSION##, ##DATE##
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** Include path **/ | 
					
						
							| 
									
										
										
										
											2013-07-10 11:33:04 +00:00
										 |  |  | set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/../Classes/'); | 
					
						
							| 
									
										
										
										
											2012-02-15 13:11:26 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /** PHPExcel_IOFactory */ | 
					
						
							|  |  |  | include 'PHPExcel/IOFactory.php'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-20 20:46:56 +00:00
										 |  |  | 	$objReader = PHPExcel_IOFactory::createReader($inputFileType); | 
					
						
							|  |  |  | 	$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; | 
					
						
							| 
									
										
										
										
											2012-02-20 20:46:56 +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; |