Reworking of some of the example/test scripts
git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@86438 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
parent
a2e37887e2
commit
18cc1dc7a3
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -0,0 +1,115 @@
|
|||
<?php
|
||||
/**
|
||||
* 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
|
||||
* 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
|
||||
* @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##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once '../Classes/PHPExcel.php';
|
||||
|
||||
|
||||
$inputFileType = 'Excel5';
|
||||
$inputFileName = 'templates/31docproperties.xls';
|
||||
|
||||
|
||||
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 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;
|
|
@ -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;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) . " MB" , PHP_EOL;
|
||||
|
|
|
@ -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';
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Excel2003XML Reader Test</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<?php
|
||||
|
||||
echo date('H:i:s') . " Load from Excel2003XML file\n";
|
||||
echo date('H:i:s') , " Load from Excel2003XML file" , PHP_EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objReader = PHPExcel_IOFactory::createReader('Excel2003XML');
|
||||
$objPHPExcel = $objReader->load("Excel2003XMLTest.xml");
|
||||
|
||||
|
||||
|
||||
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
echo '<br />Call time to read Workbook was '.sprintf('%.4f',$callTime)." seconds<br />\n";
|
||||
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<br /><hr />\n";
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
|
||||
|
||||
|
||||
echo date('H:i:s') . " Write to Excel5 format<br />";
|
||||
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<br />";
|
||||
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.<br />";
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
||||
echo date('H:i:s') , " Done writing file" , PHP_EOL;
|
||||
|
|
|
@ -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,19 +33,7 @@ date_default_timezone_set('Europe/London');
|
|||
/** PHPExcel_IOFactory */
|
||||
require_once '../Classes/PHPExcel/IOFactory.php';
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Gnumeric Reader Test</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<?php
|
||||
|
||||
echo date('H:i:s') . " Load from Gnumeric file\n";
|
||||
echo date('H:i:s') , " Load from Gnumeric file" , PHP_EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objReader = PHPExcel_IOFactory::createReader('Gnumeric');
|
||||
|
@ -54,22 +42,19 @@ $objPHPExcel = $objReader->load("GnumericTest.gnumeric");
|
|||
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
echo '<br />Call time to read Workbook was '.sprintf('%.4f',$callTime)." seconds<br />\n";
|
||||
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<br /><hr />\n";
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
|
||||
|
||||
|
||||
echo date('H:i:s') . " Write to Excel2007 format<br />";
|
||||
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<br />";
|
||||
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.<br />";
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
||||
echo date('H:i:s') , " Done writing file" , PHP_EOL;
|
||||
|
|
|
@ -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,19 +33,7 @@ date_default_timezone_set('Europe/London');
|
|||
/** PHPExcel_IOFactory */
|
||||
require_once '../Classes/PHPExcel/IOFactory.php';
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel OOCalc Reader Test</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<?php
|
||||
|
||||
echo date('H:i:s') . " Load from OOCalc file\n";
|
||||
echo date('H:i:s') , " Load from OOCalc file" , PHP_EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objReader = PHPExcel_IOFactory::createReader('OOCalc');
|
||||
|
@ -54,22 +42,20 @@ $objPHPExcel = $objReader->load("OOCalcTest.ods");
|
|||
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
echo '<br />Call time to read Workbook was '.sprintf('%.4f',$callTime)." seconds<br />\n";
|
||||
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<br /><hr />\n";
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
|
||||
|
||||
|
||||
echo date('H:i:s') . " Write to Excel2007 format<br />";
|
||||
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<br />";
|
||||
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.<br />";
|
||||
echo date('H:i:s') , " Done writing file" , PHP_EOL;
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
|
@ -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##
|
||||
*/
|
||||
|
@ -34,16 +34,17 @@ date_default_timezone_set('Europe/London');
|
|||
require_once '../Classes/PHPExcel/IOFactory.php';
|
||||
|
||||
|
||||
echo date('H:i:s') . " Load from SYLK file\n";
|
||||
echo date('H:i:s') , " Load from SYLK file" , PHP_EOL;
|
||||
$objPHPExcel = PHPExcel_IOFactory::load("SylkTest.slk");
|
||||
|
||||
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;
|
||||
|
|
|
@ -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##
|
||||
*/
|
||||
|
@ -34,25 +34,27 @@ date_default_timezone_set('Europe/London');
|
|||
require_once '../Classes/PHPExcel/IOFactory.php';
|
||||
|
||||
|
||||
echo date('H:i:s') . " Load from XML file\n";
|
||||
echo date('H:i:s') , " Load from XML file" , PHP_EOL;
|
||||
$inputFileName = "XMLTest.xml";
|
||||
|
||||
/** Identify the type of $inputFileName **/
|
||||
$inputFileType = PHPExcel_IOFactory::identify($inputFileName);
|
||||
echo 'Loading ',$inputFileName,' using ',$inputFileType," Reader\n";
|
||||
echo 'Loading ' , $inputFileName , ' using ' , $inputFileType , " Reader" , PHP_EOL;
|
||||
|
||||
/** Create a new Reader of the type that has been identified **/
|
||||
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
|
||||
/** Load $inputFileName to a PHPExcel Object **/
|
||||
$objPHPExcel = $objReader->load($inputFileName);
|
||||
|
||||
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;
|
||||
|
|
|
@ -16,13 +16,16 @@
|
|||
<LastSaved>2009-09-17T22:53:09Z</LastSaved>
|
||||
<Category>Reader</Category>
|
||||
<Company>PHPExcel</Company>
|
||||
<Version>12.00</Version>
|
||||
<Version>14.00</Version>
|
||||
</DocumentProperties>
|
||||
<OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
|
||||
<AllowPNG/>
|
||||
</OfficeDocumentSettings>
|
||||
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
|
||||
<WindowHeight>13995</WindowHeight>
|
||||
<WindowWidth>28455</WindowWidth>
|
||||
<WindowHeight>13176</WindowHeight>
|
||||
<WindowWidth>28452</WindowWidth>
|
||||
<WindowTopX>240</WindowTopX>
|
||||
<WindowTopY>510</WindowTopY>
|
||||
<WindowTopY>516</WindowTopY>
|
||||
<ProtectStructure>False</ProtectStructure>
|
||||
<ProtectWindows>False</ProtectWindows>
|
||||
</ExcelWorkbook>
|
||||
|
@ -35,7 +38,7 @@
|
|||
<NumberFormat/>
|
||||
<Protection/>
|
||||
</Style>
|
||||
<Style ss:ID="m46076128">
|
||||
<Style ss:ID="m42221568">
|
||||
<Alignment ss:Horizontal="Center" ss:Vertical="Center"/>
|
||||
<Borders>
|
||||
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="3"
|
||||
|
@ -145,8 +148,8 @@
|
|||
<Worksheet ss:Name="Sample Data">
|
||||
<Table ss:ExpandedColumnCount="10" ss:ExpandedRowCount="20" x:FullColumns="1"
|
||||
x:FullRows="1" ss:DefaultRowHeight="15">
|
||||
<Column ss:AutoFitWidth="0" ss:Width="90.75"/>
|
||||
<Column ss:Index="4" ss:AutoFitWidth="0" ss:Width="33.75"/>
|
||||
<Column ss:AutoFitWidth="0" ss:Width="90.6"/>
|
||||
<Column ss:Index="4" ss:AutoFitWidth="0" ss:Width="33.6"/>
|
||||
<Row ss:AutoFitHeight="0">
|
||||
<Cell ss:StyleID="s62"><Data ss:Type="String">Test String 1</Data></Cell>
|
||||
<Cell ss:StyleID="s63"><Data ss:Type="Number">1</Data></Cell>
|
||||
|
@ -222,7 +225,7 @@
|
|||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="13.5"/>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="13.5">
|
||||
<Cell ss:Index="2" ss:MergeAcross="1" ss:MergeDown="1" ss:StyleID="m46076128"><Data
|
||||
<Cell ss:Index="2" ss:MergeAcross="1" ss:MergeDown="1" ss:StyleID="m42221568"><Data
|
||||
ss:Type="String">BOX</Data></Cell>
|
||||
<Cell ss:Index="5" ss:StyleID="s85"/>
|
||||
<Cell ss:Index="7"><Data ss:Type="String">Test Column 1</Data></Cell>
|
||||
|
@ -251,7 +254,7 @@
|
|||
<Pane>
|
||||
<Number>3</Number>
|
||||
<ActiveRow>17</ActiveRow>
|
||||
<ActiveCol>6</ActiveCol>
|
||||
<ActiveCol>4</ActiveCol>
|
||||
</Pane>
|
||||
</Panes>
|
||||
<ProtectObjects>False</ProtectObjects>
|
||||
|
@ -272,12 +275,12 @@
|
|||
<Worksheet ss:Name="Report Data">
|
||||
<Table ss:ExpandedColumnCount="7" ss:ExpandedRowCount="14" x:FullColumns="1"
|
||||
x:FullRows="1" ss:DefaultRowHeight="15">
|
||||
<Column ss:AutoFitWidth="0" ss:Width="66.75"/>
|
||||
<Column ss:AutoFitWidth="0" ss:Width="68.25"/>
|
||||
<Column ss:AutoFitWidth="0" ss:Width="62.25"/>
|
||||
<Column ss:Width="69.75"/>
|
||||
<Column ss:Index="6" ss:Width="69.75"/>
|
||||
<Column ss:AutoFitWidth="0" ss:Width="64.5"/>
|
||||
<Column ss:AutoFitWidth="0" ss:Width="66.600000000000009"/>
|
||||
<Column ss:AutoFitWidth="0" ss:Width="68.399999999999991"/>
|
||||
<Column ss:AutoFitWidth="0" ss:Width="62.400000000000006"/>
|
||||
<Column ss:Width="69.599999999999994"/>
|
||||
<Column ss:Index="6" ss:Width="69.599999999999994"/>
|
||||
<Column ss:AutoFitWidth="0" ss:Width="64.8"/>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="31.5">
|
||||
<Cell ss:StyleID="s86"><Data ss:Type="String">Heading 1</Data></Cell>
|
||||
<Cell ss:StyleID="s86"><Data ss:Type="String">Heading 2</Data></Cell>
|
||||
|
@ -416,13 +419,6 @@
|
|||
<HorizontalResolution>600</HorizontalResolution>
|
||||
<VerticalResolution>600</VerticalResolution>
|
||||
</Print>
|
||||
<Panes>
|
||||
<Pane>
|
||||
<Number>3</Number>
|
||||
<ActiveRow>1</ActiveRow>
|
||||
<ActiveCol>8</ActiveCol>
|
||||
</Pane>
|
||||
</Panes>
|
||||
<ProtectObjects>False</ProtectObjects>
|
||||
<ProtectScenarios>False</ProtectScenarios>
|
||||
<AllowFormatCells/>
|
||||
|
@ -437,5 +433,18 @@
|
|||
<AllowFilter/>
|
||||
<AllowUsePivotTables/>
|
||||
</WorksheetOptions>
|
||||
<ConditionalFormatting xmlns="urn:schemas-microsoft-com:office:excel">
|
||||
<Range>R2C3:R14C3</Range>
|
||||
<Condition>
|
||||
<Qualifier>Greater</Qualifier>
|
||||
<Value1>0</Value1>
|
||||
<Format Style='color:#006100;background:#C6EFCE'/>
|
||||
</Condition>
|
||||
<Condition>
|
||||
<Qualifier>Less</Qualifier>
|
||||
<Value1>0</Value1>
|
||||
<Format Style='color:#9C0006;background:#FFC7CE'/>
|
||||
</Condition>
|
||||
</ConditionalFormatting>
|
||||
</Worksheet>
|
||||
</Workbook>
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue