From 11e33b2307abef3b61c33feb7a24de69beaab07c Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Thu, 20 Jun 2013 21:31:26 +0100 Subject: [PATCH] namespace examples --- Classes/Autoloader.php | 17 +++++ .../PHPExcel/CachedObjectStorageFactory.php | 62 ++++++++++--------- Classes/PHPExcel/Reader/CSV.php | 6 +- Classes/PHPExcel/Workbook.php | 20 +++--- Examples/01simple.php | 2 +- Examples/02types-xls.php | 2 +- Examples/02types.php | 2 +- Examples/03formulas.php | 2 +- Examples/04printing.php | 2 +- Examples/05featuredemo.inc.php | 2 +- .../06largescale-with-cellcaching-sqlite.php | 2 +- .../06largescale-with-cellcaching-sqlite3.php | 10 +-- Examples/06largescale-with-cellcaching.php | 2 +- Examples/06largescale.php | 2 +- Examples/08conditionalformatting.php | 48 +++++++------- Examples/08conditionalformatting2.php | 32 +++++----- Examples/09pagebreaks.php | 15 ++--- 17 files changed, 125 insertions(+), 103 deletions(-) diff --git a/Classes/Autoloader.php b/Classes/Autoloader.php index c57fc64..89c2625 100644 --- a/Classes/Autoloader.php +++ b/Classes/Autoloader.php @@ -23,8 +23,25 @@ * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version ##VERSION##, ##DATE## + * + * SplClassLoader implementation that implements the technical interoperability + * standards for PHP 5.3 namespaces and class names. + * + * http://groups.google.com/group/php-standards/web/final-proposal + * + * // Example which loads classes for the Doctrine Common package in the + * // Doctrine\Common namespace. + * $classLoader = new SplClassLoader('Doctrine\Common', '/path/to/doctrine'); + * $classLoader->register(); + * + * @author Jonathan H. Wage + * @author Roman S. Borschel + * @author Matthew Weier O'Phinney + * @author Kris Wallsmith + * @author Fabien Potencier */ + namespace PHPExcel; /** diff --git a/Classes/PHPExcel/CachedObjectStorageFactory.php b/Classes/PHPExcel/CachedObjectStorageFactory.php index 4ce2d78..4d1596c 100644 --- a/Classes/PHPExcel/CachedObjectStorageFactory.php +++ b/Classes/PHPExcel/CachedObjectStorageFactory.php @@ -56,14 +56,14 @@ class CachedObjectStorageFactory * * @var string */ - private static $_cacheStorageMethod = NULL; + protected static $_cacheStorageMethod = NULL; /** * Name of the class used for cell cacheing * * @var string */ - private static $_cacheStorageClass = NULL; + protected static $_cacheStorageClass = NULL; /** @@ -71,7 +71,7 @@ class CachedObjectStorageFactory * * @var string[] */ - private static $_storageMethods = array( + protected static $_storageMethods = array( self::cache_in_memory, self::cache_in_memory_gzip, self::cache_in_memory_serialized, @@ -91,31 +91,35 @@ class CachedObjectStorageFactory * * @var array of mixed array */ - private static $_storageMethodDefaultParameters = array( - self::cache_in_memory => array( - ), - self::cache_in_memory_gzip => array( - ), - self::cache_in_memory_serialized => array( - ), - self::cache_igbinary => array( - ), - self::cache_to_phpTemp => array( 'memoryCacheSize' => '1MB' - ), - self::cache_to_discISAM => array( 'dir' => NULL - ), - self::cache_to_apc => array( 'cacheTime' => 600 - ), - self::cache_to_memcache => array( 'memcacheServer' => 'localhost', - 'memcachePort' => 11211, - 'cacheTime' => 600 - ), - self::cache_to_wincache => array( 'cacheTime' => 600 - ), - self::cache_to_sqlite => array( - ), - self::cache_to_sqlite3 => array( - ), + protected static $_storageMethodDefaultParameters = array( + self::cache_in_memory => array( + ), + self::cache_in_memory_gzip => array( + ), + self::cache_in_memory_serialized => array( + ), + self::cache_igbinary => array( + ), + self::cache_to_phpTemp => array( 'memoryCacheSize' => '1MB' + ), + self::cache_to_discISAM => array( + 'dir' => NULL + ), + self::cache_to_apc => array( + 'cacheTime' => 600 + ), + self::cache_to_memcache => array( + 'memcacheServer' => 'localhost', + 'memcachePort' => 11211, + 'cacheTime' => 600 + ), + self::cache_to_wincache => array( + 'cacheTime' => 600 + ), + self::cache_to_sqlite => array( + ), + self::cache_to_sqlite3 => array( + ), ); @@ -124,7 +128,7 @@ class CachedObjectStorageFactory * * @var array of mixed array */ - private static $_storageMethodParameters = array(); + protected static $_storageMethodParameters = array(); /** diff --git a/Classes/PHPExcel/Reader/CSV.php b/Classes/PHPExcel/Reader/CSV.php index b159142..571dacb 100644 --- a/Classes/PHPExcel/Reader/CSV.php +++ b/Classes/PHPExcel/Reader/CSV.php @@ -227,12 +227,12 @@ class Reader_CSV extends Reader_Abstract implements Reader_IReader /** * Loads PHPExcel from file into PHPExcel instance * - * @param string $pFilename - * @param PHPExcel $objPHPExcel + * @param string $pFilename + * @param PHPExcel\Workbook $objPHPExcel * @return PHPExcel * @throws PHPExcel\Reader_Exception */ - public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel) + public function loadIntoExisting($pFilename, Workbook $objPHPExcel) { $lineEnding = ini_get('auto_detect_line_endings'); ini_set('auto_detect_line_endings', true); diff --git a/Classes/PHPExcel/Workbook.php b/Classes/PHPExcel/Workbook.php index 4cec695..77fc911 100644 --- a/Classes/PHPExcel/Workbook.php +++ b/Classes/PHPExcel/Workbook.php @@ -41,70 +41,70 @@ class Workbook * * @var string */ - private $_uniqueID; + protected $_uniqueID; /** * Document properties * * @var PHPExcel\DocumentProperties */ - private $_properties; + protected $_properties; /** * Document security * * @var PHPExcel\DocumentSecurity */ - private $_security; + protected $_security; /** * Collection of Worksheet objects * * @var PHPExcel\Worksheet[] */ - private $_workSheetCollection = array(); + protected $_workSheetCollection = array(); /** * Calculation Engine * * @var PHPExcel\Calculation */ - private $_calculationEngine = NULL; + protected $_calculationEngine = NULL; /** * Active sheet index * * @var int */ - private $_activeSheetIndex = 0; + protected $_activeSheetIndex = 0; /** * Named ranges * * @var PHPExcel\NamedRange[] */ - private $_namedRanges = array(); + protected $_namedRanges = array(); /** * CellXf supervisor * * @var PHPExcel\Style */ - private $_cellXfSupervisor; + protected $_cellXfSupervisor; /** * CellXf collection * * @var PHPExcel\Style[] */ - private $_cellXfCollection = array(); + protected $_cellXfCollection = array(); /** * CellStyleXf collection * * @var PHPExcel\Style[] */ - private $_cellStyleXfCollection = array(); + protected $_cellStyleXfCollection = array(); /** * Create a new PHPExcel with one Worksheet diff --git a/Examples/01simple.php b/Examples/01simple.php index b8d272e..a931b89 100644 --- a/Examples/01simple.php +++ b/Examples/01simple.php @@ -37,7 +37,7 @@ define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '
'); require_once '../Classes/Bootstrap.php'; -// Create new PHPExcel object +// Create new PHPExcel Workbook object echo date('H:i:s') , " Create new PHPExcel Workbook object" , EOL; $objPHPExcel = new PHPExcel\Workbook(); diff --git a/Examples/02types-xls.php b/Examples/02types-xls.php index 77dd137..859d47b 100644 --- a/Examples/02types-xls.php +++ b/Examples/02types-xls.php @@ -37,7 +37,7 @@ define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '
'); require_once '../Classes/Bootstrap.php'; -// Create new PHPExcel object +// Create new PHPExcel Workbook object echo date('H:i:s') , " Create new PHPExcel Workbook object" , EOL; $objPHPExcel = new PHPExcel\Workbook(); diff --git a/Examples/02types.php b/Examples/02types.php index ea258c6..3297e7a 100644 --- a/Examples/02types.php +++ b/Examples/02types.php @@ -37,7 +37,7 @@ define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '
'); require_once '../Classes/Bootstrap.php'; -// Create new PHPExcel object +// Create new PHPExcel Workbook object echo date('H:i:s') , " Create new PHPExcel Workbook object" , EOL; $objPHPExcel = new PHPExcel\Workbook(); diff --git a/Examples/03formulas.php b/Examples/03formulas.php index 2ffcd17..7cf0023 100644 --- a/Examples/03formulas.php +++ b/Examples/03formulas.php @@ -37,7 +37,7 @@ define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '
'); require_once '../Classes/Bootstrap.php'; -// Create new PHPExcel object +// Create new PHPExcel Workbook object echo date('H:i:s') , " Create new PHPExcel Workbook object" , EOL; $objPHPExcel = new PHPExcel\Workbook(); diff --git a/Examples/04printing.php b/Examples/04printing.php index f04ea47..5d5ea7e 100644 --- a/Examples/04printing.php +++ b/Examples/04printing.php @@ -38,7 +38,7 @@ date_default_timezone_set('Europe/London'); require_once '../Classes/Bootstrap.php'; -// Create new PHPExcel object +// Create new PHPExcel Workbook object echo date('H:i:s') , " Create new PHPExcel Workbook object" , EOL; $objPHPExcel = new PHPExcel\Workbook(); diff --git a/Examples/05featuredemo.inc.php b/Examples/05featuredemo.inc.php index 222cb79..b50e380 100644 --- a/Examples/05featuredemo.inc.php +++ b/Examples/05featuredemo.inc.php @@ -32,7 +32,7 @@ error_reporting(E_ALL); require_once '../Classes/Bootstrap.php'; -// Create new PHPExcel object +// Create new PHPExcel Workbook object echo date('H:i:s') , " Create new PHPExcel Workbook object" , EOL; $objPHPExcel = new PHPExcel\Workbook(); diff --git a/Examples/06largescale-with-cellcaching-sqlite.php b/Examples/06largescale-with-cellcaching-sqlite.php index b3bdcac..74bb200 100644 --- a/Examples/06largescale-with-cellcaching-sqlite.php +++ b/Examples/06largescale-with-cellcaching-sqlite.php @@ -42,7 +42,7 @@ PHPExcel_Settings::setCacheStorageMethod($cacheMethod); echo date('H:i:s') , " Enable Cell Caching using " , $cacheMethod , " method" , EOL; -// Create new PHPExcel object +// Create new PHPExcel Workbook object echo date('H:i:s') , " Create new PHPExcel object" , EOL; $objPHPExcel = new PHPExcel(); diff --git a/Examples/06largescale-with-cellcaching-sqlite3.php b/Examples/06largescale-with-cellcaching-sqlite3.php index 768f7d1..f5d99d5 100644 --- a/Examples/06largescale-with-cellcaching-sqlite3.php +++ b/Examples/06largescale-with-cellcaching-sqlite3.php @@ -34,17 +34,17 @@ define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '
'); date_default_timezone_set('Europe/London'); -/** Include PHPExcel */ -require_once '../Classes/PHPExcel.php'; +/** Include PHPExcel Bootstrap */ +require_once '../Classes/Bootstrap.php'; $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_sqlite3; PHPExcel_Settings::setCacheStorageMethod($cacheMethod); echo date('H:i:s') , " Enable Cell Caching using " , $cacheMethod , " method" , EOL; -// Create new PHPExcel object -echo date('H:i:s') , " Create new PHPExcel object" , EOL; -$objPHPExcel = new PHPExcel(); +// Create new PHPExcel Workbook object +echo date('H:i:s') , " Create new PHPExcel Workbook object" , EOL; +$objPHPExcel = new PHPExcel\Workbook(); // Set document properties echo date('H:i:s') , " Set properties" , EOL; diff --git a/Examples/06largescale-with-cellcaching.php b/Examples/06largescale-with-cellcaching.php index 4d2828f..344f443 100644 --- a/Examples/06largescale-with-cellcaching.php +++ b/Examples/06largescale-with-cellcaching.php @@ -44,7 +44,7 @@ if (!PHPExcel\Settings::setCacheStorageMethod($cacheMethod)) { echo date('H:i:s') , " Enable Cell Caching using " , $cacheMethod , " method" , EOL; -// Create new PHPExcel object +// Create new PHPExcel Workbook object echo date('H:i:s') , " Create new PHPExcel Workbook object" , EOL; $objPHPExcel = new PHPExcel\Workbook(); diff --git a/Examples/06largescale.php b/Examples/06largescale.php index ec34a00..f1c7c1b 100644 --- a/Examples/06largescale.php +++ b/Examples/06largescale.php @@ -51,7 +51,7 @@ for writing to Excel2007: 15000 465 */ -// Create new PHPExcel object +// Create new PHPExcel Workbook object echo date('H:i:s') , " Create new PHPExcel Workbook object" , EOL; $objPHPExcel = new PHPExcel\Workbook(); diff --git a/Examples/08conditionalformatting.php b/Examples/08conditionalformatting.php index 89a77a7..f9032a7 100644 --- a/Examples/08conditionalformatting.php +++ b/Examples/08conditionalformatting.php @@ -34,13 +34,13 @@ define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '
'); date_default_timezone_set('Europe/London'); -/** Include PHPExcel */ -require_once '../Classes/PHPExcel.php'; +/** Include PHPExcel Bootstrap */ +require_once '../Classes/Bootstrap.php'; -// Create new PHPExcel object -echo date('H:i:s') , " Create new PHPExcel object" , EOL; -$objPHPExcel = new PHPExcel(); +// Create new PHPExcel Workbook object +echo date('H:i:s') , " Create new PHPExcel Workbook object" , EOL; +$objPHPExcel = new PHPExcel\Workbook(); // Set document properties echo date('H:i:s') , " Set document properties" , EOL; @@ -86,30 +86,30 @@ $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(12); // Add conditional formatting echo date('H:i:s') , " Add conditional formatting" , EOL; -$objConditional1 = new PHPExcel_Style_Conditional(); -$objConditional1->setConditionType(PHPExcel_Style_Conditional::CONDITION_CELLIS) - ->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_BETWEEN) +$objConditional1 = new PHPExcel\Style_Conditional(); +$objConditional1->setConditionType(PHPExcel\Style_Conditional::CONDITION_CELLIS) + ->setOperatorType(PHPExcel\Style_Conditional::OPERATOR_BETWEEN) ->addCondition('200') ->addCondition('400'); -$objConditional1->getStyle()->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_YELLOW); +$objConditional1->getStyle()->getFont()->getColor()->setARGB(PHPExcel\Style_Color::COLOR_YELLOW); $objConditional1->getStyle()->getFont()->setBold(true); -$objConditional1->getStyle()->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE); +$objConditional1->getStyle()->getNumberFormat()->setFormatCode(PHPExcel\Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE); -$objConditional2 = new PHPExcel_Style_Conditional(); -$objConditional2->setConditionType(PHPExcel_Style_Conditional::CONDITION_CELLIS) - ->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_LESSTHAN) +$objConditional2 = new PHPExcel\Style_Conditional(); +$objConditional2->setConditionType(PHPExcel\Style_Conditional::CONDITION_CELLIS) + ->setOperatorType(PHPExcel\Style_Conditional::OPERATOR_LESSTHAN) ->addCondition('0'); -$objConditional2->getStyle()->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_RED); +$objConditional2->getStyle()->getFont()->getColor()->setARGB(PHPExcel\Style_Color::COLOR_RED); $objConditional2->getStyle()->getFont()->setItalic(true); -$objConditional2->getStyle()->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE); +$objConditional2->getStyle()->getNumberFormat()->setFormatCode(PHPExcel\Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE); -$objConditional3 = new PHPExcel_Style_Conditional(); -$objConditional3->setConditionType(PHPExcel_Style_Conditional::CONDITION_CELLIS) - ->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_GREATERTHANOREQUAL) +$objConditional3 = new PHPExcel\Style_Conditional(); +$objConditional3->setConditionType(PHPExcel\Style_Conditional::CONDITION_CELLIS) + ->setOperatorType(PHPExcel\Style_Conditional::OPERATOR_GREATERTHANOREQUAL) ->addCondition('0'); -$objConditional3->getStyle()->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_GREEN); +$objConditional3->getStyle()->getFont()->getColor()->setARGB(PHPExcel\Style_Color::COLOR_GREEN); $objConditional3->getStyle()->getFont()->setItalic(true); -$objConditional3->getStyle()->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE); +$objConditional3->getStyle()->getNumberFormat()->setFormatCode(PHPExcel\Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE); $conditionalStyles = $objPHPExcel->getActiveSheet()->getStyle('B2')->getConditionalStyles(); array_push($conditionalStyles, $objConditional1); @@ -142,8 +142,8 @@ $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&L&B' . $objPHP // Set page orientation and size echo date('H:i:s') , " Set page orientation and size" , EOL; -$objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT); -$objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4); +$objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel\Worksheet_PageSetup::ORIENTATION_PORTRAIT); +$objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel\Worksheet_PageSetup::PAPERSIZE_A4); // Rename worksheet @@ -159,7 +159,7 @@ $objPHPExcel->setActiveSheetIndex(0); echo date('H:i:s') , " Write to Excel2007 format" , EOL; $callStartTime = microtime(true); -$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); +$objWriter = PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save(str_replace('.php', '.xlsx', __FILE__)); $callEndTime = microtime(true); $callTime = $callEndTime - $callStartTime; @@ -170,7 +170,7 @@ echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" echo date('H:i:s') , " Write to Excel5 format" , EOL; $callStartTime = microtime(true); -$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); +$objWriter = PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter->save(str_replace('.php', '.xls', __FILE__)); $callEndTime = microtime(true); $callTime = $callEndTime - $callStartTime; diff --git a/Examples/08conditionalformatting2.php b/Examples/08conditionalformatting2.php index b59c66d..0bae0f6 100644 --- a/Examples/08conditionalformatting2.php +++ b/Examples/08conditionalformatting2.php @@ -34,13 +34,13 @@ define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '
'); date_default_timezone_set('Europe/London'); -/** Include PHPExcel */ -require_once '../Classes/PHPExcel.php'; +/** Include PHPExcel Bootstrap */ +require_once '../Classes/Bootstrap.php'; -// Create new PHPExcel object -echo date('H:i:s') , " Create new PHPExcel object" , EOL; -$objPHPExcel = new PHPExcel(); +// Create new PHPExcel Workbook object +echo date('H:i:s') , " Create new PHPExcel Workbook object" , EOL; +$objPHPExcel = new PHPExcel\Workbook(); // Set document properties echo date('H:i:s') , " Set document properties" , EOL; @@ -70,23 +70,23 @@ $objPHPExcel->getActiveSheet() $objPHPExcel->getActiveSheet()->getStyle('A1:A8') ->getNumberFormat() ->setFormatCode( - PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00 + PHPExcel\Style_NumberFormat::FORMAT_PERCENTAGE_00 ); // Add conditional formatting echo date('H:i:s') , " Add conditional formatting" , EOL; -$objConditional1 = new PHPExcel_Style_Conditional(); -$objConditional1->setConditionType(PHPExcel_Style_Conditional::CONDITION_CELLIS) - ->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_LESSTHAN) +$objConditional1 = new PHPExcel\Style_Conditional(); +$objConditional1->setConditionType(PHPExcel\Style_Conditional::CONDITION_CELLIS) + ->setOperatorType(PHPExcel\Style_Conditional::OPERATOR_LESSTHAN) ->addCondition('0'); -$objConditional1->getStyle()->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_RED); +$objConditional1->getStyle()->getFont()->getColor()->setARGB(PHPExcel\Style_Color::COLOR_RED); -$objConditional3 = new PHPExcel_Style_Conditional(); -$objConditional3->setConditionType(PHPExcel_Style_Conditional::CONDITION_CELLIS) - ->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_GREATERTHANOREQUAL) +$objConditional3 = new PHPExcel\Style_Conditional(); +$objConditional3->setConditionType(PHPExcel\Style_Conditional::CONDITION_CELLIS) + ->setOperatorType(PHPExcel\Style_Conditional::OPERATOR_GREATERTHANOREQUAL) ->addCondition('1'); -$objConditional3->getStyle()->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_GREEN); +$objConditional3->getStyle()->getFont()->getColor()->setARGB(PHPExcel\Style_Color::COLOR_GREEN); $conditionalStyles = $objPHPExcel->getActiveSheet()->getStyle('A1')->getConditionalStyles(); array_push($conditionalStyles, $objConditional1); @@ -106,7 +106,7 @@ $objPHPExcel->getActiveSheet()->duplicateConditionalStyle( echo date('H:i:s') , " Write to Excel2007 format" , EOL; $callStartTime = microtime(true); -$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); +$objWriter = PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save(str_replace('.php', '.xlsx', __FILE__)); $callEndTime = microtime(true); $callTime = $callEndTime - $callStartTime; @@ -117,7 +117,7 @@ echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" echo date('H:i:s') , " Write to Excel5 format" , EOL; $callStartTime = microtime(true); -$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); +$objWriter = PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter->save(str_replace('.php', '.xls', __FILE__)); $callEndTime = microtime(true); $callTime = $callEndTime - $callStartTime; diff --git a/Examples/09pagebreaks.php b/Examples/09pagebreaks.php index f37f763..a65e216 100644 --- a/Examples/09pagebreaks.php +++ b/Examples/09pagebreaks.php @@ -35,12 +35,13 @@ define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '
'); date_default_timezone_set('Europe/London'); /** Include PHPExcel */ -require_once '../Classes/PHPExcel.php'; +/** Include PHPExcel Bootstrap */ +require_once '../Classes/Bootstrap.php'; -// Create new PHPExcel object -echo date('H:i:s') , " Create new PHPExcel object" , EOL; -$objPHPExcel = new PHPExcel(); +// Create new PHPExcel Workbook object +echo date('H:i:s') , " Create new PHPExcel Workbook object" , EOL; +$objPHPExcel = new PHPExcel\Workbook(); // Set document properties echo date('H:i:s') , " Set document properties" , EOL; @@ -74,7 +75,7 @@ for ($i = 2; $i <= 50; $i++) { // Add page breaks every 10 rows if ($i % 10 == 0) { // Add a page break - $objPHPExcel->getActiveSheet()->setBreak( 'A' . $i, PHPExcel_Worksheet::BREAK_ROW ); + $objPHPExcel->getActiveSheet()->setBreak( 'A' . $i, PHPExcel\Worksheet::BREAK_ROW ); } } @@ -87,7 +88,7 @@ $objPHPExcel->setActiveSheetIndex(0); echo date('H:i:s') , " Write to Excel2007 format" , EOL; $callStartTime = microtime(true); -$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); +$objWriter = PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save(str_replace('.php', '.xlsx', __FILE__)); $callEndTime = microtime(true); $callTime = $callEndTime - $callStartTime; @@ -102,7 +103,7 @@ echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 echo date('H:i:s') , " Write to Excel5 format" , EOL; $callStartTime = microtime(true); -$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); +$objWriter = PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter->save(str_replace('.php', '.xls', __FILE__)); $callEndTime = microtime(true); $callTime = $callEndTime - $callStartTime;