Reworking of some of the example/test scripts
git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@86399 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
parent
6f91dd9f59
commit
a2e37887e2
|
@ -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,14 +30,14 @@ error_reporting(E_ALL);
|
|||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** PHPExcel */
|
||||
/** Include PHPExcel */
|
||||
require_once '../Classes/PHPExcel.php';
|
||||
|
||||
|
||||
// Create new PHPExcel object
|
||||
$objPHPExcel = new PHPExcel();
|
||||
|
||||
// Set properties
|
||||
// Set document properties
|
||||
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->setTitle("PDF Test Document")
|
||||
|
@ -59,7 +59,7 @@ $objPHPExcel->setActiveSheetIndex(0)
|
|||
->setCellValue('A4', 'Miscellaneous glyphs')
|
||||
->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');
|
||||
|
||||
// Rename sheet
|
||||
// Rename worksheet
|
||||
$objPHPExcel->getActiveSheet()->setTitle('Simple');
|
||||
|
||||
|
||||
|
@ -67,7 +67,7 @@ $objPHPExcel->getActiveSheet()->setTitle('Simple');
|
|||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// Redirect output to a client’s web browser (Excel2007)
|
||||
// Redirect output to a client’s web browser (PDF)
|
||||
header('Content-Type: application/pdf');
|
||||
header('Content-Disposition: attachment;filename="01simple.pdf"');
|
||||
header('Cache-Control: max-age=0');
|
||||
|
|
|
@ -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,14 +30,14 @@ error_reporting(E_ALL);
|
|||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** PHPExcel */
|
||||
/** Include PHPExcel */
|
||||
require_once '../Classes/PHPExcel.php';
|
||||
|
||||
|
||||
// Create new PHPExcel object
|
||||
$objPHPExcel = new PHPExcel();
|
||||
|
||||
// Set properties
|
||||
// Set document properties
|
||||
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->setTitle("Office 2007 XLSX Test Document")
|
||||
|
@ -59,7 +59,7 @@ $objPHPExcel->setActiveSheetIndex(0)
|
|||
->setCellValue('A4', 'Miscellaneous glyphs')
|
||||
->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');
|
||||
|
||||
// Rename sheet
|
||||
// Rename worksheet
|
||||
$objPHPExcel->getActiveSheet()->setTitle('Simple');
|
||||
|
||||
|
||||
|
|
|
@ -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,14 +30,14 @@ error_reporting(E_ALL);
|
|||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** PHPExcel */
|
||||
/** Include PHPExcel */
|
||||
require_once '../Classes/PHPExcel.php';
|
||||
|
||||
|
||||
// Create new PHPExcel object
|
||||
$objPHPExcel = new PHPExcel();
|
||||
|
||||
// Set properties
|
||||
// Set document properties
|
||||
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->setTitle("Office 2007 XLSX Test Document")
|
||||
|
@ -59,7 +59,7 @@ $objPHPExcel->setActiveSheetIndex(0)
|
|||
->setCellValue('A4', 'Miscellaneous glyphs')
|
||||
->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');
|
||||
|
||||
// Rename sheet
|
||||
// Rename worksheet
|
||||
$objPHPExcel->getActiveSheet()->setTitle('Simple');
|
||||
|
||||
|
||||
|
|
|
@ -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)
|
||||
->setCellValue('A1', 'Hello')
|
||||
->setCellValue('B2', 'world!')
|
||||
|
@ -62,8 +62,8 @@ $objPHPExcel->setActiveSheetIndex(0)
|
|||
->setCellValue('A4', 'Miscellaneous glyphs')
|
||||
->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');
|
||||
|
||||
// Rename sheet
|
||||
echo date('H:i:s') . " Rename sheet\n";
|
||||
// Rename worksheet
|
||||
echo date('H:i:s') , " Rename worksheet" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->setTitle('Simple');
|
||||
|
||||
|
||||
|
@ -72,13 +72,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;
|
||||
|
|
|
@ -0,0 +1,129 @@
|
|||
<?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';
|
||||
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s') , " Create new PHPExcel object" , PHP_EOL;
|
||||
$objPHPExcel = new PHPExcel();
|
||||
|
||||
// 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")
|
||||
->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");
|
||||
|
||||
// Set default font
|
||||
echo date('H:i:s') , " Set default font" , PHP_EOL;
|
||||
$objPHPExcel->getDefaultStyle()->getFont()->setName('Arial');
|
||||
$objPHPExcel->getDefaultStyle()->getFont()->setSize(10);
|
||||
|
||||
// Add some data, resembling some different data types
|
||||
echo date('H:i:s') , " Add some data" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'String');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Simple');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C1', 'PHPExcel');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A2', 'String');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B2', 'Symbols');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C2', '!+&=()~§±æþ');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A3', 'String');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B3', 'UTF-8');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C3', 'Создать MS Excel Книги из PHP скриптов');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A4', 'Number');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B4', 'Integer');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C4', 12);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A5', 'Number');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B5', 'Float');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C5', 34.56);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A6', 'Number');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B6', 'Negative');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C6', -7.89);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A7', 'Boolean');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B7', 'True');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C7', true);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A8', 'Boolean');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B8', 'False');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C8', false);
|
||||
|
||||
$dateTimeNow = gmmktime();
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A9', 'Date/Time');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B9', 'Date');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C9', PHPExcel_Shared_Date::PHPToExcel( $dateTimeNow ));
|
||||
$objPHPExcel->getActiveSheet()->getStyle('C9')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD2);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A10', 'Date/Time');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B10', 'Time');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C10', PHPExcel_Shared_Date::PHPToExcel( $dateTimeNow ));
|
||||
$objPHPExcel->getActiveSheet()->getStyle('C10')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A11', 'Date/Time');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B11', 'Date and Time');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C11', PHPExcel_Shared_Date::PHPToExcel( $dateTimeNow ));
|
||||
$objPHPExcel->getActiveSheet()->getStyle('C11')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_DATETIME);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setAutoSize(true);
|
||||
|
||||
// Rename worksheet
|
||||
echo date('H:i:s') , " Rename worksheet" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->setTitle('Datatypes');
|
||||
|
||||
|
||||
// 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 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 done
|
||||
echo date('H:i:s') , " Done writing file" , PHP_EOL;
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
<?php
|
||||
/**
|
||||
* 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,12 +49,12 @@ $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->getDefaultStyle()->getFont()->setName('Arial');
|
||||
$objPHPExcel->getDefaultStyle()->getFont()->setSize(10);
|
||||
|
||||
// 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');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Simple');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C1', 'PHPExcel');
|
||||
|
@ -87,8 +87,27 @@ $objPHPExcel->getActiveSheet()->setCellValue('A8', 'Boolean');
|
|||
$objPHPExcel->getActiveSheet()->setCellValue('B8', 'False');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C8', false);
|
||||
|
||||
// Rename sheet
|
||||
echo date('H:i:s') . " Rename sheet\n";
|
||||
$dateTimeNow = gmmktime();
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A9', 'Date/Time');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B9', 'Date');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C9', PHPExcel_Shared_Date::PHPToExcel( $dateTimeNow ));
|
||||
$objPHPExcel->getActiveSheet()->getStyle('C9')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD2);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A10', 'Date/Time');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B10', 'Time');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C10', PHPExcel_Shared_Date::PHPToExcel( $dateTimeNow ));
|
||||
$objPHPExcel->getActiveSheet()->getStyle('C10')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A11', 'Date/Time');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B11', 'Date and Time');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C11', PHPExcel_Shared_Date::PHPToExcel( $dateTimeNow ));
|
||||
$objPHPExcel->getActiveSheet()->getStyle('C11')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_DATETIME);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setAutoSize(true);
|
||||
|
||||
// Rename worksheet
|
||||
echo date('H:i:s') , " Rename worksheet" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->setTitle('Datatypes');
|
||||
|
||||
|
||||
|
@ -97,13 +116,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,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,32 +50,48 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
|||
|
||||
|
||||
// Add some data, we will use some formulas here
|
||||
echo date('H:i:s') . " Add some data\n";
|
||||
echo date('H:i:s') , " Add some data" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A5', 'Sum:');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Range 1');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B2', 2);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B3', 8);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B4', 10);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B5', '=SUM(B2:B4)');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Range #1')
|
||||
->setCellValue('B2', 3)
|
||||
->setCellValue('B3', 7)
|
||||
->setCellValue('B4', 13)
|
||||
->setCellValue('B5', '=SUM(B2:B4)');
|
||||
echo date('H:i:s') , " Sum of Range #1 is " ,
|
||||
$objPHPExcel->getActiveSheet()->getCell('B5')->getCalculatedValue() , PHP_EOL;
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C1', 'Range 2');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C2', 3);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C3', 9);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C4', 11);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C5', '=SUM(C2:C4)');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C1', 'Range #2')
|
||||
->setCellValue('C2', 5)
|
||||
->setCellValue('C3', 11)
|
||||
->setCellValue('C4', 17)
|
||||
->setCellValue('C5', '=SUM(C2:C4)');
|
||||
echo date('H:i:s') , " Sum of Range #2 is " ,
|
||||
$objPHPExcel->getActiveSheet()->getCell('C5')->getCalculatedValue() , PHP_EOL;
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A7', 'Total of both ranges:');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B7', '=SUM(B5:C5)');
|
||||
echo date('H:i:s') , " Sum of both Ranges is " ,
|
||||
$objPHPExcel->getActiveSheet()->getCell('B7')->getCalculatedValue() , PHP_EOL;
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A8', 'Minimum of both ranges:');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B8', '=MIN(B2:C4)');
|
||||
echo date('H:i:s') , " Minimum value in either Range is " ,
|
||||
$objPHPExcel->getActiveSheet()->getCell('B8')->getCalculatedValue() , PHP_EOL;
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A9', 'Maximum of both ranges:');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B9', '=MAX(B2:C4)');
|
||||
echo date('H:i:s') , " Maximum value in either Range is " ,
|
||||
$objPHPExcel->getActiveSheet()->getCell('B9')->getCalculatedValue() , PHP_EOL;
|
||||
|
||||
// Rename sheet
|
||||
echo date('H:i:s') . " Rename sheet\n";
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A10', 'Average of both ranges:');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B10', '=AVERAGE(B2:C4)');
|
||||
echo date('H:i:s') , " Average value of both Ranges is " ,
|
||||
$objPHPExcel->getActiveSheet()->getCell('B10')->getCalculatedValue() , PHP_EOL;
|
||||
|
||||
|
||||
// Rename worksheet
|
||||
echo date('H:i:s') , " Rename worksheet" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->setTitle('Formulas');
|
||||
|
||||
|
||||
|
@ -84,13 +100,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,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,19 +50,19 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
|||
|
||||
|
||||
// Add some data, we will use printing features
|
||||
echo date('H:i:s') . " Add some data\n";
|
||||
echo date('H:i:s') , " Add some data" , PHP_EOL;
|
||||
for ($i = 1; $i < 200; $i++) {
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A' . $i, $i);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B' . $i, 'Test value');
|
||||
}
|
||||
|
||||
// Set header and footer. When no different headers for odd/even are used, odd header is assumed.
|
||||
echo date('H:i:s') . " Set header/footer\n";
|
||||
echo date('H:i:s') , " Set header/footer" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&L&G&C&HPlease treat this document as confidential!');
|
||||
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&L&B' . $objPHPExcel->getProperties()->getTitle() . '&RPage &P of &N');
|
||||
|
||||
// Add a drawing to the header
|
||||
echo date('H:i:s') . " Add a drawing to the header\n";
|
||||
echo date('H:i:s') , " Add a drawing to the header" , PHP_EOL;
|
||||
$objDrawing = new PHPExcel_Worksheet_HeaderFooterDrawing();
|
||||
$objDrawing->setName('PHPExcel logo');
|
||||
$objDrawing->setPath('./images/phpexcel_logo.gif');
|
||||
|
@ -70,12 +70,12 @@ $objDrawing->setHeight(36);
|
|||
$objPHPExcel->getActiveSheet()->getHeaderFooter()->addImage($objDrawing, PHPExcel_Worksheet_HeaderFooter::IMAGE_HEADER_LEFT);
|
||||
|
||||
// Set page orientation and size
|
||||
echo date('H:i:s') . " Set page orientation and size\n";
|
||||
echo date('H:i:s') , " Set page orientation and size" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);
|
||||
$objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
|
||||
|
||||
// Rename sheet
|
||||
echo date('H:i:s') . " Rename sheet\n";
|
||||
// Rename worksheet
|
||||
echo date('H:i:s') , " Rename worksheet" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->setTitle('Printing');
|
||||
|
||||
|
||||
|
@ -84,13 +84,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##
|
||||
*/
|
||||
|
@ -28,16 +28,16 @@
|
|||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
|
||||
/** PHPExcel */
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../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")
|
||||
|
@ -48,7 +48,7 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
|||
|
||||
|
||||
// Create a first sheet, representing sales 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('B1', 'Invoice');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D1', PHPExcel_Shared_Date::PHPToExcel( gmmktime(0,0,0,date('m'),date('d'),date('Y')) ));
|
||||
|
@ -65,18 +65,18 @@ $objPHPExcel->getActiveSheet()->setCellValue('A4', '1001');
|
|||
$objPHPExcel->getActiveSheet()->setCellValue('B4', 'PHP for dummies');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C4', '20');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D4', '1');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E4', '=C4*D4');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E4', '=IF(D4<>"",C4*D4,"")');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A5', '1012');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B5', 'OpenXML for dummies');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C5', '22');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D5', '2');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E5', '=C5*D5');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E5', '=IF(D5<>"",C5*D5,"")');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E6', '=C6*D6');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E7', '=C7*D7');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E8', '=C8*D8');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E9', '=C9*D9');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E6', '=IF(D6<>"",C6*D6,"")');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E7', '=IF(D7<>"",C7*D7,"")');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E8', '=IF(D8<>"",C8*D8,"")');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E9', '=IF(D9<>"",C9*D9,"")');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D11', 'Total excl.:');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E11', '=SUM(E4:E9)');
|
||||
|
@ -88,7 +88,7 @@ $objPHPExcel->getActiveSheet()->setCellValue('D13', 'Total incl.:');
|
|||
$objPHPExcel->getActiveSheet()->setCellValue('E13', '=E11+E12');
|
||||
|
||||
// Add comment
|
||||
echo date('H:i:s') . " Add comments\n";
|
||||
echo date('H:i:s') , " Add comments" , PHP_EOL;
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getComment('E11')->setAuthor('PHPExcel');
|
||||
$objCommentRichText = $objPHPExcel->getActiveSheet()->getComment('E11')->getText()->createTextRun('PHPExcel:');
|
||||
|
@ -114,7 +114,7 @@ $objPHPExcel->getActiveSheet()->getComment('E13')->getFillColor()->setRGB('EEEEE
|
|||
|
||||
|
||||
// Add rich-text string
|
||||
echo date('H:i:s') . " Add rich-text string\n";
|
||||
echo date('H:i:s') , " Add rich-text string" , PHP_EOL;
|
||||
$objRichText = new PHPExcel_RichText();
|
||||
$objRichText->createText('This invoice is ');
|
||||
|
||||
|
@ -128,28 +128,28 @@ $objRichText->createText(', unless specified otherwise on the invoice.');
|
|||
$objPHPExcel->getActiveSheet()->getCell('A18')->setValue($objRichText);
|
||||
|
||||
// Merge cells
|
||||
echo date('H:i:s') . " Merge cells\n";
|
||||
echo date('H:i:s') , " Merge cells" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->mergeCells('A18:E22');
|
||||
$objPHPExcel->getActiveSheet()->mergeCells('A28:B28'); // Just to test...
|
||||
$objPHPExcel->getActiveSheet()->unmergeCells('A28:B28'); // Just to test...
|
||||
|
||||
// Protect cells
|
||||
echo date('H:i:s') . " Protect cells\n";
|
||||
echo date('H:i:s') , " Protect cells" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->getProtection()->setSheet(true); // Needs to be set to true in order to enable any worksheet protection!
|
||||
$objPHPExcel->getActiveSheet()->protectCells('A3:E13', 'PHPExcel');
|
||||
|
||||
// Set cell number formats
|
||||
echo date('H:i:s') . " Set cell number formats\n";
|
||||
echo date('H:i:s') , " Set cell number formats" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->getStyle('E4:E13')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE);
|
||||
|
||||
// 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('B')->setAutoSize(true);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(12);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(12);
|
||||
|
||||
// Set fonts
|
||||
echo date('H:i:s') . " Set fonts\n";
|
||||
echo date('H:i:s') , " Set fonts" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setName('Candara');
|
||||
$objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setSize(20);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setBold(true);
|
||||
|
@ -163,7 +163,7 @@ $objPHPExcel->getActiveSheet()->getStyle('D13')->getFont()->setBold(true);
|
|||
$objPHPExcel->getActiveSheet()->getStyle('E13')->getFont()->setBold(true);
|
||||
|
||||
// Set alignments
|
||||
echo date('H:i:s') . " Set alignments\n";
|
||||
echo date('H:i:s') , " Set alignments" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->getStyle('D11')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('D12')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('D13')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
|
||||
|
@ -174,7 +174,7 @@ $objPHPExcel->getActiveSheet()->getStyle('A18')->getAlignment()->setVertical(PHP
|
|||
$objPHPExcel->getActiveSheet()->getStyle('B5')->getAlignment()->setShrinkToFit(true);
|
||||
|
||||
// Set thin black border outline around column
|
||||
echo date('H:i:s') . " Set thin black border outline around column\n";
|
||||
echo date('H:i:s') , " Set thin black border outline around column" , PHP_EOL;
|
||||
$styleThinBlackBorderOutline = array(
|
||||
'borders' => array(
|
||||
'outline' => array(
|
||||
|
@ -187,7 +187,7 @@ $objPHPExcel->getActiveSheet()->getStyle('A4:E10')->applyFromArray($styleThinBla
|
|||
|
||||
|
||||
// Set thick brown border outline around "Total"
|
||||
echo date('H:i:s') . " Set thick brown border outline around Total\n";
|
||||
echo date('H:i:s') , " Set thick brown border outline around Total" , PHP_EOL;
|
||||
$styleThickBrownBorderOutline = array(
|
||||
'borders' => array(
|
||||
'outline' => array(
|
||||
|
@ -199,12 +199,12 @@ $styleThickBrownBorderOutline = array(
|
|||
$objPHPExcel->getActiveSheet()->getStyle('D13:E13')->applyFromArray($styleThickBrownBorderOutline);
|
||||
|
||||
// Set fills
|
||||
echo date('H:i:s') . " Set fills\n";
|
||||
echo date('H:i:s') , " Set fills" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A1:E1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A1:E1')->getFill()->getStartColor()->setARGB('FF808080');
|
||||
|
||||
// Set style for header row using alternative method
|
||||
echo date('H:i:s') . " Set style for header row using alternative method\n";
|
||||
echo date('H:i:s') , " Set style for header row using alternative method" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A3:E3')->applyFromArray(
|
||||
array(
|
||||
'font' => array(
|
||||
|
@ -263,11 +263,11 @@ $objPHPExcel->getActiveSheet()->getStyle('E3')->applyFromArray(
|
|||
);
|
||||
|
||||
// Unprotect a cell
|
||||
echo date('H:i:s') . " Unprotect a cell\n";
|
||||
echo date('H:i:s') , " Unprotect a cell" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->getStyle('B1')->getProtection()->setLocked(PHPExcel_Style_Protection::PROTECTION_UNPROTECTED);
|
||||
|
||||
// Add a hyperlink to the sheet
|
||||
echo date('H:i:s') . " Add a hyperlink to the sheet\n";
|
||||
echo date('H:i:s') , " Add a hyperlink to the sheet" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E26', 'www.phpexcel.net');
|
||||
$objPHPExcel->getActiveSheet()->getCell('E26')->getHyperlink()->setUrl('http://www.phpexcel.net');
|
||||
$objPHPExcel->getActiveSheet()->getCell('E26')->getHyperlink()->setTooltip('Navigate to website');
|
||||
|
@ -279,7 +279,7 @@ $objPHPExcel->getActiveSheet()->getCell('E27')->getHyperlink()->setTooltip('Revi
|
|||
$objPHPExcel->getActiveSheet()->getStyle('E27')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
|
||||
|
||||
// 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_Drawing();
|
||||
$objDrawing->setName('Logo');
|
||||
$objDrawing->setDescription('Logo');
|
||||
|
@ -288,7 +288,7 @@ $objDrawing->setHeight(36);
|
|||
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
|
||||
|
||||
// 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_Drawing();
|
||||
$objDrawing->setName('Paid');
|
||||
$objDrawing->setDescription('Paid');
|
||||
|
@ -301,7 +301,7 @@ $objDrawing->getShadow()->setDirection(45);
|
|||
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
|
||||
|
||||
// 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_Drawing();
|
||||
$objDrawing->setName('PHPExcel logo');
|
||||
$objDrawing->setDescription('PHPExcel logo');
|
||||
|
@ -312,36 +312,36 @@ $objDrawing->setOffsetX(10);
|
|||
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
|
||||
|
||||
// Play around with inserting and removing rows and columns
|
||||
echo date('H:i:s') . " Play around with inserting and removing rows and columns\n";
|
||||
echo date('H:i:s') , " Play around with inserting and removing rows and columns" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->insertNewRowBefore(6, 10);
|
||||
$objPHPExcel->getActiveSheet()->removeRow(6, 10);
|
||||
$objPHPExcel->getActiveSheet()->insertNewColumnBefore('E', 5);
|
||||
$objPHPExcel->getActiveSheet()->removeColumn('E', 5);
|
||||
|
||||
// Set header and footer. When no different headers for odd/even are used, odd header is assumed.
|
||||
echo date('H:i:s') . " Set header/footer\n";
|
||||
echo date('H:i:s') , " Set header/footer" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&L&BInvoice&RPrinted on &D');
|
||||
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&L&B' . $objPHPExcel->getProperties()->getTitle() . '&RPage &P of &N');
|
||||
|
||||
// Set page orientation and size
|
||||
echo date('H:i:s') . " Set page orientation and size\n";
|
||||
echo date('H:i:s') , " Set page orientation and size" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT);
|
||||
$objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
|
||||
|
||||
// Rename sheet
|
||||
echo date('H:i:s') . " Rename sheet\n";
|
||||
// Rename first worksheet
|
||||
echo date('H:i:s') , " Rename first worksheet" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->setTitle('Invoice');
|
||||
|
||||
|
||||
// Create a new worksheet, after the default sheet
|
||||
echo date('H:i:s') . " Create new Worksheet object\n";
|
||||
echo date('H:i:s') , " Create a second Worksheet object" , PHP_EOL;
|
||||
$objPHPExcel->createSheet();
|
||||
|
||||
// Llorem ipsum...
|
||||
$sLloremIpsum = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vivamus eget ante. Sed cursus nunc semper tortor. Aliquam luctus purus non elit. Fusce vel elit commodo sapien dignissim dignissim. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Curabitur accumsan magna sed massa. Nullam bibendum quam ac ipsum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Proin augue. Praesent malesuada justo sed orci. Pellentesque lacus ligula, sodales quis, ultricies a, ultricies vitae, elit. Sed luctus consectetuer dolor. Vivamus vel sem ut nisi sodales accumsan. Nunc et felis. Suspendisse semper viverra odio. Morbi at odio. Integer a orci a purus venenatis molestie. Nam mattis. Praesent rhoncus, nisi vel mattis auctor, neque nisi faucibus sem, non dapibus elit pede ac nisl. Cras turpis.';
|
||||
|
||||
// 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', 'Terms and conditions');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A3', $sLloremIpsum);
|
||||
|
@ -350,19 +350,19 @@ $objPHPExcel->getActiveSheet()->setCellValue('A5', $sLloremIpsum);
|
|||
$objPHPExcel->getActiveSheet()->setCellValue('A6', $sLloremIpsum);
|
||||
|
||||
// Set the worksheet tab color
|
||||
echo date('H:i:s') . " Set the worksheet tab color\n";
|
||||
echo date('H:i:s') , " Set the worksheet tab color" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->getTabColor()->setARGB('FF0094FF');;
|
||||
|
||||
// Set alignments
|
||||
echo date('H:i:s') . " Set alignments\n";
|
||||
echo date('H:i:s') , " Set alignments" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A3:A6')->getAlignment()->setWrapText(true);
|
||||
|
||||
// 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')->setWidth(80);
|
||||
|
||||
// Set fonts
|
||||
echo date('H:i:s') . " Set fonts\n";
|
||||
echo date('H:i:s') , " Set fonts" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setName('Candara');
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setSize(20);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true);
|
||||
|
@ -371,7 +371,7 @@ $objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setUnderline(PHPExcel
|
|||
$objPHPExcel->getActiveSheet()->getStyle('A3:A6')->getFont()->setSize(8);
|
||||
|
||||
// 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_Drawing();
|
||||
$objDrawing->setName('Terms and conditions');
|
||||
$objDrawing->setDescription('Terms and conditions');
|
||||
|
@ -380,12 +380,12 @@ $objDrawing->setCoordinates('B14');
|
|||
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
|
||||
|
||||
// Set page orientation and size
|
||||
echo date('H:i:s') . " Set page orientation and size\n";
|
||||
echo date('H:i:s') , " Set page orientation and size" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);
|
||||
$objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
|
||||
|
||||
// Rename sheet
|
||||
echo date('H:i:s') . " Rename sheet\n";
|
||||
// Rename second worksheet
|
||||
echo date('H:i:s') , " Rename second worksheet" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->setTitle('Terms and conditions');
|
||||
|
||||
|
||||
|
|
|
@ -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##
|
||||
*/
|
||||
|
@ -32,17 +32,18 @@ date_default_timezone_set('Europe/London');
|
|||
|
||||
include "05featuredemo.inc.php";
|
||||
|
||||
/** PHPExcel_IOFactory */
|
||||
/** Include PHPExcel_IOFactory */
|
||||
require_once '../Classes/PHPExcel/IOFactory.php';
|
||||
|
||||
|
||||
// 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;
|
||||
|
|
|
@ -0,0 +1,123 @@
|
|||
<?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';
|
||||
|
||||
|
||||
/*
|
||||
After doing some test, I've got these results benchmarked
|
||||
for writing to Excel2007:
|
||||
|
||||
Number of rows Seconds to generate
|
||||
200 3
|
||||
500 4
|
||||
1000 6
|
||||
2000 12
|
||||
4000 36
|
||||
8000 64
|
||||
15000 465
|
||||
*/
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s') , " Create new PHPExcel object" , PHP_EOL;
|
||||
$objPHPExcel = new PHPExcel();
|
||||
|
||||
// Set document properties
|
||||
echo date('H:i:s') , " Set properties" , PHP_EOL;
|
||||
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->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");
|
||||
|
||||
|
||||
// Create a first sheet
|
||||
echo date('H:i:s') , " Add data" , PHP_EOL;
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Firstname");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B1', "Lastname");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C1', "Phone");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D1', "Fax");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E1', "Is Client ?");
|
||||
|
||||
|
||||
// Hide "Phone" and "fax" column
|
||||
echo date('H:i:s') , " Hide 'Phone' and 'fax' columns" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setVisible(false);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setVisible(false);
|
||||
|
||||
|
||||
// Set outline levels
|
||||
echo date('H:i:s') , " Set outline levels" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setOutlineLevel(1)
|
||||
->setVisible(false)
|
||||
->setCollapsed(true);
|
||||
|
||||
// Freeze panes
|
||||
echo date('H:i:s') , " Freeze panes" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->freezePane('A2');
|
||||
|
||||
|
||||
// Rows to repeat at top
|
||||
echo date('H:i:s') , " Rows to repeat at top" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->getPageSetup()->setRowsToRepeatAtTopByStartAndEnd(1, 1);
|
||||
|
||||
|
||||
// Add data
|
||||
for ($i = 2; $i <= 5000; $i++) {
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A' . $i, "FName $i")
|
||||
->setCellValue('B' . $i, "LName $i")
|
||||
->setCellValue('C' . $i, "PhoneNo $i")
|
||||
->setCellValue('D' . $i, "FaxNo $i")
|
||||
->setCellValue('E' . $i, true);
|
||||
}
|
||||
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// Save Excel 5 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 done
|
||||
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 */
|
||||
/** Include PHPExcel */
|
||||
require_once '../Classes/PHPExcel.php';
|
||||
|
||||
|
||||
|
@ -49,11 +49,11 @@ for writing to Excel2007:
|
|||
*/
|
||||
|
||||
// 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 properties" , PHP_EOL;
|
||||
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->setTitle("Office 2007 XLSX Test Document")
|
||||
|
@ -64,7 +64,7 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
|||
|
||||
|
||||
// Create a first sheet
|
||||
echo date('H:i:s') . " Add data\n";
|
||||
echo date('H:i:s') , " Add data" , PHP_EOL;
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Firstname");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B1', "Lastname");
|
||||
|
@ -74,34 +74,34 @@ $objPHPExcel->getActiveSheet()->setCellValue('E1', "Is Client ?");
|
|||
|
||||
|
||||
// Hide "Phone" and "fax" column
|
||||
echo date('H:i:s') . " Hide \"Phone\" and \"fax\" column\n";
|
||||
echo date('H:i:s') , " Hide 'Phone' and 'fax' columns" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setVisible(false);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setVisible(false);
|
||||
|
||||
|
||||
// Set outline levels
|
||||
echo date('H:i:s') . " Set outline levels\n";
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setOutlineLevel(1);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setVisible(false);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setCollapsed(true);
|
||||
echo date('H:i:s') , " Set outline levels" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setOutlineLevel(1)
|
||||
->setVisible(false)
|
||||
->setCollapsed(true);
|
||||
|
||||
// Freeze panes
|
||||
echo date('H:i:s') . " Freeze panes\n";
|
||||
echo date('H:i:s') , " Freeze panes" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->freezePane('A2');
|
||||
|
||||
|
||||
// Rows to repeat at top
|
||||
echo date('H:i:s') . " Rows to repeat at top\n";
|
||||
echo date('H:i:s') , " Rows to repeat at top" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->getPageSetup()->setRowsToRepeatAtTopByStartAndEnd(1, 1);
|
||||
|
||||
|
||||
// Add data
|
||||
for ($i = 2; $i <= 5000; $i++) {
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A' . $i, "FName $i");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B' . $i, "LName $i");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C' . $i, "PhoneNo $i");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D' . $i, "FaxNo $i");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E' . $i, true);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A' . $i, "FName $i")
|
||||
->setCellValue('B' . $i, "LName $i")
|
||||
->setCellValue('C' . $i, "PhoneNo $i")
|
||||
->setCellValue('D' . $i, "FaxNo $i")
|
||||
->setCellValue('E' . $i, true);
|
||||
}
|
||||
|
||||
|
||||
|
@ -110,13 +110,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##
|
||||
*/
|
||||
|
@ -29,7 +29,7 @@ error_reporting(E_ALL);
|
|||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** PHPExcel_IOFactory */
|
||||
/** Include PHPExcel_IOFactory */
|
||||
require_once '../Classes/PHPExcel/IOFactory.php';
|
||||
|
||||
|
||||
|
@ -37,16 +37,17 @@ if (!file_exists("05featuredemo.xlsx")) {
|
|||
exit("Please run 05featuredemo.php first.\n");
|
||||
}
|
||||
|
||||
echo date('H:i:s') . " Load from Excel2007 file\n";
|
||||
echo date('H:i:s') , " Load from Excel2007 file" , PHP_EOL;
|
||||
$objPHPExcel = PHPExcel_IOFactory::load("05featuredemo.xlsx");
|
||||
|
||||
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")
|
||||
|
@ -50,7 +50,7 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
|||
|
||||
|
||||
// Create a first sheet, representing sales 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', 'Description');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Amount');
|
||||
|
@ -75,13 +75,13 @@ $objPHPExcel->getActiveSheet()->setCellValue('B7', '=SUM(B2:B6)');
|
|||
|
||||
|
||||
// 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')->setWidth(30);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(12);
|
||||
|
||||
|
||||
// Add conditional formatting
|
||||
echo date('H:i:s') . " Add conditional formatting\n";
|
||||
echo date('H:i:s') , " Add conditional formatting" , PHP_EOL;
|
||||
$objConditional1 = new PHPExcel_Style_Conditional();
|
||||
$objConditional1->setConditionType(PHPExcel_Style_Conditional::CONDITION_CELLIS);
|
||||
$objConditional1->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_BETWEEN);
|
||||
|
@ -113,11 +113,17 @@ array_push($conditionalStyles, $objConditional2);
|
|||
array_push($conditionalStyles, $objConditional3);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('B2')->setConditionalStyles($conditionalStyles);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->duplicateStyle( $objPHPExcel->getActiveSheet()->getStyle('B2'), 'B3:B7' );
|
||||
|
||||
// duplicate the conditional styles across a range of cells
|
||||
echo date('H:i:s') , " Duplicate the conditional formatting across a range of cells" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->duplicateConditionalStyle(
|
||||
$objPHPExcel->getActiveSheet()->getStyle('B2')->getConditionalStyles(),
|
||||
'B3:B7'
|
||||
);
|
||||
|
||||
|
||||
// Set fonts
|
||||
echo date('H:i:s') . " Set fonts\n";
|
||||
echo date('H:i:s') , " Set fonts" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setBold(true);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A7')->getFont()->setBold(true);
|
||||
|
@ -125,19 +131,19 @@ $objPHPExcel->getActiveSheet()->getStyle('B7')->getFont()->setBold(true);
|
|||
|
||||
|
||||
// Set header and footer. When no different headers for odd/even are used, odd header is assumed.
|
||||
echo date('H:i:s') . " Set header/footer\n";
|
||||
echo date('H:i:s') , " Set header/footer" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&L&BPersonal cash register&RPrinted on &D');
|
||||
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&L&B' . $objPHPExcel->getProperties()->getTitle() . '&RPage &P of &N');
|
||||
|
||||
|
||||
// Set page orientation and size
|
||||
echo date('H:i:s') . " Set page orientation and size\n";
|
||||
echo date('H:i:s') , " Set page orientation and size" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT);
|
||||
$objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
|
||||
|
||||
|
||||
// Rename sheet
|
||||
echo date('H:i:s') . " Rename sheet\n";
|
||||
// Rename worksheet
|
||||
echo date('H:i:s') , " Rename worksheet" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->setTitle('Invoice');
|
||||
|
||||
|
||||
|
@ -146,13 +152,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,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,13 +50,13 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
|||
|
||||
|
||||
// Create a first sheet
|
||||
echo date('H:i:s') . " Add data and breaks\n";
|
||||
echo date('H:i:s') , " Add data and page breaks" , PHP_EOL;
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Firstname");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B1', "Lastname");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C1', "Phone");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D1', "Fax");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E1', "Is Client ?");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Firstname")
|
||||
->setCellValue('B1', "Lastname")
|
||||
->setCellValue('C1', "Phone")
|
||||
->setCellValue('D1', "Fax")
|
||||
->setCellValue('E1', "Is Client ?");
|
||||
|
||||
|
||||
// Add data
|
||||
|
@ -80,13 +80,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,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,64 +49,101 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
|||
->setCategory("Test result file");
|
||||
|
||||
|
||||
// Create a first sheet
|
||||
echo date('H:i:s') . " Add data\n";
|
||||
// Create the worksheet
|
||||
echo date('H:i:s') , " Add data" , PHP_EOL;
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Quarter");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B1', "Country");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C1', "Sales");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Year")
|
||||
->setCellValue('B1', "Quarter")
|
||||
->setCellValue('C1', "Country")
|
||||
->setCellValue('D1', "Sales");
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A2', "Q1");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B2', "United States");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C2', "800");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A3', "Q2");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B3', "United States");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C3', "700");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A4', "Q3");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B4', "United States");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C4', "900");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A5', "Q4");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B5', "United States");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C5', "950");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A6', "Q1");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B6', "Belgium");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C6', "400");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A7', "Q2");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B7', "Belgium");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C7', "350");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A8', "Q3");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B8', "Belgium");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C8', "450");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A9', "Q4");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B9', "Belgium");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C9', "500");
|
||||
$dataArray = array(array("2010", "Q1", "United States", 790),
|
||||
array("2010", "Q2", "United States", 730),
|
||||
array("2010", "Q3", "United States", 860),
|
||||
array("2010", "Q4", "United States", 850),
|
||||
array("2011", "Q1", "United States", 800),
|
||||
array("2011", "Q2", "United States", 700),
|
||||
array("2011", "Q3", "United States", 900),
|
||||
array("2011", "Q4", "United States", 950),
|
||||
array("2010", "Q1", "Belgium", 380),
|
||||
array("2010", "Q2", "Belgium", 390),
|
||||
array("2010", "Q3", "Belgium", 420),
|
||||
array("2010", "Q4", "Belgium", 460),
|
||||
array("2011", "Q1", "Belgium", 400),
|
||||
array("2011", "Q2", "Belgium", 350),
|
||||
array("2011", "Q3", "Belgium", 450),
|
||||
array("2011", "Q4", "Belgium", 500),
|
||||
array("2010", "Q1", "UK", 690),
|
||||
array("2010", "Q2", "UK", 610),
|
||||
array("2010", "Q3", "UK", 620),
|
||||
array("2010", "Q4", "UK", 600),
|
||||
array("2011", "Q1", "UK", 720),
|
||||
array("2011", "Q2", "UK", 650),
|
||||
array("2011", "Q3", "UK", 580),
|
||||
array("2011", "Q4", "UK", 510),
|
||||
array("2010", "Q1", "France", 510),
|
||||
array("2010", "Q2", "France", 490),
|
||||
array("2010", "Q3", "France", 460),
|
||||
array("2010", "Q4", "France", 590),
|
||||
array("2011", "Q1", "France", 620),
|
||||
array("2011", "Q2", "France", 650),
|
||||
array("2011", "Q3", "France", 415),
|
||||
array("2011", "Q4", "France", 570),
|
||||
array("2010", "Q1", "Germany", 720),
|
||||
array("2010", "Q2", "Germany", 680),
|
||||
array("2010", "Q3", "Germany", 640),
|
||||
array("2010", "Q4", "Germany", 660),
|
||||
array("2011", "Q1", "Germany", 680),
|
||||
array("2011", "Q2", "Germany", 620),
|
||||
array("2011", "Q3", "Germany", 710),
|
||||
array("2011", "Q4", "Germany", 690),
|
||||
array("2010", "Q1", "Spain", 510),
|
||||
array("2010", "Q2", "Spain", 490),
|
||||
array("2010", "Q3", "Spain", 470),
|
||||
array("2010", "Q4", "Spain", 420),
|
||||
array("2011", "Q1", "Spain", 460),
|
||||
array("2011", "Q2", "Spain", 390),
|
||||
array("2011", "Q3", "Spain", 430),
|
||||
array("2011", "Q4", "Spain", 415),
|
||||
array("2010", "Q1", "Italy", 440),
|
||||
array("2010", "Q2", "Italy", 410),
|
||||
array("2010", "Q3", "Italy", 420),
|
||||
array("2010", "Q4", "Italy", 450),
|
||||
array("2011", "Q1", "Italy", 430),
|
||||
array("2011", "Q2", "Italy", 370),
|
||||
array("2011", "Q3", "Italy", 350),
|
||||
array("2011", "Q4", "Italy", 335),
|
||||
);
|
||||
|
||||
|
||||
$objPHPExcel->getActiveSheet()->fromArray($dataArray, NULL, 'A2');
|
||||
|
||||
|
||||
// Set title row bold
|
||||
echo date('H:i:s') . " Set title row bold\n";
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setBold(true);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('C1')->getFont()->setBold(true);
|
||||
echo date('H:i:s') , " Set title row bold" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A1:D1')->getFont()->setBold(true);
|
||||
|
||||
|
||||
// Set autofilter
|
||||
echo date('H:i:s') . " Set autofilter\n";
|
||||
$objPHPExcel->getActiveSheet()->setAutoFilter('A1:C9'); // Always include the complete filter range!
|
||||
// Excel does support setting only the caption
|
||||
// row, but that's not a best practise...
|
||||
echo date('H:i:s') , " Set autofilter" , PHP_EOL;
|
||||
// Always include the complete filter range!
|
||||
// Excel does support setting only the caption
|
||||
// row, but that's not a best practise...
|
||||
$objPHPExcel->getActiveSheet()->setAutoFilter($objPHPExcel->getActiveSheet()->calculateWorksheetDimension());
|
||||
|
||||
// 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\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;
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
<?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';
|
||||
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s') , " Create new PHPExcel object" , PHP_EOL;
|
||||
$objPHPExcel = new PHPExcel();
|
||||
|
||||
// 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")
|
||||
->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);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Hello');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B2', 'world!');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C1', 'Hello');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D2', 'world!');
|
||||
|
||||
// Rename worksheet
|
||||
echo date('H:i:s') , " Rename worksheet" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->setTitle('Simple');
|
||||
|
||||
|
||||
// Set document security
|
||||
echo date('H:i:s') , " Set document security" , PHP_EOL;
|
||||
$objPHPExcel->getSecurity()->setLockWindows(true);
|
||||
$objPHPExcel->getSecurity()->setLockStructure(true);
|
||||
$objPHPExcel->getSecurity()->setWorkbookPassword("PHPExcel");
|
||||
|
||||
|
||||
// Set sheet security
|
||||
echo date('H:i:s') , " Set sheet security" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->getProtection()->setPassword('PHPExcel');
|
||||
$objPHPExcel->getActiveSheet()->getProtection()->setSheet(true); // This should be enabled in order to enable any of the following!
|
||||
$objPHPExcel->getActiveSheet()->getProtection()->setSort(true);
|
||||
$objPHPExcel->getActiveSheet()->getProtection()->setInsertRows(true);
|
||||
$objPHPExcel->getActiveSheet()->getProtection()->setFormatCells(true);
|
||||
|
||||
|
||||
// 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 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 done
|
||||
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,27 +50,27 @@ $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', 'Hello');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B2', 'world!');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C1', 'Hello');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D2', 'world!');
|
||||
|
||||
// Rename sheet
|
||||
echo date('H:i:s') . " Rename sheet\n";
|
||||
// Rename worksheet
|
||||
echo date('H:i:s') , " Rename worksheet" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->setTitle('Simple');
|
||||
|
||||
|
||||
// Set document security
|
||||
echo date('H:i:s') . " Set document security\n";
|
||||
echo date('H:i:s') , " Set document security" , PHP_EOL;
|
||||
$objPHPExcel->getSecurity()->setLockWindows(true);
|
||||
$objPHPExcel->getSecurity()->setLockStructure(true);
|
||||
$objPHPExcel->getSecurity()->setWorkbookPassword("PHPExcel");
|
||||
|
||||
|
||||
// Set sheet security
|
||||
echo date('H:i:s') . " Set sheet security\n";
|
||||
echo date('H:i:s') , " Set sheet security" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->getProtection()->setPassword('PHPExcel');
|
||||
$objPHPExcel->getActiveSheet()->getProtection()->setSheet(true); // This should be enabled in order to enable any of the following!
|
||||
$objPHPExcel->getActiveSheet()->getProtection()->setSort(true);
|
||||
|
@ -83,13 +83,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,21 +30,21 @@ error_reporting(E_ALL);
|
|||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** PHPExcel */
|
||||
/** Include PHPExcel */
|
||||
require_once '../Classes/PHPExcel.php';
|
||||
|
||||
|
||||
// List functions
|
||||
echo date('H:i:s') . " List implemented functions\n";
|
||||
echo date('H:i:s') , " List implemented functions" , PHP_EOL;
|
||||
$objCalc = PHPExcel_Calculation::getInstance();
|
||||
print_r($objCalc->listFunctionNames());
|
||||
|
||||
// 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();
|
||||
|
||||
// Add some data, we will use some formulas here
|
||||
echo date('H:i:s') . " Add some data\n";
|
||||
echo date('H:i:s') , " Add some data and formulas" , PHP_EOL;
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A14', 'Count:');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A15', 'Sum:');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A16', 'Max:');
|
||||
|
@ -155,92 +155,57 @@ $objPHPExcel->getActiveSheet()->setCellValue('D2', 2);
|
|||
$objPHPExcel->getActiveSheet()->setCellValue('D3', 3);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D4', 4);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D5', '=((D2 * D3) + D4) & " should be 10"');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D14', '=((D2 * D3) + D4) & " should be 10"');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E1', 'Other functions');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E2', '=PI()');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E3', '=RAND()');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E4', '=RANDBETWEEN(5, 10)');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E12', 'Other functions');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E14', '=PI()');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E15', '=RAND()');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E16', '=RANDBETWEEN(5, 10)');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E14', 'Count of both ranges:');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('F14', '=COUNT(B2:C12)');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E17', 'Count of both ranges:');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('F17', '=COUNT(B2:C12)');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E15', 'Total of both ranges:');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('F15', '=SUM(B2:C12)');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E18', 'Total of both ranges:');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('F18', '=SUM(B2:C12)');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E16', 'Maximum of both ranges:');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('F16', '=MAX(B2:C12)');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E19', 'Maximum of both ranges:');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('F19', '=MAX(B2:C12)');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E17', 'Minimum of both ranges:');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('F17', '=MIN(B2:C12)');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E20', 'Minimum of both ranges:');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('F20', '=MIN(B2:C12)');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E18', 'Average of both ranges:');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('F18', '=AVERAGE(B2:C12)');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E21', 'Average of both ranges:');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('F21', '=AVERAGE(B2:C12)');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E19', 'Median of both ranges:');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('F19', '=MEDIAN(B2:C12)');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E22', 'Median of both ranges:');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('F22', '=MEDIAN(B2:C12)');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E20', 'Mode of both ranges:');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('F20', '=MODE(B2:C12)');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E23', 'Mode of both ranges:');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('F23', '=MODE(B2:C12)');
|
||||
|
||||
|
||||
// Calculated data
|
||||
echo date('H:i:s') . " Calculated data\n";
|
||||
echo 'Value of B14 [=COUNT(B2:B12)]: ' . $objPHPExcel->getActiveSheet()->getCell('B14')->getCalculatedValue() . "\r\n";
|
||||
echo 'Value of B15 [=SUM(B2:B12)]: ' . $objPHPExcel->getActiveSheet()->getCell('B15')->getCalculatedValue() . "\r\n";
|
||||
echo 'Value of B16 [=MAX(B2:B12)]: ' . $objPHPExcel->getActiveSheet()->getCell('B16')->getCalculatedValue() . "\r\n";
|
||||
echo 'Value of B17 [=MIN(B2:B12)]: ' . $objPHPExcel->getActiveSheet()->getCell('B17')->getCalculatedValue() . "\r\n";
|
||||
echo 'Value of B18 [=AVERAGE(B2:B12)]: ' . $objPHPExcel->getActiveSheet()->getCell('B18')->getCalculatedValue() . "\r\n";
|
||||
echo 'Value of B19 [=MEDIAN(B2:B12)]: ' . $objPHPExcel->getActiveSheet()->getCell('B19')->getCalculatedValue() . "\r\n";
|
||||
echo 'Value of B20 [=MODE(B2:B12)]: ' . $objPHPExcel->getActiveSheet()->getCell('B20')->getCalculatedValue() . "\r\n";
|
||||
echo date('H:i:s') , " Calculated data" , PHP_EOL;
|
||||
for ($col = 'B'; $col != 'G'; ++$col) {
|
||||
for($row = 14; $row <= 41; ++$row) {
|
||||
if ((!is_null($formula = $objPHPExcel->getActiveSheet()->getCell($col.$row)->getValue())) &&
|
||||
($formula[0] == '=')) {
|
||||
echo 'Value of ' , $col , $row , ' [' , $formula , ']: ' ,
|
||||
$objPHPExcel->getActiveSheet()->getCell($col.$row)->getCalculatedValue() . PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo 'Value of B22 [=COUNTA(B2:B12)]: ' . $objPHPExcel->getActiveSheet()->getCell('B22')->getCalculatedValue() . "\r\n";
|
||||
echo 'Value of B23 [=MAXA(B2:B12)]: ' . $objPHPExcel->getActiveSheet()->getCell('B23')->getCalculatedValue() . "\r\n";
|
||||
echo 'Value of B24 [=MINA(B2:B12)]: ' . $objPHPExcel->getActiveSheet()->getCell('B24')->getCalculatedValue() . "\r\n";
|
||||
|
||||
echo 'Value of B26 [=STDEV(B2:B12)]: ' . $objPHPExcel->getActiveSheet()->getCell('B26')->getCalculatedValue() . "\r\n";
|
||||
echo 'Value of B27 [=STDEVA(B2:B12)]: ' . $objPHPExcel->getActiveSheet()->getCell('B27')->getCalculatedValue() . "\r\n";
|
||||
echo 'Value of B28 [=STDEVP(B2:B12)]: ' . $objPHPExcel->getActiveSheet()->getCell('B28')->getCalculatedValue() . "\r\n";
|
||||
echo 'Value of B29 [=STDEVPA(B2:B12)]: ' . $objPHPExcel->getActiveSheet()->getCell('B29')->getCalculatedValue() . "\r\n";
|
||||
|
||||
echo 'Value of B31 [=DEVSQ(B2:B12)]: ' . $objPHPExcel->getActiveSheet()->getCell('B31')->getCalculatedValue() . "\r\n";
|
||||
echo 'Value of B32 [=VAR(B2:B12)]: ' . $objPHPExcel->getActiveSheet()->getCell('B32')->getCalculatedValue() . "\r\n";
|
||||
echo 'Value of B33 [=VARA(B2:B12)]: ' . $objPHPExcel->getActiveSheet()->getCell('B33')->getCalculatedValue() . "\r\n";
|
||||
echo 'Value of B34 [=VARP(B2:B12)]: ' . $objPHPExcel->getActiveSheet()->getCell('B34')->getCalculatedValue() . "\r\n";
|
||||
echo 'Value of B35 [=VARPA(B2:B12)]: ' . $objPHPExcel->getActiveSheet()->getCell('B35')->getCalculatedValue() . "\r\n";
|
||||
|
||||
echo 'Value of C14 [=COUNT(C2:C12)]: ' . $objPHPExcel->getActiveSheet()->getCell('C14')->getCalculatedValue() . "\r\n";
|
||||
echo 'Value of C15 [=SUM(C2:C12)]: ' . $objPHPExcel->getActiveSheet()->getCell('C15')->getCalculatedValue() . "\r\n";
|
||||
echo 'Value of C16 [=MAX(C2:C12)]: ' . $objPHPExcel->getActiveSheet()->getCell('C16')->getCalculatedValue() . "\r\n";
|
||||
echo 'Value of C17 [=MIN(C2:C12)]: ' . $objPHPExcel->getActiveSheet()->getCell('C17')->getCalculatedValue() . "\r\n";
|
||||
echo 'Value of C18 [=AVERAGE(C2:C12)]: ' . $objPHPExcel->getActiveSheet()->getCell('C18')->getCalculatedValue() . "\r\n";
|
||||
echo 'Value of C19 [=MEDIAN(C2:C12)]: ' . $objPHPExcel->getActiveSheet()->getCell('C19')->getCalculatedValue() . "\r\n";
|
||||
echo 'Value of C20 [=MODE(C2:C12)]: ' . $objPHPExcel->getActiveSheet()->getCell('C20')->getCalculatedValue() . "\r\n";
|
||||
|
||||
echo 'Value of C22 [=COUNTA(C2:C12)]: ' . $objPHPExcel->getActiveSheet()->getCell('C22')->getCalculatedValue() . "\r\n";
|
||||
echo 'Value of C23 [=MAXA(C2:C12)]: ' . $objPHPExcel->getActiveSheet()->getCell('C23')->getCalculatedValue() . "\r\n";
|
||||
echo 'Value of C24 [=MINA(C2:C12)]: ' . $objPHPExcel->getActiveSheet()->getCell('C24')->getCalculatedValue() . "\r\n";
|
||||
|
||||
echo 'Value of C26 [=STDEV(C2:C12)]: ' . $objPHPExcel->getActiveSheet()->getCell('C26')->getCalculatedValue() . "\r\n";
|
||||
echo 'Value of C27 [=STDEVA(C2:C12)]: ' . $objPHPExcel->getActiveSheet()->getCell('C27')->getCalculatedValue() . "\r\n";
|
||||
echo 'Value of C28 [=STDEVP(C2:C12)]: ' . $objPHPExcel->getActiveSheet()->getCell('C28')->getCalculatedValue() . "\r\n";
|
||||
echo 'Value of C29 [=STDEVPA(C2:C12)]: ' . $objPHPExcel->getActiveSheet()->getCell('C29')->getCalculatedValue() . "\r\n";
|
||||
|
||||
echo 'Value of C31 [=DEVSQ(C2:C12)]: ' . $objPHPExcel->getActiveSheet()->getCell('C31')->getCalculatedValue() . "\r\n";
|
||||
echo 'Value of C32 [=VAR(C2:C12)]: ' . $objPHPExcel->getActiveSheet()->getCell('C32')->getCalculatedValue() . "\r\n";
|
||||
echo 'Value of C33 [=VARA(C2:C12)]: ' . $objPHPExcel->getActiveSheet()->getCell('C33')->getCalculatedValue() . "\r\n";
|
||||
echo 'Value of C34 [=VARP(C2:C12)]: ' . $objPHPExcel->getActiveSheet()->getCell('C34')->getCalculatedValue() . "\r\n";
|
||||
echo 'Value of C35 [=VARPA(C2:C12)]: ' . $objPHPExcel->getActiveSheet()->getCell('C35')->getCalculatedValue() . "\r\n";
|
||||
|
||||
echo 'Value of B37 [=DATE(2007, 12, 21)]: ' . $objPHPExcel->getActiveSheet()->getCell('B37')->getCalculatedValue() . "\r\n";
|
||||
echo 'Value of B38 [=DATEDIF( DATE(2007, 12, 21), DATE(2007, 12, 22), "D" )]: ' . $objPHPExcel->getActiveSheet()->getCell('B38')->getCalculatedValue() . "\r\n";
|
||||
echo 'Value of B39 [=DATEVALUE("01-Feb-2006 10:06 AM")]: ' . $objPHPExcel->getActiveSheet()->getCell('B39')->getCalculatedValue() . "\r\n";
|
||||
echo 'Value of B40 [=DAY( DATE(2006, 1, 2) )]: ' . $objPHPExcel->getActiveSheet()->getCell('B40')->getCalculatedValue() . "\r\n";
|
||||
echo 'Value of B41 [=DAYS360( DATE(2002, 2, 3), DATE(2005, 5, 31) )]: ' . $objPHPExcel->getActiveSheet()->getCell('B41')->getCalculatedValue() . "\r\n";
|
||||
// Save Excel 2007 file
|
||||
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.\r\n";
|
||||
echo date('H:i:s') , " Done" , 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,13 +36,14 @@ include "05featuredemo.inc.php";
|
|||
require_once '../Classes/PHPExcel/IOFactory.php';
|
||||
|
||||
|
||||
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;
|
||||
|
|
|
@ -0,0 +1,107 @@
|
|||
<?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';
|
||||
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s') , " Create new PHPExcel object" , PHP_EOL;
|
||||
$objPHPExcel = new PHPExcel();
|
||||
|
||||
|
||||
// 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")
|
||||
->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");
|
||||
|
||||
|
||||
// Create a first sheet
|
||||
echo date('H:i:s') , " Add data" , PHP_EOL;
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Cell B3 and B5 contain data validation...");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A3', "Number:");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B3', "10");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A5', "List:");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B5', "Item A");
|
||||
|
||||
|
||||
// Set data validation
|
||||
echo date('H:i:s') , " Set data validation" , PHP_EOL;
|
||||
$objValidation = $objPHPExcel->getActiveSheet()->getCell('B3')->getDataValidation();
|
||||
$objValidation->setType( PHPExcel_Cell_DataValidation::TYPE_WHOLE );
|
||||
$objValidation->setErrorStyle( PHPExcel_Cell_DataValidation::STYLE_STOP );
|
||||
$objValidation->setAllowBlank(true);
|
||||
$objValidation->setShowInputMessage(true);
|
||||
$objValidation->setShowErrorMessage(true);
|
||||
$objValidation->setErrorTitle('Input error');
|
||||
$objValidation->setError('Only numbers between 10 and 20 are allowed!');
|
||||
$objValidation->setPromptTitle('Allowed input');
|
||||
$objValidation->setPrompt('Only numbers between 10 and 20 are allowed.');
|
||||
$objValidation->setFormula1(10);
|
||||
$objValidation->setFormula2(20);
|
||||
|
||||
$objValidation = $objPHPExcel->getActiveSheet()->getCell('B5')->getDataValidation();
|
||||
$objValidation->setType( PHPExcel_Cell_DataValidation::TYPE_LIST );
|
||||
$objValidation->setErrorStyle( PHPExcel_Cell_DataValidation::STYLE_INFORMATION );
|
||||
$objValidation->setAllowBlank(false);
|
||||
$objValidation->setShowInputMessage(true);
|
||||
$objValidation->setShowErrorMessage(true);
|
||||
$objValidation->setShowDropDown(true);
|
||||
$objValidation->setErrorTitle('Input error');
|
||||
$objValidation->setError('Value is not in list.');
|
||||
$objValidation->setPromptTitle('Pick from list');
|
||||
$objValidation->setPrompt('Please pick a value from the drop-down list.');
|
||||
$objValidation->setFormula1('"Item A,Item B,Item C"'); // Make sure to put the list items between " and " !!!
|
||||
|
||||
|
||||
// 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 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 done
|
||||
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,17 +30,17 @@ 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")
|
||||
|
@ -51,7 +51,7 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
|||
|
||||
|
||||
// Create a first sheet
|
||||
echo date('H:i:s') . " Add data\n";
|
||||
echo date('H:i:s') , " Add data" , PHP_EOL;
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Cell B3 and B5 contain data validation...");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A3', "Number:");
|
||||
|
@ -61,7 +61,7 @@ $objPHPExcel->getActiveSheet()->setCellValue('B5', "Item A");
|
|||
|
||||
|
||||
// Set data validation
|
||||
echo date('H:i:s') . " Set data validation\n";
|
||||
echo date('H:i:s') , " Set data validation" , PHP_EOL;
|
||||
$objValidation = $objPHPExcel->getActiveSheet()->getCell('B3')->getDataValidation();
|
||||
$objValidation->setType( PHPExcel_Cell_DataValidation::TYPE_WHOLE );
|
||||
$objValidation->setErrorStyle( PHPExcel_Cell_DataValidation::STYLE_STOP );
|
||||
|
@ -69,7 +69,7 @@ $objValidation->setAllowBlank(true);
|
|||
$objValidation->setShowInputMessage(true);
|
||||
$objValidation->setShowErrorMessage(true);
|
||||
$objValidation->setErrorTitle('Input error');
|
||||
$objValidation->setError('Number is not allowed!');
|
||||
$objValidation->setError('Only numbers between 10 and 20 are allowed!');
|
||||
$objValidation->setPromptTitle('Allowed input');
|
||||
$objValidation->setPrompt('Only numbers between 10 and 20 are allowed.');
|
||||
$objValidation->setFormula1(10);
|
||||
|
@ -94,13 +94,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##
|
||||
*/
|
||||
|
@ -36,29 +36,31 @@ include "05featuredemo.inc.php";
|
|||
require_once '../Classes/PHPExcel/IOFactory.php';
|
||||
|
||||
|
||||
echo date('H:i:s') . " Write to CSV format\n";
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'CSV')
|
||||
->setDelimiter(',')
|
||||
->setEnclosure('')
|
||||
->setLineEnding("\r\n")
|
||||
->setSheetIndex(0)
|
||||
->save(str_replace('.php', '.csv', __FILE__));
|
||||
echo date('H:i:s') , " Write to CSV format" , PHP_EOL;
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'CSV')->setDelimiter(',')
|
||||
->setEnclosure('"')
|
||||
->setLineEnding("\r\n")
|
||||
->setSheetIndex(0)
|
||||
->save(str_replace('.php', '.csv', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.csv', __FILE__) , PHP_EOL;
|
||||
|
||||
echo date('H:i:s') . " Read from CSV format\n";
|
||||
$objReader = PHPExcel_IOFactory::createReader('CSV')
|
||||
->setDelimiter(',')
|
||||
->setEnclosure('')
|
||||
->setLineEnding("\r\n")
|
||||
->setSheetIndex(0);
|
||||
echo date('H:i:s') , " Read from CSV format" , PHP_EOL;
|
||||
$objReader = PHPExcel_IOFactory::createReader('CSV')->setDelimiter(',')
|
||||
->setEnclosure('"')
|
||||
->setLineEnding("\r\n")
|
||||
->setSheetIndex(0);
|
||||
$objPHPExcelFromCSV = $objReader->load(str_replace('.php', '.csv', __FILE__));
|
||||
echo date('H:i:s') , " File read from " , str_replace('.php', '.csv', __FILE__) , PHP_EOL;
|
||||
|
||||
echo date('H:i:s') . " Write to Excel2007 format\n";
|
||||
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , PHP_EOL;
|
||||
$objWriter2007 = PHPExcel_IOFactory::createWriter($objPHPExcelFromCSV, 'Excel2007');
|
||||
$objWriter2007->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##
|
||||
*/
|
||||
|
@ -36,15 +36,16 @@ include "05featuredemo.inc.php";
|
|||
require_once '../Classes/PHPExcel/IOFactory.php';
|
||||
|
||||
|
||||
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->setSheetIndex(0);
|
||||
//$objWriter->setImagesRoot('http://www.example.com');
|
||||
$objWriter->save(str_replace('.php', '.htm', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.htm', __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;
|
||||
|
|
|
@ -35,11 +35,11 @@ require_once '../Classes/PHPExcel.php';
|
|||
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s') . " Create new PHPExcel object<br />";
|
||||
echo date('H:i:s') . " Create new PHPExcel object" , PHP_EOL;
|
||||
$objPHPExcel = new PHPExcel();
|
||||
|
||||
// Set properties
|
||||
echo date('H:i:s') . " Set properties<br />";
|
||||
echo date('H:i:s') . " Set properties" , PHP_EOL;
|
||||
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Franklin")
|
||||
->setTitle("Office 2007 XLSX Test Document")
|
||||
|
@ -48,7 +48,7 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
|||
->setKeywords("office 2007 openxml php")
|
||||
->setCategory("Test result file");
|
||||
// Add some data
|
||||
echo date('H:i:s') . " Add some data<br />";
|
||||
echo date('H:i:s') . " Add some data" , PHP_EOL;
|
||||
$objPHPExcel->setActiveSheetIndex(0)
|
||||
->setCellValue('A1', 'Hello')
|
||||
->setCellValue('B2', 'world!');
|
||||
|
@ -57,40 +57,47 @@ $objPHPExcel->setActiveSheetIndex(0)
|
|||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
// Save Excel 2007 file
|
||||
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') . " 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<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 memory peak usage
|
||||
echo date('H:i:s') . " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB\r<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.\r<br />";
|
||||
echo date('H:i:s') . " Done writing files." , PHP_EOL;
|
||||
unset($objWriter);
|
||||
|
||||
echo '<br />';
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s') . " Create new PHPExcel object<br />";
|
||||
|
||||
echo PHP_EOL;
|
||||
// Reread File
|
||||
echo date('H:i:s') . " Reread Excel5 file" , PHP_EOL;
|
||||
$objPHPExcelRead = PHPExcel_IOFactory::load('31docproperties_write.xls');
|
||||
|
||||
// Set properties
|
||||
echo date('H:i:s') . " Get properties<br />";
|
||||
echo 'Creator : '.$objPHPExcelRead->getProperties()->getCreator().'<br />';
|
||||
echo 'LastModifiedBy : '.$objPHPExcelRead->getProperties()->getLastModifiedBy().'<br />';
|
||||
echo 'Title : '.$objPHPExcelRead->getProperties()->getTitle().'<br />';
|
||||
echo 'Subject : '.$objPHPExcelRead->getProperties()->getSubject().'<br />';
|
||||
echo 'Description : '.$objPHPExcelRead->getProperties()->getDescription().'<br />';
|
||||
echo 'Keywords : '.$objPHPExcelRead->getProperties()->getKeywords().'<br />';
|
||||
echo 'Category : '.$objPHPExcelRead->getProperties()->getCategory().'<br />';
|
||||
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 memory peak usage
|
||||
echo date('H:i:s') . " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB\r<br />";
|
||||
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##
|
||||
*/
|
||||
|
@ -32,18 +32,22 @@ error_reporting(E_ALL);
|
|||
$aTests = array(
|
||||
'01simple.php'
|
||||
, '02types.php'
|
||||
, '02types-xls.php'
|
||||
, '03formulas.php'
|
||||
, '04printing.php'
|
||||
, '05featuredemo.php'
|
||||
, '06largescale.php'
|
||||
, '06largescale-xls.php'
|
||||
, '07reader.php'
|
||||
, '08conditionalformatting.php'
|
||||
, '09pagebreaks.php'
|
||||
, '10autofilter.php'
|
||||
, '11documentsecurity.php'
|
||||
, '11documentsecurity-xls.php'
|
||||
, '13calculation.php'
|
||||
, '14excel5.php'
|
||||
, '15datavalidation.php'
|
||||
, '15datavalidation-xls.php'
|
||||
, '16csv.php'
|
||||
, '17html.php'
|
||||
, '18extendedcalculation.php'
|
||||
|
@ -59,6 +63,8 @@ $aTests = array(
|
|||
, '28iterator.php'
|
||||
, '29advancedvaluebinder.php'
|
||||
, '30template.php'
|
||||
, '31docproperties_write.php'
|
||||
, '32chartreadwrite.php'
|
||||
, 'OOCalcReader.php'
|
||||
, 'SylkReader.php'
|
||||
, 'Excel2003XMLReader.php'
|
||||
|
|
Loading…
Reference in New Issue