diff --git a/Tests/07reader.php b/Tests/07reader.php index ec09e4ee..5b14b944 100644 --- a/Tests/07reader.php +++ b/Tests/07reader.php @@ -34,7 +34,7 @@ require_once '../Classes/PHPExcel/IOFactory.php'; if (!file_exists("05featuredemo.xlsx")) { - exit("Please run 05featuredemo.php first.\n"); + exit("Please run 05featuredemo.php first." . PHP_EOL); } echo date('H:i:s') , " Load from Excel2007 file" , PHP_EOL; diff --git a/Tests/19namedrange.php b/Tests/19namedrange.php index 0603d2fd..20098c89 100644 --- a/Tests/19namedrange.php +++ b/Tests/19namedrange.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (C) 2006 - 2011 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 @@ -20,7 +20,7 @@ * * @category PHPExcel * @package PHPExcel - * @copyright Copyright (c) 2006 - 2011 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## */ @@ -30,16 +30,16 @@ error_reporting(E_ALL); date_default_timezone_set('Europe/London'); -/** PHPExcel */ +/** Include PHPExcel */ require_once '../Classes/PHPExcel.php'; // Create new PHPExcel object -echo date('H:i:s') . " Create new PHPExcel object\n"; +echo date('H:i:s') , " Create new PHPExcel object" , PHP_EOL; $objPHPExcel = new PHPExcel(); -// Set properties -echo date('H:i:s') . " Set properties\n"; +// Set document properties +echo date('H:i:s') , " Set document properties" , PHP_EOL; $objPHPExcel->getProperties()->setCreator("Maarten Balliauw") ->setLastModifiedBy("Maarten Balliauw") ->setTitle("Office 2007 XLSX Test Document") @@ -50,51 +50,51 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw") // Add some data -echo date('H:i:s') . " Add some data\n"; +echo date('H:i:s') , " Add some data" , PHP_EOL; $objPHPExcel->setActiveSheetIndex(0); -$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Firstname:'); -$objPHPExcel->getActiveSheet()->setCellValue('A2', 'Lastname:'); -$objPHPExcel->getActiveSheet()->setCellValue('A3', 'Fullname:'); -$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Maarten'); -$objPHPExcel->getActiveSheet()->setCellValue('B2', 'Balliauw'); -$objPHPExcel->getActiveSheet()->setCellValue('B3', '=B1 & " " & B2'); +$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Firstname:') + ->setCellValue('A2', 'Lastname:') + ->setCellValue('A3', 'Fullname:') + ->setCellValue('B1', 'Maarten') + ->setCellValue('B2', 'Balliauw') + ->setCellValue('B3', '=B1 & " " & B2'); // Define named ranges -echo date('H:i:s') . " Define named ranges\n"; +echo date('H:i:s') , " Define named ranges" , PHP_EOL; $objPHPExcel->addNamedRange( new PHPExcel_NamedRange('PersonName', $objPHPExcel->getActiveSheet(), 'B1') ); $objPHPExcel->addNamedRange( new PHPExcel_NamedRange('PersonLN', $objPHPExcel->getActiveSheet(), 'B2') ); // Rename named ranges -echo date('H:i:s') . " Rename named ranges\n"; +echo date('H:i:s') , " Rename named ranges" , PHP_EOL; $objPHPExcel->getNamedRange('PersonName')->setName('PersonFN'); -// Rename sheet -echo date('H:i:s') . " Rename sheet\n"; +// Rename worksheet +echo date('H:i:s') , " Rename worksheet" , PHP_EOL; $objPHPExcel->getActiveSheet()->setTitle('Person'); // Create a new worksheet, after the default sheet -echo date('H:i:s') . " Create new Worksheet object\n"; +echo date('H:i:s') , " Create new Worksheet object" , PHP_EOL; $objPHPExcel->createSheet(); // Add some data to the second sheet, resembling some different data types -echo date('H:i:s') . " Add some data\n"; +echo date('H:i:s') , " Add some data" , PHP_EOL; $objPHPExcel->setActiveSheetIndex(1); -$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Firstname:'); -$objPHPExcel->getActiveSheet()->setCellValue('A2', 'Lastname:'); -$objPHPExcel->getActiveSheet()->setCellValue('A3', 'Fullname:'); -$objPHPExcel->getActiveSheet()->setCellValue('B1', '=PersonFN'); -$objPHPExcel->getActiveSheet()->setCellValue('B2', '=PersonLN'); -$objPHPExcel->getActiveSheet()->setCellValue('B3', '=PersonFN & " " & PersonLN'); +$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Firstname:') + ->setCellValue('A2', 'Lastname:') + ->setCellValue('A3', 'Fullname:') + ->setCellValue('B1', '=PersonFN') + ->setCellValue('B2', '=PersonLN') + ->setCellValue('B3', '=PersonFN & " " & PersonLN'); // Resolve range -echo date('H:i:s') . " Resolve range\n"; -echo 'Cell B1 {=PersonFN}: ' . $objPHPExcel->getActiveSheet()->getCell('B1')->getCalculatedValue() . "\n"; -echo 'Cell B3 {=PersonFN & " " & PersonLN}: ' . $objPHPExcel->getActiveSheet()->getCell('B3')->getCalculatedValue() . "\n"; -echo 'Cell Person!B1: ' . $objPHPExcel->getActiveSheet()->getCell('Person!B1')->getCalculatedValue() . "\n"; +echo date('H:i:s') , " Resolve range" , PHP_EOL; +echo 'Cell B1 {=PersonFN}: ' , $objPHPExcel->getActiveSheet()->getCell('B1')->getCalculatedValue() , PHP_EOL; +echo 'Cell B3 {=PersonFN & " " & PersonLN}: ' , $objPHPExcel->getActiveSheet()->getCell('B3')->getCalculatedValue() , PHP_EOL; +echo 'Cell Person!B1: ' , $objPHPExcel->getActiveSheet()->getCell('Person!B1')->getCalculatedValue() , PHP_EOL; -// Rename sheet -echo date('H:i:s') . " Rename sheet\n"; +// Rename worksheet +echo date('H:i:s') , " Rename worksheet" , PHP_EOL; $objPHPExcel->getActiveSheet()->setTitle('Person (cloned)'); // Set active sheet index to the first sheet, so Excel opens this as the first sheet @@ -102,13 +102,14 @@ $objPHPExcel->setActiveSheetIndex(0); // Save Excel 2007 file -echo date('H:i:s') . " Write to Excel2007 format\n"; +echo date('H:i:s') , " Write to Excel2007 format" , 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\r\n"; +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 file.\r\n"; +echo date('H:i:s') , " Done writing file" , PHP_EOL; diff --git a/Tests/20readexcel5.php b/Tests/20readexcel5.php index a227fb57..f763257f 100644 --- a/Tests/20readexcel5.php +++ b/Tests/20readexcel5.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (C) 2006 - 2011 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 @@ -20,7 +20,7 @@ * * @category PHPExcel * @package PHPExcel - * @copyright Copyright (c) 2006 - 2011 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## */ @@ -30,7 +30,7 @@ error_reporting(E_ALL); date_default_timezone_set('Europe/London'); -/** PHPExcel_IOFactory */ +/** Include PHPExcel_IOFactory */ require_once '../Classes/PHPExcel/IOFactory.php'; @@ -38,16 +38,17 @@ if (!file_exists("14excel5.xls")) { exit("Please run 14excel5.php first.\n"); } -echo date('H:i:s') . " Load from Excel5 file\n"; +echo date('H:i:s') , " Load workbook from Excel5 file" , PHP_EOL; $objPHPExcel = PHPExcel_IOFactory::load("14excel5.xls"); -echo date('H:i:s') . " Write to Excel2007 format\n"; +echo date('H:i:s') , " Write to Excel2007 format" , 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\r\n"; +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 reading file.\r\n"; +echo date('H:i:s') , " Done reading file" , PHP_EOL; diff --git a/Tests/21pdf.php b/Tests/21pdf.php index 3bda1061..d1042279 100644 --- a/Tests/21pdf.php +++ b/Tests/21pdf.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (C) 2006 - 2011 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 @@ -20,7 +20,7 @@ * * @category PHPExcel * @package PHPExcel - * @copyright Copyright (c) 2006 - 2011 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## */ @@ -36,20 +36,21 @@ include "05featuredemo.inc.php"; require_once '../Classes/PHPExcel/IOFactory.php'; -echo date('H:i:s') . " Hide grid lines\n"; +echo date('H:i:s') , " Hide grid lines" , PHP_EOL; $objPHPExcel->getActiveSheet()->setShowGridLines(false); -echo date('H:i:s') . " Set orientation to landscape\n"; +echo date('H:i:s') , " Set orientation to landscape" , PHP_EOL; $objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE); -echo date('H:i:s') . " Write to PDF format\n"; +echo date('H:i:s') , " Write to PDF format" , PHP_EOL; $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF'); $objWriter->setSheetIndex(0); $objWriter->save(str_replace('.php', '.pdf', __FILE__)); +echo date('H:i:s') , " File written to " , str_replace('.php', '.pdf', __FILE__) , PHP_EOL; // Echo memory peak usage -echo date('H:i:s') . " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB\r\n"; +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.\r\n"; +echo date('H:i:s') , " Done writing files" , PHP_EOL; diff --git a/Tests/22heavilyformatted.php b/Tests/22heavilyformatted.php index 179fa49e..5ddd978a 100644 --- a/Tests/22heavilyformatted.php +++ b/Tests/22heavilyformatted.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (C) 2006 - 2011 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 @@ -20,7 +20,7 @@ * * @category PHPExcel * @package PHPExcel - * @copyright Copyright (c) 2006 - 2011 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## */ @@ -30,16 +30,16 @@ error_reporting(E_ALL); date_default_timezone_set('Europe/London'); -/** PHPExcel */ +/** Include PHPExcel */ require_once '../Classes/PHPExcel.php'; // Create new PHPExcel object -echo date('H:i:s') . " Create new PHPExcel object\n"; +echo date('H:i:s') , " Create new PHPExcel object" , PHP_EOL; $objPHPExcel = new PHPExcel(); -// Set properties -echo date('H:i:s') . " Set properties\n"; +// Set document properties +echo date('H:i:s') , " Set document properties" , PHP_EOL; $objPHPExcel->getProperties()->setCreator("Maarten Balliauw") ->setLastModifiedBy("Maarten Balliauw") ->setTitle("Office 2007 XLSX Test Document") @@ -50,7 +50,7 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw") // Add some data -echo date('H:i:s') . " Add some data\n"; +echo date('H:i:s') , " Add some data" , PHP_EOL; $objPHPExcel->setActiveSheetIndex(0); $objPHPExcel->getActiveSheet()->getStyle('A1:T100')->applyFromArray( @@ -74,17 +74,14 @@ $objPHPExcel->getActiveSheet()->getStyle('C5:R95')->applyFromArray( ); // Save Excel 2007 file -echo date('H:i:s') . " Write to Excel2007 format\n"; +echo date('H:i:s') , " Write to Excel2007 format" , 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\r\n"; +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 file.\r\n"; - - - -?> +echo date('H:i:s') , " Done writing file" , PHP_EOL; diff --git a/Tests/23sharedstyles.php b/Tests/23sharedstyles.php index c541cce8..95e4fb5d 100644 --- a/Tests/23sharedstyles.php +++ b/Tests/23sharedstyles.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (C) 2006 - 2011 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 @@ -20,7 +20,7 @@ * * @category PHPExcel * @package PHPExcel - * @copyright Copyright (c) 2006 - 2011 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## */ @@ -30,16 +30,16 @@ error_reporting(E_ALL); date_default_timezone_set('Europe/London'); -/** PHPExcel */ +/** Include PHPExcel */ require_once '../Classes/PHPExcel.php'; // Create new PHPExcel object -echo date('H:i:s') . " Create new PHPExcel object\n"; +echo date('H:i:s') , " Create new PHPExcel object" , PHP_EOL; $objPHPExcel = new PHPExcel(); -// Set properties -echo date('H:i:s') . " Set properties\n"; +// Set document properties +echo date('H:i:s') , " Set document properties" , PHP_EOL; $objPHPExcel->getProperties()->setCreator("Maarten Balliauw") ->setLastModifiedBy("Maarten Balliauw") ->setTitle("Office 2007 XLSX Test Document") @@ -50,7 +50,7 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw") // Add some data -echo date('H:i:s') . " Add some data\n"; +echo date('H:i:s') , " Add some data" , PHP_EOL; $objPHPExcel->setActiveSheetIndex(0); $sharedStyle1 = new PHPExcel_Style(); @@ -82,13 +82,14 @@ $objPHPExcel->getActiveSheet()->setSharedStyle($sharedStyle1, "A1:T100"); $objPHPExcel->getActiveSheet()->setSharedStyle($sharedStyle2, "C5:R95"); // Save Excel 2007 file -echo date('H:i:s') . " Write to Excel2007 format\n"; +echo date('H:i:s') , " Write to Excel2007 format" , 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\r\n"; +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 file.\r\n"; +echo date('H:i:s') , " Done writing file" , PHP_EOL; diff --git a/Tests/24readfilter.php b/Tests/24readfilter.php index 715116ee..d695e0f1 100644 --- a/Tests/24readfilter.php +++ b/Tests/24readfilter.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (C) 2006 - 2011 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 @@ -20,7 +20,7 @@ * * @category PHPExcel * @package PHPExcel - * @copyright Copyright (c) 2006 - 2011 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## */ @@ -51,21 +51,22 @@ class MyReadFilter implements PHPExcel_Reader_IReadFilter } -echo date('H:i:s') . " Load from Excel2007 file\n"; +echo date('H:i:s') , " Load from Excel2007 file" , PHP_EOL; $objReader = PHPExcel_IOFactory::createReader('Excel2007'); $objReader->setReadFilter( new MyReadFilter() ); $objPHPExcel = $objReader->load("06largescale.xlsx"); -echo date('H:i:s') . " Remove unnecessary rows\n"; +echo date('H:i:s') , " Remove unnecessary rows" , PHP_EOL; $objPHPExcel->getActiveSheet()->removeRow(2, 18); -echo date('H:i:s') . " Write to Excel2007 format\n"; +echo date('H:i:s') , " Write to Excel2007 format" , 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\r\n"; +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.\r\n"; +echo date('H:i:s') , " Done writing files" , PHP_EOL; diff --git a/Tests/25inmemoryimage.php b/Tests/25inmemoryimage.php index 3483a024..1b99cfc4 100644 --- a/Tests/25inmemoryimage.php +++ b/Tests/25inmemoryimage.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (C) 2006 - 2011 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 @@ -20,7 +20,7 @@ * * @category PHPExcel * @package PHPExcel - * @copyright Copyright (c) 2006 - 2011 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## */ @@ -30,16 +30,16 @@ error_reporting(E_ALL); date_default_timezone_set('Europe/London'); -/** PHPExcel */ +/** Include PHPExcel */ require_once '../Classes/PHPExcel.php'; // Create new PHPExcel object -echo date('H:i:s') . " Create new PHPExcel object\n"; +echo date('H:i:s') , " Create new PHPExcel object" , PHP_EOL; $objPHPExcel = new PHPExcel(); -// Set properties -echo date('H:i:s') . " Set properties\n"; +// Set document properties +echo date('H:i:s') , " Set document properties" , PHP_EOL; $objPHPExcel->getProperties()->setCreator("Maarten Balliauw") ->setLastModifiedBy("Maarten Balliauw") ->setTitle("Office 2007 XLSX Test Document") @@ -49,13 +49,13 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw") ->setCategory("Test result file"); // Generate an image -echo date('H:i:s') . " Generate an image\n"; +echo date('H:i:s') , " Generate an image" , PHP_EOL; $gdImage = @imagecreatetruecolor(120, 20) or die('Cannot Initialize new GD image stream'); $textColor = imagecolorallocate($gdImage, 255, 255, 255); imagestring($gdImage, 1, 5, 5, 'Created with PHPExcel', $textColor); // Add a drawing to the worksheet -echo date('H:i:s') . " Add a drawing to the worksheet\n"; +echo date('H:i:s') , " Add a drawing to the worksheet" , PHP_EOL; $objDrawing = new PHPExcel_Worksheet_MemoryDrawing(); $objDrawing->setName('Sample image'); $objDrawing->setDescription('Sample image'); @@ -65,13 +65,14 @@ $objDrawing->setMimeType(PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_DEFAULT); $objDrawing->setHeight(36); $objDrawing->setWorksheet($objPHPExcel->getActiveSheet()); -echo date('H:i:s') . " Write to Excel2007 format\n"; +echo date('H:i:s') , " Write to Excel2007 format" , 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\r\n"; +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.\r\n"; +echo date('H:i:s') , " Done writing files" , PHP_EOL; diff --git a/Tests/26utf8.php b/Tests/26utf8.php index 45f728f7..41e85af2 100644 --- a/Tests/26utf8.php +++ b/Tests/26utf8.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (C) 2006 - 2011 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 @@ -20,7 +20,7 @@ * * @category PHPExcel * @package PHPExcel - * @copyright Copyright (c) 2006 - 2011 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## */ @@ -30,59 +30,61 @@ error_reporting(E_ALL); date_default_timezone_set('Europe/London'); -/** PHPExcel */ +/** Include PHPExcel */ require_once '../Classes/PHPExcel.php'; -// Create new PHPExcel object -echo date('H:i:s') . " Create new PHPExcel object\n"; -$objPHPExcel = new PHPExcel(); - // Read from Excel2007 (.xlsx) template -echo date('H:i:s') . " Load Excel2007 template file\n"; +echo date('H:i:s') , " Load Excel2007 template file" , PHP_EOL; $objReader = PHPExcel_IOFactory::createReader('Excel2007'); $objPHPExcel = $objReader->load("templates/26template.xlsx"); /** at this point, we could do some manipulations with the template, but we skip this step */ // Export to Excel2007 (.xlsx) -echo date('H:i:s') . " Write to Excel5 format\n"; +echo date('H:i:s') , " Write to Excel5 format" , 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; // Export to Excel5 (.xls) -echo date('H:i:s') . " Write to Excel5 format\n"; +echo date('H:i:s') , " Write to Excel5 format" , PHP_EOL; $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter->save(str_replace('.php', '.xls', __FILE__)); +echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', __FILE__) , PHP_EOL; // Export to HTML (.html) -echo date('H:i:s') . " Write to HTML format\n"; +echo date('H:i:s') , " Write to HTML format" , PHP_EOL; $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'HTML'); $objWriter->save(str_replace('.php', '.htm', __FILE__)); +echo date('H:i:s') , " File written to " , str_replace('.php', '.htm', __FILE__) , PHP_EOL; // Export to PDF (.pdf) -echo date('H:i:s') . " Write to PDF format\n"; +echo date('H:i:s') , " Write to PDF format" , PHP_EOL; $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF'); $objWriter->save(str_replace('.php', '.pdf', __FILE__)); +echo date('H:i:s') , " File written to " , str_replace('.php', '.pdf', __FILE__) , PHP_EOL; // Remove first two rows with field headers before exporting to CSV -echo date('H:i:s') . " Removing first two rows\n"; +echo date('H:i:s') , " Removing first two heading rows for CSV export" , PHP_EOL; $objWorksheet = $objPHPExcel->getActiveSheet(); $objWorksheet->removeRow(1, 2); // Export to CSV (.csv) -echo date('H:i:s') . " Write to CSV format\n"; +echo date('H:i:s') , " Write to CSV format" , PHP_EOL; $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'CSV'); $objWriter->save(str_replace('.php', '.csv', __FILE__)); +echo date('H:i:s') , " File written to " , str_replace('.php', '.csv', __FILE__) , PHP_EOL; // Export to CSV with BOM (.csv) -echo date('H:i:s') . " Write to CSV format (with BOM)\n"; +echo date('H:i:s') , " Write to CSV format (with BOM)" , PHP_EOL; $objWriter->setUseBOM(true); $objWriter->save(str_replace('.php', '-bom.csv', __FILE__)); +echo date('H:i:s') , " File written to " , str_replace('.php', '-bom.csv', __FILE__) , PHP_EOL; // Echo memory peak usage -echo date('H:i:s') . " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB\r\n"; +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.\r\n"; +echo date('H:i:s') , " Done writing files" , PHP_EOL; diff --git a/Tests/27imagesexcel5.php b/Tests/27imagesexcel5.php index 17243a92..7f95c90f 100644 --- a/Tests/27imagesexcel5.php +++ b/Tests/27imagesexcel5.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (C) 2006 - 2011 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 @@ -20,7 +20,7 @@ * * @category PHPExcel * @package PHPExcel - * @copyright Copyright (c) 2006 - 2011 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## */ @@ -30,32 +30,30 @@ error_reporting(E_ALL); date_default_timezone_set('Europe/London'); -/** PHPExcel */ +/** Include PHPExcel */ require_once '../Classes/PHPExcel.php'; -// Create new PHPExcel object -echo date('H:i:s') . " Create new PHPExcel object\n"; -$objPHPExcel = new PHPExcel(); - // Read from Excel5 (.xls) template -echo date('H:i:s') . " Load Excel2007 template file\n"; +echo date('H:i:s') , " Load Excel2007 template file" , PHP_EOL; $objReader = PHPExcel_IOFactory::createReader('Excel5'); $objPHPExcel = $objReader->load("templates/27template.xls"); // Export to Excel2007 (.xlsx) -echo date('H:i:s') . " Write to Excel5 format\n"; +echo date('H:i:s') , " Write to Excel5 format" , 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; // Export to Excel5 (.xls) -echo date('H:i:s') . " Write to Excel5 format\n"; +echo date('H:i:s') , " Write to Excel5 format" , PHP_EOL; $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter->save(str_replace('.php', '.xls', __FILE__)); +echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', __FILE__) , PHP_EOL; // Echo memory peak usage -echo date('H:i:s') . " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB\r\n"; +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.\r\n"; +echo date('H:i:s') , " Done writing files" , PHP_EOL; diff --git a/Tests/28iterator.php b/Tests/28iterator.php index 0e209c27..52fbfce0 100644 --- a/Tests/28iterator.php +++ b/Tests/28iterator.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (C) 2006 - 2011 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 @@ -20,7 +20,7 @@ * * @category PHPExcel * @package PHPExcel - * @copyright Copyright (c) 2006 - 2011 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## */ @@ -35,25 +35,25 @@ require_once '../Classes/PHPExcel/IOFactory.php'; if (!file_exists("05featuredemo.xlsx")) { - exit("Please run 05featuredemo.php first.\n"); + exit("Please run 05featuredemo.php first." . PHP_EOL); } -echo date('H:i:s') . " Load from Excel2007 file\n"; +echo date('H:i:s') , " Load from Excel2007 file" , PHP_EOL; $objReader = PHPExcel_IOFactory::createReader('Excel2007'); $objPHPExcel = $objReader->load("05featuredemo.xlsx"); -echo date('H:i:s') . " Iterate worksheets\n"; +echo date('H:i:s') , " Iterate worksheets" , PHP_EOL; foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) { - echo '- ' . $worksheet->getTitle() . "\r\n"; + echo 'Worksheet - ' , $worksheet->getTitle() , PHP_EOL; foreach ($worksheet->getRowIterator() as $row) { - echo ' - Row number: ' . $row->getRowIndex() . "\r\n"; + echo ' Row number - ' , $row->getRowIndex() , PHP_EOL; $cellIterator = $row->getCellIterator(); $cellIterator->setIterateOnlyExistingCells(false); // Loop all cells, even if it is not set foreach ($cellIterator as $cell) { if (!is_null($cell)) { - echo ' - Cell: ' . $cell->getCoordinate() . ' - ' . $cell->getCalculatedValue() . "\r\n"; + echo ' Cell - ' , $cell->getCoordinate() , ' - ' , $cell->getCalculatedValue() , PHP_EOL; } } } @@ -61,7 +61,4 @@ foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) { // Echo memory peak usage -echo date('H:i:s') . " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB\r\n"; - -// Echo done -echo date('H:i:s') . " Done writing files.\r\n"; +echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL; diff --git a/Tests/29advancedvaluebinder.php b/Tests/29advancedvaluebinder.php index 4e5564ab..c58911b1 100644 --- a/Tests/29advancedvaluebinder.php +++ b/Tests/29advancedvaluebinder.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (C) 2006 - 2011 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 @@ -20,7 +20,7 @@ * * @category PHPExcel * @package PHPExcel - * @copyright Copyright (c) 2006 - 2011 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## */ @@ -35,19 +35,19 @@ require_once '../Classes/PHPExcel.php'; // Set timezone -echo date('H:i:s') . " Set timezone\n"; +echo date('H:i:s') , " Set timezone" , PHP_EOL; date_default_timezone_set('UTC'); // Set value binder -echo date('H:i:s') . " Set value binder\n"; +echo date('H:i:s') , " Set value binder" , PHP_EOL; PHPExcel_Cell::setValueBinder( new PHPExcel_Cell_AdvancedValueBinder() ); // Create new PHPExcel object -echo date('H:i:s') . " Create new PHPExcel object\n"; +echo date('H:i:s') , " Create new PHPExcel object" , PHP_EOL; $objPHPExcel = new PHPExcel(); -// Set properties -echo date('H:i:s') . " Set properties\n"; +// Set document properties +echo date('H:i:s') , " Set document properties" , PHP_EOL; $objPHPExcel->getProperties()->setCreator("Maarten Balliauw") ->setLastModifiedBy("Maarten Balliauw") ->setTitle("Office 2007 XLSX Test Document") @@ -57,17 +57,17 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw") ->setCategory("Test result file"); // Set default font -echo date('H:i:s') . " Set default font\n"; +echo date('H:i:s') , " Set default font" , PHP_EOL; $objPHPExcel->getActiveSheet()->getDefaultStyle()->getFont()->setName('Arial'); $objPHPExcel->getActiveSheet()->getDefaultStyle()->getFont()->setSize(10); // Set column widths -echo date('H:i:s') . " Set column widths\n"; +echo date('H:i:s') , " Set column widths" , PHP_EOL; $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setAutoSize(true); $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(14); // Add some data, resembling some different data types -echo date('H:i:s') . " Add some data\n"; +echo date('H:i:s') , " Add some data" , PHP_EOL; $objPHPExcel->getActiveSheet()->setCellValue('A1', 'String value:'); $objPHPExcel->getActiveSheet()->setCellValue('B1', 'Mark Baker'); @@ -131,8 +131,8 @@ $objPHPExcel->getActiveSheet()->setCellValue('B20', '19-Dec-1960 01:30'); $objPHPExcel->getActiveSheet()->setCellValue('A21', 'Formula:'); $objPHPExcel->getActiveSheet()->setCellValue('B21', '=SUM(B2:B9)'); -// Rename sheet -echo date('H:i:s') . " Rename sheet\n"; +// Rename worksheet +echo date('H:i:s') , " Rename worksheet" , PHP_EOL; $objPHPExcel->getActiveSheet()->setTitle('Advanced value binder'); @@ -141,13 +141,14 @@ $objPHPExcel->setActiveSheetIndex(0); // Save Excel 2007 file -echo date('H:i:s') . " Write to Excel5 format\n"; +echo date('H:i:s') , " Write to Excel5 format" , PHP_EOL; $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter->save(str_replace('.php', '.xls', __FILE__)); +echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', __FILE__) , PHP_EOL; // Echo memory peak usage -echo date('H:i:s') . " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB\r\n"; +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 file.\r\n"; +echo date('H:i:s') , " Done writing file" , PHP_EOL; diff --git a/Tests/30template.php b/Tests/30template.php index ed2641af..d601bea0 100644 --- a/Tests/30template.php +++ b/Tests/30template.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (C) 2006 - 2011 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 @@ -20,7 +20,7 @@ * * @category PHPExcel * @package PHPExcel - * @copyright Copyright (c) 2006 - 2011 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## */ @@ -35,14 +35,14 @@ require_once '../Classes/PHPExcel/IOFactory.php'; -echo date('H:i:s') . " Load from Excel5 template\n"; +echo date('H:i:s') , " Load from Excel5 template" , PHP_EOL; $objReader = PHPExcel_IOFactory::createReader('Excel5'); $objPHPExcel = $objReader->load("templates/30template.xls"); -echo date('H:i:s') . " Add new data to the template\n"; +echo date('H:i:s') , " Add new data to the template" , PHP_EOL; $data = array(array('title' => 'Excel for dummies', 'price' => 17.99, 'quantity' => 2 @@ -73,17 +73,14 @@ foreach($data as $r => $dataRow) { $objPHPExcel->getActiveSheet()->removeRow($baseRow-1,1); - - -echo date('H:i:s') . " Write to Excel5 format\n"; +echo date('H:i:s') , " Write to Excel5 format" , PHP_EOL; $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter->save(str_replace('.php', '.xls', __FILE__)); - - +echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', __FILE__) , PHP_EOL; // Echo memory peak usage -echo date('H:i:s') . " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB\r\n"; +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 file.\r\n"; +echo date('H:i:s') , " Done writing file" , PHP_EOL; diff --git a/Tests/31docproperties_write-xls.php b/Tests/31docproperties_write-xls.php new file mode 100644 index 00000000..58e2269a --- /dev/null +++ b/Tests/31docproperties_write-xls.php @@ -0,0 +1,115 @@ +load($inputFileName); + +$callEndTime = microtime(true); +$callTime = $callEndTime - $callStartTime; +echo 'Call time to read Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , PHP_EOL; +// Echo memory usage +echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , PHP_EOL; + + +echo date('H:i:s') , " Adjust properties" , PHP_EOL; +$objPHPExcel->getProperties()->setTitle("Office 95 XLS Test Document") + ->setSubject("Office 95 XLS Test Document") + ->setDescription("Test XLS document, generated using PHPExcel") + ->setKeywords("office 95 biff php"); + + +// Save Excel 95 file +echo date('H:i:s') , " Write to Excel5 format" , PHP_EOL; +$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); +$objWriter->save(str_replace('.php', '.xls', __FILE__)); +echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', __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 PHP_EOL; +// Reread File +echo date('H:i:s') , " Reread Excel5 file" , PHP_EOL; +$objPHPExcelRead = PHPExcel_IOFactory::load(str_replace('.php', '.xls', __FILE__)); + +// Set properties +echo date('H:i:s') , " Get properties" , PHP_EOL; + +echo 'Core Properties:' , PHP_EOL; +echo ' Created by - ' , $objPHPExcel->getProperties()->getCreator() , PHP_EOL; +echo ' Created on - ' , date('d-M-Y',$objPHPExcel->getProperties()->getCreated()) , ' at ' , + date('H:i:s',$objPHPExcel->getProperties()->getCreated()) , PHP_EOL; +echo ' Last Modified by - ' , $objPHPExcel->getProperties()->getLastModifiedBy() , PHP_EOL; +echo ' Last Modified on - ' , date('d-M-Y',$objPHPExcel->getProperties()->getModified()) , ' at ' , + date('H:i:s',$objPHPExcel->getProperties()->getModified()) , PHP_EOL; +echo ' Title - ' , $objPHPExcel->getProperties()->getTitle() , PHP_EOL; +echo ' Subject - ' , $objPHPExcel->getProperties()->getSubject() , PHP_EOL; +echo ' Description - ' , $objPHPExcel->getProperties()->getDescription() , PHP_EOL; +echo ' Keywords: - ' , $objPHPExcel->getProperties()->getKeywords() , PHP_EOL; + + +echo 'Extended (Application) Properties:' , PHP_EOL; +echo ' Category - ' , $objPHPExcel->getProperties()->getCategory() , PHP_EOL; +echo ' Company - ' , $objPHPExcel->getProperties()->getCompany() , PHP_EOL; +echo ' Manager - ' , $objPHPExcel->getProperties()->getManager() , PHP_EOL; + + +echo 'Custom Properties:' , PHP_EOL; +$customProperties = $objPHPExcel->getProperties()->getCustomProperties(); +foreach($customProperties as $customProperty) { + $propertyValue = $objPHPExcel->getProperties()->getCustomPropertyValue($customProperty); + $propertyType = $objPHPExcel->getProperties()->getCustomPropertyType($customProperty); + echo ' ' , $customProperty , ' - (' , $propertyType , ') - '; + if ($propertyType == PHPExcel_DocumentProperties::PROPERTY_TYPE_DATE) { + echo date('d-M-Y H:i:s',$propertyValue) , PHP_EOL; + } elseif ($propertyType == PHPExcel_DocumentProperties::PROPERTY_TYPE_BOOLEAN) { + echo (($propertyValue) ? 'TRUE' : 'FALSE') , PHP_EOL; + } else { + echo $propertyValue , PHP_EOL; + } +} + +// Echo memory peak usage +echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) . " MB" , PHP_EOL; diff --git a/Tests/31docproperties_write.php b/Tests/31docproperties_write.php index b76e1001..c3ef6a8a 100644 --- a/Tests/31docproperties_write.php +++ b/Tests/31docproperties_write.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (C) 2006 - 2011 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 @@ -20,7 +20,7 @@ * * @category PHPExcel * @package PHPExcel - * @copyright Copyright (c) 2006 - 2011 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## */ @@ -30,77 +30,86 @@ error_reporting(E_ALL); date_default_timezone_set('Europe/London'); -/** PHPExcel */ +/** Include PHPExcel */ require_once '../Classes/PHPExcel.php'; -// Create new PHPExcel object -echo date('H:i:s') . " Create new PHPExcel object" , PHP_EOL; -$objPHPExcel = new PHPExcel(); +$inputFileType = 'Excel2007'; +$inputFileName = 'templates/31docproperties.xlsx'; -// Set properties -echo date('H:i:s') . " Set properties" , PHP_EOL; -$objPHPExcel->getProperties()->setCreator("Maarten Balliauw") - ->setLastModifiedBy("Franklin") - ->setTitle("Office 2007 XLSX Test Document") + +echo date('H:i:s') , " Load Tests from $inputFileType file" , PHP_EOL; +$callStartTime = microtime(true); + +$objPHPExcelReader = PHPExcel_IOFactory::createReader($inputFileType); +$objPHPExcel = $objPHPExcelReader->load($inputFileName); + +$callEndTime = microtime(true); +$callTime = $callEndTime - $callStartTime; +echo 'Call time to read Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , PHP_EOL; +// Echo memory usage +echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , PHP_EOL; + + +echo date('H:i:s') , " Adjust properties" , PHP_EOL; +$objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document") ->setSubject("Office 2007 XLSX Test Document") - ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.") - ->setKeywords("office 2007 openxml php") - ->setCategory("Test result file"); -// Add some data -echo date('H:i:s') . " Add some data" , PHP_EOL; -$objPHPExcel->setActiveSheetIndex(0) - ->setCellValue('A1', 'Hello') - ->setCellValue('B2', 'world!'); + ->setDescription("Test XLSX document, generated using PHPExcel") + ->setKeywords("office 2007 openxml php"); -// Set active sheet index to the first sheet, so Excel opens this as the first sheet -$objPHPExcel->setActiveSheetIndex(0); // Save Excel 2007 file -echo date('H:i:s') . " Write to Excel2007 format" , PHP_EOL; +echo date('H:i:s') , " Write to Excel2007 format" , PHP_EOL; $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save(str_replace('.php', '.xlsx', __FILE__)); - -echo date('H:i:s') . " Adjust properties" , PHP_EOL; -$objPHPExcel->getProperties()->setTitle("Office 95 XLS Test Document") - ->setSubject("Office 95 XLS Test Document") - ->setDescription("Test document for Office 95 XLS, generated using PHP classes.") - ->setKeywords("office 95 openxml php"); - -// Save Excel5 file -echo date('H:i:s') . " Write to Excel5 format" , PHP_EOL; -$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); -$objWriter->save(str_replace('.php', '.xls', __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; -unset($objWriter); +echo date('H:i:s') , " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB" , PHP_EOL; echo PHP_EOL; // Reread File -echo date('H:i:s') . " Reread Excel5 file" , PHP_EOL; -$objPHPExcelRead = PHPExcel_IOFactory::load('31docproperties_write.xls'); +echo date('H:i:s') , " Reread Excel2007 file" , PHP_EOL; +$objPHPExcelRead = PHPExcel_IOFactory::load(str_replace('.php', '.xlsx', __FILE__)); // Set properties -echo date('H:i:s') . " Get properties" , PHP_EOL; -echo 'Creator : '.$objPHPExcelRead->getProperties()->getCreator() , PHP_EOL; -echo 'LastModifiedBy : '.$objPHPExcelRead->getProperties()->getLastModifiedBy() , PHP_EOL; -echo 'Title : '.$objPHPExcelRead->getProperties()->getTitle() , PHP_EOL; -echo 'Subject : '.$objPHPExcelRead->getProperties()->getSubject() , PHP_EOL; -echo 'Description : '.$objPHPExcelRead->getProperties()->getDescription() , PHP_EOL; -echo 'Keywords : '.$objPHPExcelRead->getProperties()->getKeywords() , PHP_EOL; -echo 'Category : '.$objPHPExcelRead->getProperties()->getCategory() , PHP_EOL; +echo date('H:i:s') , " Get properties" , PHP_EOL; + +echo 'Core Properties:' , PHP_EOL; +echo ' Created by - ' , $objPHPExcel->getProperties()->getCreator() , PHP_EOL; +echo ' Created on - ' , date('d-M-Y',$objPHPExcel->getProperties()->getCreated()) , ' at ' , + date('H:i:s',$objPHPExcel->getProperties()->getCreated()) , PHP_EOL; +echo ' Last Modified by - ' , $objPHPExcel->getProperties()->getLastModifiedBy() , PHP_EOL; +echo ' Last Modified on - ' , date('d-M-Y',$objPHPExcel->getProperties()->getModified()) , ' at ' , + date('H:i:s',$objPHPExcel->getProperties()->getModified()) , PHP_EOL; +echo ' Title - ' , $objPHPExcel->getProperties()->getTitle() , PHP_EOL; +echo ' Subject - ' , $objPHPExcel->getProperties()->getSubject() , PHP_EOL; +echo ' Description - ' , $objPHPExcel->getProperties()->getDescription() , PHP_EOL; +echo ' Keywords: - ' , $objPHPExcel->getProperties()->getKeywords() , PHP_EOL; + + +echo 'Extended (Application) Properties:' , PHP_EOL; +echo ' Category - ' , $objPHPExcel->getProperties()->getCategory() , PHP_EOL; +echo ' Company - ' , $objPHPExcel->getProperties()->getCompany() , PHP_EOL; +echo ' Manager - ' , $objPHPExcel->getProperties()->getManager() , PHP_EOL; + + +echo 'Custom Properties:' , PHP_EOL; +$customProperties = $objPHPExcel->getProperties()->getCustomProperties(); +foreach($customProperties as $customProperty) { + $propertyValue = $objPHPExcel->getProperties()->getCustomPropertyValue($customProperty); + $propertyType = $objPHPExcel->getProperties()->getCustomPropertyType($customProperty); + echo ' ' , $customProperty , ' - (' , $propertyType , ') - '; + if ($propertyType == PHPExcel_DocumentProperties::PROPERTY_TYPE_DATE) { + echo date('d-M-Y H:i:s',$propertyValue) , PHP_EOL; + } elseif ($propertyType == PHPExcel_DocumentProperties::PROPERTY_TYPE_BOOLEAN) { + echo (($propertyValue) ? 'TRUE' : 'FALSE') , PHP_EOL; + } else { + echo $propertyValue , PHP_EOL; + } +} // Echo memory peak usage -echo date('H:i:s') . " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB" , PHP_EOL; - - - - - -?> \ No newline at end of file +echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) . " MB" , PHP_EOL; diff --git a/Tests/Excel2003XMLReader.php b/Tests/Excel2003XMLReader.php index eec2a405..052cce6c 100644 --- a/Tests/Excel2003XMLReader.php +++ b/Tests/Excel2003XMLReader.php @@ -2,7 +2,7 @@ /** * PHPExcel * - * Copyright (C) 2006 - 2011 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 @@ -20,7 +20,7 @@ * * @category PHPExcel * @package PHPExcel - * @copyright Copyright (c) 2006 - 2011 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## */ @@ -33,45 +33,29 @@ date_default_timezone_set('Europe/London'); /** PHPExcel_IOFactory */ require_once '../Classes/PHPExcel/IOFactory.php'; -?> - -
- -