Merge branch 'develop' of https://github.com/PHPOffice/PHPExcel into autofilter

This commit is contained in:
Mark Baker 2012-08-07 10:16:03 +01:00
commit b694241de6
116 changed files with 5489 additions and 4156 deletions

View File

@ -239,9 +239,12 @@ class PHPExcel_Calculation_TextData {
$haystack = ($haystack) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
}
if (($offset > 0) && (strlen($haystack) > $offset)) {
if (($offset > 0) && (PHPExcel_Shared_String::CountCharacters($haystack) > $offset)) {
if (PHPExcel_Shared_String::CountCharacters($needle) == 0) {
return $offset;
}
if (function_exists('mb_strpos')) {
$pos = mb_strpos($haystack, $needle, --$offset,'UTF-8');
$pos = mb_strpos($haystack, $needle, --$offset, 'UTF-8');
} else {
$pos = strpos($haystack, $needle, --$offset);
}
@ -272,7 +275,10 @@ class PHPExcel_Calculation_TextData {
$haystack = ($haystack) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
}
if (($offset > 0) && (strlen($haystack) > $offset)) {
if (($offset > 0) && (PHPExcel_Shared_String::CountCharacters($haystack) > $offset)) {
if (PHPExcel_Shared_String::CountCharacters($needle) == 0) {
return $offset;
}
if (function_exists('mb_stripos')) {
$pos = mb_stripos($haystack, $needle, --$offset,'UTF-8');
} else {

View File

@ -1,108 +1,112 @@
<?php
/**
* PHPExcel
* PHPExcel
*
* Copyright (c) 2006 - 2012 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 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.
* 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
* 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_Cell
* @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##
* @category PHPExcel
* @package PHPExcel_Cell
* @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##
*/
/**
* PHPExcel_Cell
* PHPExcel_Cell
*
* @category PHPExcel
* @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @category PHPExcel
* @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Cell
{
/**
* Value binder to use
* Value binder to use
*
* @var PHPExcel_Cell_IValueBinder
* @var PHPExcel_Cell_IValueBinder
*/
private static $_valueBinder = null;
private static $_valueBinder = NULL;
/**
* Column of the cell
* Column of the cell
*
* @var string
* @var string
*/
private $_column;
/**
* Row of the cell
* Row of the cell
*
* @var int
* @var int
*/
private $_row;
/**
* Value of the cell
* Value of the cell
*
* @var mixed
* @var mixed
*/
private $_value;
/**
* Calculated value of the cell (used for caching)
* Calculated value of the cell (used for caching)
* This returns the value last calculated by MS Excel or whichever spreadsheet program was used to
* create the original spreadsheet file.
* Note that this value is not guaranteed to reflect the actual calculated value because it is
* possible that auto-calculation was disabled in the original spreadsheet, and underlying data
* values used by the formula have changed since it was last calculated.
*
* @var mixed
* @var mixed
*/
private $_calculatedValue = null;
private $_calculatedValue = NULL;
/**
* Type of the cell data
* Type of the cell data
*
* @var string
* @var string
*/
private $_dataType;
/**
* Parent worksheet
* Parent worksheet
*
* @var PHPExcel_Worksheet
* @var PHPExcel_Worksheet
*/
private $_parent;
/**
* Index to cellXf
* Index to cellXf
*
* @var int
* @var int
*/
private $_xfIndex;
/**
* Attributes of the formula
*
* Attributes of the formula
*
*/
private $_formulaAttributes;
/**
* Send notification to the cache controller
* Send notification to the cache controller
*
* @return void
* @return void
**/
public function notifyCacheController() {
$this->_parent->getCellCacheController()->updateCacheData($this);
@ -110,7 +114,7 @@ class PHPExcel_Cell
}
public function detach() {
$this->_parent = null;
$this->_parent = NULL;
}
public function attach($parent) {
@ -119,16 +123,16 @@ class PHPExcel_Cell
/**
* Create a new Cell
* Create a new Cell
*
* @param string $pColumn
* @param int $pRow
* @param mixed $pValue
* @param string $pDataType
* @param PHPExcel_Worksheet $pSheet
* @throws Exception
* @param string $pColumn
* @param int $pRow
* @param mixed $pValue
* @param string $pDataType
* @param PHPExcel_Worksheet $pSheet
* @throws PHPExcel_Exception
*/
public function __construct($pColumn = 'A', $pRow = 1, $pValue = null, $pDataType = null, PHPExcel_Worksheet $pSheet = null)
public function __construct($pColumn = 'A', $pRow = 1, $pValue = NULL, $pDataType = NULL, PHPExcel_Worksheet $pSheet = NULL)
{
// Initialise cell coordinate
$this->_column = strtoupper($pColumn);
@ -141,13 +145,13 @@ class PHPExcel_Cell
$this->_parent = $pSheet;
// Set datatype?
if ($pDataType !== null) {
if ($pDataType !== NULL) {
if ($pDataType == PHPExcel_Cell_DataType::TYPE_STRING2)
$pDataType = PHPExcel_Cell_DataType::TYPE_STRING;
$this->_dataType = $pDataType;
} else {
if (!self::getValueBinder()->bindValue($this, $pValue)) {
throw new Exception("Value could not be bound to cell.");
throw new PHPExcel_Exception("Value could not be bound to cell.");
}
}
@ -156,9 +160,9 @@ class PHPExcel_Cell
}
/**
* Get cell coordinate column
* Get cell coordinate column
*
* @return string
* @return string
*/
public function getColumn()
{
@ -166,9 +170,9 @@ class PHPExcel_Cell
}
/**
* Get cell coordinate row
* Get cell coordinate row
*
* @return int
* @return int
*/
public function getRow()
{
@ -176,9 +180,9 @@ class PHPExcel_Cell
}
/**
* Get cell coordinate
* Get cell coordinate
*
* @return string
* @return string
*/
public function getCoordinate()
{
@ -186,9 +190,9 @@ class PHPExcel_Cell
}
/**
* Get cell value
* Get cell value
*
* @return mixed
* @return mixed
*/
public function getValue()
{
@ -196,42 +200,45 @@ class PHPExcel_Cell
}
/**
* Get cell value with formatting
* Get cell value with formatting
*
* @return string
* @return string
*/
public function getFormattedValue()
{
return (string) PHPExcel_Style_NumberFormat::toFormattedString( $this->getCalculatedValue(),
$this->_parent->getParent()->getCellXfByIndex($this->getXfIndex())->getNumberFormat()->getFormatCode()
);
return (string) PHPExcel_Style_NumberFormat::toFormattedString(
$this->getCalculatedValue(),
$this->_parent->getParent()->getCellXfByIndex($this->getXfIndex())
->getNumberFormat()->getFormatCode()
);
}
/**
* Set cell value
* Set cell value
*
* Sets the value for a cell, automatically determining the datatype using the value binder
* Sets the value for a cell, automatically determining the datatype using the value binder
*
* @param mixed $pValue Value
* @return PHPExcel_Cell
* @param mixed $pValue Value
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function setValue($pValue = null)
public function setValue($pValue = NULL)
{
if (!self::getValueBinder()->bindValue($this, $pValue)) {
throw new Exception("Value could not be bound to cell.");
throw new PHPExcel_Exception("Value could not be bound to cell.");
}
return $this;
}
/**
* Set the value for a cell, with the explicit data type passed to the method (bypassing any use of the value binder)
* Set the value for a cell, with the explicit data type passed to the method (bypassing any use of the value binder)
*
* @param mixed $pValue Value
* @param string $pDataType Explicit data type
* @return PHPExcel_Cell
* @throws Exception
* @param mixed $pValue Value
* @param string $pDataType Explicit data type
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function setValueExplicit($pValue = null, $pDataType = PHPExcel_Cell_DataType::TYPE_STRING)
public function setValueExplicit($pValue = NULL, $pDataType = PHPExcel_Cell_DataType::TYPE_STRING)
{
// set the value according to data type
switch ($pDataType) {
@ -242,25 +249,20 @@ class PHPExcel_Cell
case PHPExcel_Cell_DataType::TYPE_INLINE:
$this->_value = PHPExcel_Cell_DataType::checkString($pValue);
break;
case PHPExcel_Cell_DataType::TYPE_NUMERIC:
$this->_value = (float)$pValue;
break;
case PHPExcel_Cell_DataType::TYPE_FORMULA:
$this->_value = (string)$pValue;
break;
case PHPExcel_Cell_DataType::TYPE_BOOL:
$this->_value = (bool)$pValue;
break;
case PHPExcel_Cell_DataType::TYPE_ERROR:
$this->_value = PHPExcel_Cell_DataType::checkErrorCode($pValue);
break;
default:
throw new Exception('Invalid datatype: ' . $pDataType);
throw new PHPExcel_Exception('Invalid datatype: ' . $pDataType);
break;
}
@ -271,13 +273,14 @@ class PHPExcel_Cell
}
/**
* Get calculated cell value
* Get calculated cell value
*
* @deprecated Since version 1.7.8 for planned changes to cell for array formula handling
*
* @return mixed
* @return mixed
* @throws PHPExcel_Exception
*/
public function getCalculatedValue($resetLog=true)
public function getCalculatedValue($resetLog = TRUE)
{
// echo 'Cell '.$this->getCoordinate().' value is a '.$this->_dataType.' with a value of '.$this->getValue().'<br />';
if ($this->_dataType == PHPExcel_Cell_DataType::TYPE_FORMULA) {
@ -292,7 +295,11 @@ class PHPExcel_Cell
}
// echo 'Calculation Exception: '.$ex->getMessage().'<br />';
$result = '#N/A';
throw(new Exception($this->getParent()->getTitle().'!'.$this->getCoordinate().' -> '.$ex->getMessage()));
throw(
new PHPExcel_Exception(
$this->getParent()->getTitle().'!'.$this->getCoordinate().' -> '.$ex->getMessage()
)
);
}
if ($result === '#Not Yet Implemented') {
@ -305,21 +312,19 @@ class PHPExcel_Cell
// if ($this->_value === NULL) {
// echo 'Cell '.$this->getCoordinate().' has no value, formula or otherwise<br />';
// return null;
// return NULL;
// }
// echo 'Cell value for '.$this->getCoordinate().' is not a formula: Returning data value of '.$this->_value.'<br />';
return $this->_value;
}
/**
* Set calculated value (used for caching)
* Set old calculated value (cached)
*
* @deprecated Since version 1.7.8 for planned changes to cell for array formula handling
*
* @param mixed $pValue Value
* @return PHPExcel_Cell
* @param mixed $pValue Value
* @return PHPExcel_Cell
*/
public function setCalculatedValue($pValue = null)
public function setCalculatedValue($pValue = NULL)
{
if ($pValue !== NULL) {
$this->_calculatedValue = (is_numeric($pValue)) ? (float) $pValue : $pValue;
@ -329,9 +334,14 @@ class PHPExcel_Cell
}
/**
* Get old calculated value (cached)
* Get old calculated value (cached)
* This returns the value last calculated by MS Excel or whichever spreadsheet program was used to
* create the original spreadsheet file.
* Note that this value is not guaranteed to refelect the actual calculated value because it is
* possible that auto-calculation was disabled in the original spreadsheet, and underlying data
* values used by the formula have changed since it was last calculated.
*
* @return mixed
* @return mixed
*/
public function getOldCalculatedValue()
{
@ -339,9 +349,9 @@ class PHPExcel_Cell
}
/**
* Get cell data type
* Get cell data type
*
* @return string
* @return string
*/
public function getDataType()
{
@ -349,10 +359,10 @@ class PHPExcel_Cell
}
/**
* Set cell data type
* Set cell data type
*
* @param string $pDataType
* @return PHPExcel_Cell
* @param string $pDataType
* @return PHPExcel_Cell
*/
public function setDataType($pDataType = PHPExcel_Cell_DataType::TYPE_STRING)
{
@ -365,44 +375,46 @@ class PHPExcel_Cell
}
/**
* Has Data validation?
* Does this cell contain Data validation rules?
*
* @return boolean
* @return boolean
* @throws PHPExcel_Exception
*/
public function hasDataValidation()
{
if (!isset($this->_parent)) {
throw new Exception('Cannot check for data validation when cell is not bound to a worksheet');
throw new PHPExcel_Exception('Cannot check for data validation when cell is not bound to a worksheet');
}
return $this->_parent->dataValidationExists($this->getCoordinate());
}
/**
* Get Data validation
* Get Data validation rules
*
* @return PHPExcel_Cell_DataValidation
* @return PHPExcel_Cell_DataValidation
* @throws PHPExcel_Exception
*/
public function getDataValidation()
{
if (!isset($this->_parent)) {
throw new Exception('Cannot get data validation for cell that is not bound to a worksheet');
throw new PHPExcel_Exception('Cannot get data validation for cell that is not bound to a worksheet');
}
return $this->_parent->getDataValidation($this->getCoordinate());
}
/**
* Set Data validation
* Set Data validation rules
*
* @param PHPExcel_Cell_DataValidation $pDataValidation
* @throws Exception
* @return PHPExcel_Cell
* @param PHPExcel_Cell_DataValidation $pDataValidation
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function setDataValidation(PHPExcel_Cell_DataValidation $pDataValidation = null)
public function setDataValidation(PHPExcel_Cell_DataValidation $pDataValidation = NULL)
{
if (!isset($this->_parent)) {
throw new Exception('Cannot set data validation for cell that is not bound to a worksheet');
throw new PHPExcel_Exception('Cannot set data validation for cell that is not bound to a worksheet');
}
$this->_parent->setDataValidation($this->getCoordinate(), $pDataValidation);
@ -411,45 +423,46 @@ class PHPExcel_Cell
}
/**
* Has Hyperlink
* Does this cell contain a Hyperlink?
*
* @return boolean
* @return boolean
* @throws PHPExcel_Exception
*/
public function hasHyperlink()
{
if (!isset($this->_parent)) {
throw new Exception('Cannot check for hyperlink when cell is not bound to a worksheet');
throw new PHPExcel_Exception('Cannot check for hyperlink when cell is not bound to a worksheet');
}
return $this->_parent->hyperlinkExists($this->getCoordinate());
}
/**
* Get Hyperlink
* Get Hyperlink
*
* @throws Exception
* @return PHPExcel_Cell_Hyperlink
* @return PHPExcel_Cell_Hyperlink
* @throws PHPExcel_Exception
*/
public function getHyperlink()
{
if (!isset($this->_parent)) {
throw new Exception('Cannot get hyperlink for cell that is not bound to a worksheet');
throw new PHPExcel_Exception('Cannot get hyperlink for cell that is not bound to a worksheet');
}
return $this->_parent->getHyperlink($this->getCoordinate());
}
/**
* Set Hyperlink
* Set Hyperlink
*
* @param PHPExcel_Cell_Hyperlink $pHyperlink
* @throws Exception
* @return PHPExcel_Cell
* @param PHPExcel_Cell_Hyperlink $pHyperlink
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function setHyperlink(PHPExcel_Cell_Hyperlink $pHyperlink = null)
public function setHyperlink(PHPExcel_Cell_Hyperlink $pHyperlink = NULL)
{
if (!isset($this->_parent)) {
throw new Exception('Cannot set hyperlink for cell that is not bound to a worksheet');
throw new PHPExcel_Exception('Cannot set hyperlink for cell that is not bound to a worksheet');
}
$this->_parent->setHyperlink($this->getCoordinate(), $pHyperlink);
@ -458,19 +471,19 @@ class PHPExcel_Cell
}
/**
* Get parent
* Get parent worksheet
*
* @return PHPExcel_Worksheet
* @return PHPExcel_Worksheet
*/
public function getParent() {
return $this->_parent;
}
/**
* Re-bind parent
* Re-bind parent
*
* @param PHPExcel_Worksheet $parent
* @return PHPExcel_Cell
* @param PHPExcel_Worksheet $parent
* @return PHPExcel_Cell
*/
public function rebindParent(PHPExcel_Worksheet $parent) {
$this->_parent = $parent;
@ -479,17 +492,17 @@ class PHPExcel_Cell
}
/**
* Is cell in a specific range?
* Is cell in a specific range?
*
* @param string $pRange Cell range (e.g. A1:A1)
* @return boolean
* @param string $pRange Cell range (e.g. A1:A1)
* @return boolean
*/
public function isInRange($pRange = 'A1:A1')
{
list($rangeStart,$rangeEnd) = PHPExcel_Cell::rangeBoundaries($pRange);
list($rangeStart,$rangeEnd) = self::rangeBoundaries($pRange);
// Translate properties
$myColumn = PHPExcel_Cell::columnIndexFromString($this->getColumn());
$myColumn = self::columnIndexFromString($this->getColumn());
$myRow = $this->getRow();
// Verify if cell is in range
@ -499,80 +512,91 @@ class PHPExcel_Cell
}
/**
* Coordinate from string
* Coordinate from string
*
* @param string $pCoordinateString
* @return array Array containing column and row (indexes 0 and 1)
* @throws Exception
* @param string $pCoordinateString
* @return array Array containing column and row (indexes 0 and 1)
* @throws PHPExcel_Exception
*/
public static function coordinateFromString($pCoordinateString = 'A1')
{
if (preg_match("/^([$]?[A-Z]{1,3})([$]?\d{1,7})$/", $pCoordinateString, $matches)) {
return array($matches[1],$matches[2]);
} elseif ((strpos($pCoordinateString,':') !== false) || (strpos($pCoordinateString,',') !== false)) {
throw new Exception('Cell coordinate string can not be a range of cells.');
} elseif ((strpos($pCoordinateString,':') !== FALSE) || (strpos($pCoordinateString,',') !== FALSE)) {
throw new PHPExcel_Exception('Cell coordinate string can not be a range of cells');
} elseif ($pCoordinateString == '') {
throw new Exception('Cell coordinate can not be zero-length string.');
} else {
throw new Exception('Invalid cell coordinate '.$pCoordinateString);
throw new PHPExcel_Exception('Cell coordinate can not be zero-length string');
}
throw new PHPExcel_Exception('Invalid cell coordinate '.$pCoordinateString);
}
/**
* Make string row, column or cell coordinate absolute
* Make string row, column or cell coordinate absolute
*
* @param string $pCoordinateString e.g. 'A' or '1' or 'A1'
* @return string Absolute coordinate e.g. '$A' or '$1' or '$A$1'
* @throws Exception
* @param string $pCoordinateString e.g. 'A' or '1' or 'A1'
* Note that this value can be a row or column reference as well as a cell reference
* @return string Absolute coordinate e.g. '$A' or '$1' or '$A$1'
* @throws PHPExcel_Exception
*/
public static function absoluteReference($pCoordinateString = 'A1')
{
if (strpos($pCoordinateString,':') === false && strpos($pCoordinateString,',') === false) {
if (strpos($pCoordinateString,':') === FALSE && strpos($pCoordinateString,',') === FALSE) {
// Split out any worksheet name from the reference
$worksheet = '';
$cellAddress = explode('!',$pCoordinateString);
if (count($cellAddress) > 1) {
list($worksheet,$pCoordinateString) = $cellAddress;
}
if ($worksheet > '') $worksheet .= '!';
// Create absolute coordinate
if (ctype_digit($pCoordinateString)) {
return '$'.$pCoordinateString;
return $worksheet . '$' . $pCoordinateString;
} elseif (ctype_alpha($pCoordinateString)) {
return '$'.strtoupper($pCoordinateString);
return $worksheet . '$' . strtoupper($pCoordinateString);
}
return self::absoluteCoordinate($pCoordinateString);
} else {
throw new Exception("Coordinate string should not be a cell range.");
return $worksheet . self::absoluteCoordinate($pCoordinateString);
}
throw new PHPExcel_Exception('Cell coordinate string can not be a range of cells');
}
/**
* Make string coordinate absolute
* Make string coordinate absolute
*
* @param string $pCoordinateString e.g. 'A1'
* @return string Absolute coordinate e.g. '$A$1'
* @throws Exception
* @param string $pCoordinateString e.g. 'A1'
* @return string Absolute coordinate e.g. '$A$1'
* @throws PHPExcel_Exception
*/
public static function absoluteCoordinate($pCoordinateString = 'A1')
{
if (strpos($pCoordinateString,':') === false && strpos($pCoordinateString,',') === false) {
// Create absolute coordinate
if (strpos($pCoordinateString,':') === FALSE && strpos($pCoordinateString,',') === FALSE) {
// Split out any worksheet name from the coordinate
$worksheet = '';
$cellAddress = explode('!',$pCoordinateString);
if (count($cellAddress) == 2) {
if (count($cellAddress) > 1) {
list($worksheet,$pCoordinateString) = $cellAddress;
}
if ($worksheet > '') $worksheet .= '!';
list($column, $row) = PHPExcel_Cell::coordinateFromString($pCoordinateString);
if ($column[0] == '$') $column = substr($column,1);
if ($row[0] == '$') $row = substr($row,1);
if ($worksheet > '')
$worksheet .= '!';
// Create absolute coordinate
list($column, $row) = self::coordinateFromString($pCoordinateString);
$column = ltrim($column,'$');
$row = ltrim($row,'$');
return $worksheet . '$' . $column . '$' . $row;
} else {
throw new Exception("Coordinate string should not be a cell range.");
}
throw new PHPExcel_Exception('Cell coordinate string can not be a range of cells');
}
/**
* Split range into coordinate strings
* Split range into coordinate strings
*
* @param string $pRange
* @return array Array containg one or more arrays containing one or two coordinate strings
* @param string $pRange e.g. 'B4:D9' or 'B4:D9,H2:O11' or 'B4'
* @return array Array containg one or more arrays containing one or two coordinate strings
* e.g. array('B4','D9') or array(array('B4','D9'),array('H2','O11'))
* or array('B4')
*/
public static function splitRange($pRange = 'A1:A1')
{
@ -585,17 +609,17 @@ class PHPExcel_Cell
}
/**
* Build range from coordinate strings
* Build range from coordinate strings
*
* @param array $pRange Array containg one or more arrays containing one or two coordinate strings
* @return string String representation of $pRange
* @throws Exception
* @param array $pRange Array containg one or more arrays containing one or two coordinate strings
* @return string String representation of $pRange
* @throws PHPExcel_Exception
*/
public static function buildRange($pRange)
{
// Verify range
if (!is_array($pRange) || empty($pRange) || !is_array($pRange[0])) {
throw new Exception('Range does not contain any information.');
throw new PHPExcel_Exception('Range does not contain any information');
}
// Build range
@ -610,10 +634,11 @@ class PHPExcel_Cell
}
/**
* Calculate range boundaries
* Calculate range boundaries
*
* @param string $pRange Cell range (e.g. A1:A1)
* @return array Range coordinates (Start Cell, End Cell) where Start Cell and End Cell are arrays (Column Number, Row Number)
* @param string $pRange Cell range (e.g. A1:A1)
* @return array Range coordinates array(Start Cell, End Cell)
* where Start Cell and End Cell are arrays (Column Number, Row Number)
*/
public static function rangeBoundaries($pRange = 'A1:A1')
{
@ -621,42 +646,43 @@ class PHPExcel_Cell
$pRange = strtoupper($pRange);
// Extract range
if (strpos($pRange, ':') === false) {
if (strpos($pRange, ':') === FALSE) {
$rangeA = $rangeB = $pRange;
} else {
list($rangeA, $rangeB) = explode(':', $pRange);
}
// Calculate range outer borders
$rangeStart = PHPExcel_Cell::coordinateFromString($rangeA);
$rangeEnd = PHPExcel_Cell::coordinateFromString($rangeB);
$rangeStart = self::coordinateFromString($rangeA);
$rangeEnd = self::coordinateFromString($rangeB);
// Translate column into index
$rangeStart[0] = PHPExcel_Cell::columnIndexFromString($rangeStart[0]);
$rangeEnd[0] = PHPExcel_Cell::columnIndexFromString($rangeEnd[0]);
$rangeStart[0] = self::columnIndexFromString($rangeStart[0]);
$rangeEnd[0] = self::columnIndexFromString($rangeEnd[0]);
return array($rangeStart, $rangeEnd);
}
/**
* Calculate range dimension
* Calculate range dimension
*
* @param string $pRange Cell range (e.g. A1:A1)
* @return array Range dimension (width, height)
* @param string $pRange Cell range (e.g. A1:A1)
* @return array Range dimension (width, height)
*/
public static function rangeDimension($pRange = 'A1:A1')
{
// Calculate range outer borders
list($rangeStart,$rangeEnd) = PHPExcel_Cell::rangeBoundaries($pRange);
list($rangeStart,$rangeEnd) = self::rangeBoundaries($pRange);
return array( ($rangeEnd[0] - $rangeStart[0] + 1), ($rangeEnd[1] - $rangeStart[1] + 1) );
}
/**
* Calculate range boundaries
* Calculate range boundaries
*
* @param string $pRange Cell range (e.g. A1:A1)
* @return array Range boundaries (staring Column, starting Row, Final Column, Final Row)
* @param string $pRange Cell range (e.g. A1:A1)
* @return array Range coordinates array(Start Cell, End Cell)
* where Start Cell and End Cell are arrays (Column ID, Row Number)
*/
public static function getRangeBoundaries($pRange = 'A1:A1')
{
@ -664,7 +690,7 @@ class PHPExcel_Cell
$pRange = strtoupper($pRange);
// Extract range
if (strpos($pRange, ':') === false) {
if (strpos($pRange, ':') === FALSE) {
$rangeA = $rangeB = $pRange;
} else {
list($rangeA, $rangeB) = explode(':', $pRange);
@ -674,11 +700,11 @@ class PHPExcel_Cell
}
/**
* Column index from string
* Column index from string
*
* @param string $pString
* @return int Column index (base 1 !!!)
* @throws Exception
* @param string $pString
* @return int Column index (base 1 !!!)
* @throws Exception
*/
public static function columnIndexFromString($pString = 'A')
{
@ -714,14 +740,14 @@ class PHPExcel_Cell
return $_indexCache[$pString];
}
}
throw new Exception("Column string index can not be " . ((isset($pString{0})) ? "longer than 3 characters" : "empty") . ".");
throw new PHPExcel_Exception("Column string index can not be " . ((isset($pString{0})) ? "longer than 3 characters" : "empty"));
}
/**
* String from columnindex
* String from columnindex
*
* @param int $pColumnIndex Column index (base 0 !!!)
* @return string
* @param int $pColumnIndex Column index (base 0 !!!)
* @return string
*/
public static function stringFromColumnIndex($pColumnIndex = 0)
{
@ -747,10 +773,10 @@ class PHPExcel_Cell
}
/**
* Extract all cell references in range
* Extract all cell references in range
*
* @param string $pRange Range (e.g. A1 or A1:A10 or A1:A10 A100:A1000)
* @return array Array containing single cell references
* @param string $pRange Range (e.g. A1 or A1:C10 or A1:E10 A20:E25)
* @return array Array containing single cell references
*/
public static function extractAllCellReferencesInRange($pRange = 'A1') {
// Returnvalue
@ -760,13 +786,13 @@ class PHPExcel_Cell
$cellBlocks = explode(' ', str_replace('$', '', strtoupper($pRange)));
foreach ($cellBlocks as $cellBlock) {
// Single cell?
if (strpos($cellBlock,':') === false && strpos($cellBlock,',') === false) {
if (strpos($cellBlock,':') === FALSE && strpos($cellBlock,',') === FALSE) {
$returnValue[] = $cellBlock;
continue;
}
// Range...
$ranges = PHPExcel_Cell::splitRange($cellBlock);
$ranges = self::splitRange($cellBlock);
foreach($ranges as $range) {
// Single cell?
if (!isset($range[1])) {
@ -796,8 +822,16 @@ class PHPExcel_Cell
}
}
// Sort the result by column and row
$sortKeys = array();
foreach (array_unique($returnValue) as $coord) {
list($column,$row) = sscanf($coord,'%[A-Z]%d');
$sortKeys[sprintf('%3s%09d',$column,$row)] = $coord;
}
ksort($sortKeys);
// Return value
return $returnValue;
return array_values($sortKeys);
}
/**
@ -813,7 +847,7 @@ class PHPExcel_Cell
return -1;
} elseif ($a->_row > $b->_row) {
return 1;
} elseif (PHPExcel_Cell::columnIndexFromString($a->_column) < PHPExcel_Cell::columnIndexFromString($b->_column)) {
} elseif (self::columnIndexFromString($a->_column) < self::columnIndexFromString($b->_column)) {
return -1;
} else {
return 1;
@ -839,7 +873,7 @@ class PHPExcel_Cell
* @param PHPExcel_Cell_IValueBinder $binder
* @throws Exception
*/
public static function setValueBinder(PHPExcel_Cell_IValueBinder $binder = null) {
public static function setValueBinder(PHPExcel_Cell_IValueBinder $binder = NULL) {
if ($binder === NULL) {
throw new Exception("A PHPExcel_Cell_IValueBinder is required for PHPExcel to function correctly.");
}
@ -901,5 +935,15 @@ class PHPExcel_Cell
return $this->_formulaAttributes;
}
/**
* Convert to string
*
* @return string
*/
public function __toString()
{
return (string) $this->getValue();
}
}

View File

@ -88,6 +88,26 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
return true;
}
// Check for currency
$currencyCode = PHPExcel_Shared_String::getCurrencyCode();
if (preg_match('/^'.preg_quote($currencyCode).' ?(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$/', $value)) {
// Convert value to number
$cell->setValueExplicit( trim(str_replace($currencyCode, '', $value)), PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Set style
$cell->getParent()->getStyle( $cell->getCoordinate() )
->getNumberFormat()->setFormatCode(
str_replace('$', $currencyCode, PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE )
);
return true;
} elseif (preg_match('/^\$ ?(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$/', $value)) {
// Convert value to number
$cell->setValueExplicit( trim(str_replace('$', '', $value)), PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Set style
$cell->getParent()->getStyle( $cell->getCoordinate() )
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE );
return true;
}
// Check for time without seconds e.g. '9:45', '09:45'
if (preg_match('/^(\d|[0-1]\d|2[0-3]):[0-5]\d$/', $value)) {
list($h, $m) = explode(':', $value);

View File

@ -146,6 +146,7 @@ class PHPExcel_Chart_DataSeries
if ((count($plotLabel) == 0) || (is_null($plotLabel[$keys[0]]))) {
$plotLabel[$keys[0]] = new PHPExcel_Chart_DataSeriesValues();
}
$this->_plotLabel = $plotLabel;
if ((count($plotCategory) == 0) || (is_null($plotCategory[$keys[0]]))) {
$plotCategory[$keys[0]] = new PHPExcel_Chart_DataSeriesValues();
@ -337,7 +338,16 @@ class PHPExcel_Chart_DataSeries
public function refresh(PHPExcel_Worksheet $worksheet) {
foreach($this->_plotValues as $plotValues) {
$plotValues->refresh($worksheet);
if ($plotValues !== NULL)
$plotValues->refresh($worksheet);
}
foreach($this->_plotLabel as $plotValues) {
if ($plotValues !== NULL)
$plotValues->refresh($worksheet);
}
foreach($this->_plotCategory as $plotValues) {
if ($plotValues !== NULL)
$plotValues->refresh($worksheet);
}
}

View File

@ -273,14 +273,22 @@ class PHPExcel_Chart_DataSeriesValues
return $this;
}
private function _stripNulls($var) {
return $var !== NULL;
}
public function refresh(PHPExcel_Worksheet $worksheet) {
if ($this->_dataSource !== NULL) {
$calcEngine = PHPExcel_Calculation::getInstance();
$this->_dataValues = PHPExcel_Calculation::_unwrapResult(
$newDataValues = PHPExcel_Calculation::_unwrapResult(
$calcEngine->_calculateFormulaValue(
$this->_dataSource
'='.$this->_dataSource,
NULL,
$worksheet->getCell('A1')
)
);
$this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues);
}
}

View File

@ -0,0 +1,52 @@
<?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##
*/
/**
* PHPExcel_Exception
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Exception extends Exception {
/**
* Error handler callback
*
* @param mixed $code
* @param mixed $string
* @param mixed $file
* @param mixed $line
* @param mixed $context
*/
public static function errorHandlerCallback($code, $string, $file, $line, $context) {
$e = new self($string, $code);
$e->line = $line;
$e->file = $file;
throw $e;
}
}

View File

@ -51,7 +51,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
*
* @var boolean
*/
private $_readDataOnly = false;
private $_readDataOnly = FALSE;
/**
* Read charts that are defined in the workbook?
@ -59,7 +59,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
*
* @var boolean
*/
private $_includeCharts = false;
private $_includeCharts = FALSE;
/**
* Restrict which sheets should be loaded?
@ -67,28 +67,28 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
*
* @var array of string
*/
private $_loadSheetsOnly = null;
private $_loadSheetsOnly = NULL;
/**
* PHPExcel_Reader_IReadFilter instance
*
* @var PHPExcel_Reader_IReadFilter
*/
private $_readFilter = null;
private $_readFilter = NULL;
/**
* PHPExcel_ReferenceHelper instance
*
* @var PHPExcel_ReferenceHelper
*/
private $_referenceHelper = null;
private $_referenceHelper = NULL;
/**
* PHPExcel_Reader_Excel2007_Theme instance
*
* @var PHPExcel_Reader_Excel2007_Theme
*/
private static $_theme = null;
private static $_theme = NULL;
/**
@ -121,7 +121,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
*
* @return PHPExcel_Reader_Excel2007
*/
public function setReadDataOnly($pValue = false) {
public function setReadDataOnly($pValue = FALSE) {
$this->_readDataOnly = $pValue;
return $this;
}
@ -150,7 +150,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
*
* @return PHPExcel_Reader_Excel2007
*/
public function setIncludeCharts($pValue = false) {
public function setIncludeCharts($pValue = FALSE) {
$this->_includeCharts = (boolean) $pValue;
return $this;
}
@ -178,7 +178,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
*
* @return PHPExcel_Reader_Excel2007
*/
public function setLoadSheetsOnly($value = null)
public function setLoadSheetsOnly($value = NULL)
{
$this->_loadSheetsOnly = is_array($value) ?
$value : array($value);
@ -194,7 +194,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
*/
public function setLoadAllSheets()
{
$this->_loadSheetsOnly = null;
$this->_loadSheetsOnly = NULL;
return $this;
}
@ -342,11 +342,11 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
private static function _castToBool($c) {
// echo 'Initial Cast to Boolean<br />';
$value = isset($c->v) ? (string) $c->v : null;
$value = isset($c->v) ? (string) $c->v : NULL;
if ($value == '0') {
return false;
return FALSE;
} elseif ($value == '1') {
return true;
return TRUE;
} else {
return (bool)$c->v;
}
@ -356,18 +356,18 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
private static function _castToError($c) {
// echo 'Initial Cast to Error<br />';
return isset($c->v) ? (string) $c->v : null;;
return isset($c->v) ? (string) $c->v : NULL;
} // function _castToError()
private static function _castToString($c) {
// echo 'Initial Cast to String<br />';
return isset($c->v) ? (string) $c->v : null;;
return isset($c->v) ? (string) $c->v : NULL;
} // function _castToString()
private function _castToFormula($c,$r,&$cellDataType,&$value,&$calculatedValue,&$sharedFormulas,$castBaseType) {
// echo '<font color="darkgreen">Formula</font><br />';
// echo 'Formula<br />';
// echo '$c->f is '.$c->f.'<br />';
$cellDataType = 'f';
$value = "={$c->f}";
@ -375,7 +375,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
// Shared formula?
if (isset($c->f['t']) && strtolower((string)$c->f['t']) == 'shared') {
// echo '<font color="darkgreen">SHARED FORMULA</font><br />';
// echo 'SHARED FORMULA<br />';
$instance = (string)$c->f['si'];
// echo 'Instance ID = '.$instance.'<br />';
@ -384,7 +384,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
// print_r($sharedFormulas);
// echo '</pre>';
if (!isset($sharedFormulas[(string)$c->f['si']])) {
// echo '<font color="darkgreen">SETTING NEW SHARED FORMULA</font><br />';
// echo 'SETTING NEW SHARED FORMULA<br />';
// echo 'Master is '.$r.'<br />';
// echo 'Formula is '.$value.'<br />';
$sharedFormulas[$instance] = array( 'master' => $r,
@ -394,7 +394,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
// print_r($sharedFormulas);
// echo '</pre>';
} else {
// echo '<font color="darkgreen">GETTING SHARED FORMULA</font><br />';
// echo 'GETTING SHARED FORMULA<br />';
// echo 'Master is '.$sharedFormulas[$instance]['master'].'<br />';
// echo 'Formula is '.$sharedFormulas[$instance]['formula'].'<br />';
$master = PHPExcel_Cell::coordinateFromString($sharedFormulas[$instance]['master']);
@ -1408,7 +1408,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
}
// TODO: Make sure drawings and graph are loaded differently!
// TODO: Autoshapes from twoCellAnchors!
if ($zip->locateName(dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")) {
$relsWorksheet = simplexml_load_string($this->_getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels") ); //~ http://schemas.openxmlformats.org/package/2006/relationships");
$drawings = array();
@ -1469,6 +1469,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
}
$objDrawing->setWorksheet($docSheet);
} else {
// ? Can charts be positioned with a oneCellAnchor ?
$coordinates = PHPExcel_Cell::stringFromColumnIndex((string) $oneCellAnchor->from->col) . ($oneCellAnchor->from->row + 1);
$offsetX = PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->colOff);
$offsetY = PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->rowOff);
@ -1509,7 +1510,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$shadow->setAlpha(self::array_item($outerShdw->srgbClr->alpha->attributes(), "val") / 1000);
}
$objDrawing->setWorksheet($docSheet);
} elseif($this->_includeCharts) {
} elseif(($this->_includeCharts) && ($twoCellAnchor->graphicFrame)) {
$fromCoordinate = PHPExcel_Cell::stringFromColumnIndex((string) $twoCellAnchor->from->col) . ($twoCellAnchor->from->row + 1);
$fromOffsetX = PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->colOff);
$fromOffsetY = PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->rowOff);
@ -1733,7 +1734,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
}
private static function _readColor($color, $background=false) {
private static function _readColor($color, $background=FALSE) {
if (isset($color["rgb"])) {
return (string)$color["rgb"];
} else if (isset($color["indexed"])) {

View File

@ -64,7 +64,8 @@ class PHPExcel_Reader_Excel2007_Chart
$namespacesChartMeta = $chartElements->getNamespaces(true);
$chartElementsC = $chartElements->children($namespacesChartMeta['c']);
$XaxisLabel = $YaxisLabel = $legend = $title = null;
$XaxisLabel = $YaxisLabel = $legend = $title = NULL;
$dispBlanksAs = $plotVisOnly = NULL;
foreach($chartElementsC as $chartElementKey => $chartElement) {
switch ($chartElementKey) {
@ -304,6 +305,13 @@ class PHPExcel_Reader_Excel2007_Chart
$seriesData['pointCount'] = count($seriesData['dataValues']);
return new PHPExcel_Chart_DataSeriesValues('String',$seriesSource,$seriesData['formatCode'],$seriesData['pointCount'],$seriesData['dataValues'],$marker,$smoothLine);
} elseif (isset($seriesDetail->v)) {
$seriesData = array( 'formatCode' => '@',
'pointCount' => 1,
'dataValues' => array((string) $seriesDetail->v)
);
return new PHPExcel_Chart_DataSeriesValues('String',NULL,'@',1,$seriesData['dataValues'],$marker,$smoothLine);
}
return null;
} // function _chartDataSeriesValueSet()

View File

@ -944,101 +944,92 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
// echo '<br />';
// the first shape container never has a corresponding OBJ record, hence $n + 1
$spContainer = $allSpContainers[$n + 1];
if (isset($allSpContainers[$n + 1]) && is_object($allSpContainers[$n + 1])) {
$spContainer = $allSpContainers[$n + 1];
// we skip all spContainers that are a part of a group shape since we cannot yet handle those
if ($spContainer->getNestingLevel() > 1) {
continue;
}
// calculate the width and height of the shape
list($startColumn, $startRow) = PHPExcel_Cell::coordinateFromString($spContainer->getStartCoordinates());
list($endColumn, $endRow) = PHPExcel_Cell::coordinateFromString($spContainer->getEndCoordinates());
$startOffsetX = $spContainer->getStartOffsetX();
$startOffsetY = $spContainer->getStartOffsetY();
$endOffsetX = $spContainer->getEndOffsetX();
$endOffsetY = $spContainer->getEndOffsetY();
$width = PHPExcel_Shared_Excel5::getDistanceX($this->_phpSheet, $startColumn, $startOffsetX, $endColumn, $endOffsetX);
$height = PHPExcel_Shared_Excel5::getDistanceY($this->_phpSheet, $startRow, $startOffsetY, $endRow, $endOffsetY);
// calculate offsetX and offsetY of the shape
$offsetX = $startOffsetX * PHPExcel_Shared_Excel5::sizeCol($this->_phpSheet, $startColumn) / 1024;
$offsetY = $startOffsetY * PHPExcel_Shared_Excel5::sizeRow($this->_phpSheet, $startRow) / 256;
switch ($obj['otObjType']) {
case 0x19:
// Note
// echo 'Cell Annotation Object<br />';
// echo 'Object ID is ',$obj['idObjID'],'<br />';
//
if (isset($this->_cellNotes[$obj['idObjID']])) {
$cellNote = $this->_cellNotes[$obj['idObjID']];
// echo '_cellNotes[',$obj['idObjID'],']: ';
// var_dump($cellNote);
// echo '<br />';
//
if (isset($this->_textObjects[$obj['idObjID']])) {
$textObject = $this->_textObjects[$obj['idObjID']];
// echo '_textObject: ';
// var_dump($textObject);
// echo '<br />';
//
$this->_cellNotes[$obj['idObjID']]['objTextData'] = $textObject;
$text = $textObject['text'];
}
// echo $text,'<br />';
}
break;
case 0x08:
// echo 'Picture Object<br />';
// picture
// get index to BSE entry (1-based)
$BSEindex = $spContainer->getOPT(0x0104);
$BSECollection = $escherWorkbook->getDggContainer()->getBstoreContainer()->getBSECollection();
$BSE = $BSECollection[$BSEindex - 1];
$blipType = $BSE->getBlipType();
// need check because some blip types are not supported by Escher reader such as EMF
if ($blip = $BSE->getBlip()) {
$ih = imagecreatefromstring($blip->getData());
$drawing = new PHPExcel_Worksheet_MemoryDrawing();
$drawing->setImageResource($ih);
// width, height, offsetX, offsetY
$drawing->setResizeProportional(false);
$drawing->setWidth($width);
$drawing->setHeight($height);
$drawing->setOffsetX($offsetX);
$drawing->setOffsetY($offsetY);
switch ($blipType) {
case PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_JPEG:
$drawing->setRenderingFunction(PHPExcel_Worksheet_MemoryDrawing::RENDERING_JPEG);
$drawing->setMimeType(PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_JPEG);
break;
case PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG:
$drawing->setRenderingFunction(PHPExcel_Worksheet_MemoryDrawing::RENDERING_PNG);
$drawing->setMimeType(PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_PNG);
break;
}
$drawing->setWorksheet($this->_phpSheet);
$drawing->setCoordinates($spContainer->getStartCoordinates());
// we skip all spContainers that are a part of a group shape since we cannot yet handle those
if ($spContainer->getNestingLevel() > 1) {
continue;
}
break;
// calculate the width and height of the shape
list($startColumn, $startRow) = PHPExcel_Cell::coordinateFromString($spContainer->getStartCoordinates());
list($endColumn, $endRow) = PHPExcel_Cell::coordinateFromString($spContainer->getEndCoordinates());
default:
// other object type
break;
$startOffsetX = $spContainer->getStartOffsetX();
$startOffsetY = $spContainer->getStartOffsetY();
$endOffsetX = $spContainer->getEndOffsetX();
$endOffsetY = $spContainer->getEndOffsetY();
$width = PHPExcel_Shared_Excel5::getDistanceX($this->_phpSheet, $startColumn, $startOffsetX, $endColumn, $endOffsetX);
$height = PHPExcel_Shared_Excel5::getDistanceY($this->_phpSheet, $startRow, $startOffsetY, $endRow, $endOffsetY);
// calculate offsetX and offsetY of the shape
$offsetX = $startOffsetX * PHPExcel_Shared_Excel5::sizeCol($this->_phpSheet, $startColumn) / 1024;
$offsetY = $startOffsetY * PHPExcel_Shared_Excel5::sizeRow($this->_phpSheet, $startRow) / 256;
switch ($obj['otObjType']) {
case 0x19:
// Note
// echo 'Cell Annotation Object<br />';
// echo 'Object ID is ',$obj['idObjID'],'<br />';
//
if (isset($this->_cellNotes[$obj['idObjID']])) {
$cellNote = $this->_cellNotes[$obj['idObjID']];
if (isset($this->_textObjects[$obj['idObjID']])) {
$textObject = $this->_textObjects[$obj['idObjID']];
$this->_cellNotes[$obj['idObjID']]['objTextData'] = $textObject;
}
}
break;
case 0x08:
// echo 'Picture Object<br />';
// picture
// get index to BSE entry (1-based)
$BSEindex = $spContainer->getOPT(0x0104);
$BSECollection = $escherWorkbook->getDggContainer()->getBstoreContainer()->getBSECollection();
$BSE = $BSECollection[$BSEindex - 1];
$blipType = $BSE->getBlipType();
// need check because some blip types are not supported by Escher reader such as EMF
if ($blip = $BSE->getBlip()) {
$ih = imagecreatefromstring($blip->getData());
$drawing = new PHPExcel_Worksheet_MemoryDrawing();
$drawing->setImageResource($ih);
// width, height, offsetX, offsetY
$drawing->setResizeProportional(false);
$drawing->setWidth($width);
$drawing->setHeight($height);
$drawing->setOffsetX($offsetX);
$drawing->setOffsetY($offsetY);
switch ($blipType) {
case PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_JPEG:
$drawing->setRenderingFunction(PHPExcel_Worksheet_MemoryDrawing::RENDERING_JPEG);
$drawing->setMimeType(PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_JPEG);
break;
case PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG:
$drawing->setRenderingFunction(PHPExcel_Worksheet_MemoryDrawing::RENDERING_PNG);
$drawing->setMimeType(PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_PNG);
break;
}
$drawing->setWorksheet($this->_phpSheet);
$drawing->setCoordinates($spContainer->getStartCoordinates());
}
break;
default:
// other object type
break;
}
}
}
@ -1055,6 +1046,14 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
if (!empty($this->_cellNotes)) {
foreach($this->_cellNotes as $note => $noteDetails) {
if (!isset($noteDetails['objTextData'])) {
if (isset($this->_textObjects[$note])) {
$textObject = $this->_textObjects[$note];
$noteDetails['objTextData'] = $textObject;
} else {
$noteDetails['objTextData']['text'] = '';
}
}
// echo '<b>Cell annotation ',$note,'</b><br />';
// var_dump($noteDetails);
// echo '<br />';

View File

@ -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_Reader
* @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##
*/
@ -40,7 +40,7 @@ if (!defined('PHPEXCEL_ROOT')) {
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_HTML implements PHPExcel_Reader_IReader
{

View File

@ -319,14 +319,23 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
foreach ($worksheetData as $key => $rowData) {
switch ($key) {
case 'table-row' :
$rowDataTableAttributes = $rowData->attributes($namespacesContent['table']);
$rowRepeats = (isset($rowDataTableAttributes['number-rows-repeated'])) ?
$rowDataTableAttributes['number-rows-repeated'] : 1;
$columnIndex = 0;
foreach ($rowData as $key => $cellData) {
$tmpInfo['lastColumnIndex'] = max($tmpInfo['lastColumnIndex'], $columnIndex);
++$columnIndex;
$cellDataTableAttributes = $cellData->attributes($namespacesContent['table']);
$colRepeats = (isset($cellDataTableAttributes['number-columns-repeated'])) ?
$cellDataTableAttributes['number-columns-repeated'] : 1;
$cellDataOfficeAttributes = $cellData->attributes($namespacesContent['office']);
if (isset($cellDataOfficeAttributes['value-type'])) {
$tmpInfo['lastColumnIndex'] = max($tmpInfo['lastColumnIndex'], $columnIndex + $colRepeats - 1);
$tmpInfo['totalRows'] = max($tmpInfo['totalRows'], $rowIndex + $rowRepeats);
}
$columnIndex += $colRepeats;
}
++$rowIndex;
$tmpInfo['totalRows'] = max($tmpInfo['totalRows'], $rowIndex);
$rowIndex += $rowRepeats;
break;
}
}
@ -492,6 +501,9 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
break;
}
case 'table-row' :
$rowDataTableAttributes = $rowData->attributes($namespacesContent['table']);
$rowRepeats = (isset($rowDataTableAttributes['number-rows-repeated'])) ?
$rowDataTableAttributes['number-rows-repeated'] : 1;
$columnID = 'A';
foreach($rowData as $key => $cellData) {
if ($this->getReadFilter() !== NULL) {
@ -574,6 +586,22 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
$type = PHPExcel_Cell_DataType::TYPE_BOOL;
$dataValue = ($allCellDataText == 'TRUE') ? True : False;
break;
case 'percentage' :
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
$dataValue = (float) $cellDataOfficeAttributes['value'];
if (floor($dataValue) == $dataValue) {
$dataValue = (integer) $dataValue;
}
$formatting = PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00;
break;
case 'currency' :
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
$dataValue = (float) $cellDataOfficeAttributes['value'];
if (floor($dataValue) == $dataValue) {
$dataValue = (integer) $dataValue;
}
$formatting = PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE;
break;
case 'float' :
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
$dataValue = (float) $cellDataOfficeAttributes['value'];
@ -628,45 +656,53 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
// echo 'Adjusted Formula: '.$cellDataFormula.'<br />';
}
$repeats = (isset($cellDataTableAttributes['number-columns-repeated'])) ?
$colRepeats = (isset($cellDataTableAttributes['number-columns-repeated'])) ?
$cellDataTableAttributes['number-columns-repeated'] : 1;
if ($type !== NULL) {
for ($i = 0; $i < $repeats; ++$i) {
for ($i = 0; $i < $colRepeats; ++$i) {
if ($i > 0) {
++$columnID;
}
$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $dataValue),$type);
if ($hasCalculatedValue) {
// echo 'Forumla result is '.$dataValue.'<br />';
$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setCalculatedValue($dataValue);
}
if (($cellDataOfficeAttributes['value-type'] == 'date') ||
($cellDataOfficeAttributes['value-type'] == 'time')) {
$objPHPExcel->getActiveSheet()->getStyle($columnID.$rowID)->getNumberFormat()->setFormatCode($formatting);
}
if ($hyperlink !== NULL) {
$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->getHyperlink()->setUrl($hyperlink);
if ($type !== PHPExcel_Cell_DataType::TYPE_NULL) {
for ($rowAdjust = 0; $rowAdjust < $rowRepeats; ++$rowAdjust) {
$rID = $rowID + $rowAdjust;
$objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $dataValue),$type);
if ($hasCalculatedValue) {
// echo 'Forumla result is '.$dataValue.'<br />';
$objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->setCalculatedValue($dataValue);
}
if ($formatting !== NULL) {
$objPHPExcel->getActiveSheet()->getStyle($columnID.$rID)->getNumberFormat()->setFormatCode($formatting);
} else {
$objPHPExcel->getActiveSheet()->getStyle($columnID.$rID)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_GENERAL);
}
if ($hyperlink !== NULL) {
$objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->getHyperlink()->setUrl($hyperlink);
}
}
}
}
}
// Merged cells
if ((isset($cellDataTableAttributes['number-columns-spanned'])) || (isset($cellDataTableAttributes['number-rows-spanned']))) {
$columnTo = $columnID;
if (isset($cellDataTableAttributes['number-columns-spanned'])) {
$columnTo = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($columnID) + $cellDataTableAttributes['number-columns-spanned'] -2);
if (($type !== PHPExcel_Cell_DataType::TYPE_NULL) || (!$this->_readDataOnly)) {
$columnTo = $columnID;
if (isset($cellDataTableAttributes['number-columns-spanned'])) {
$columnTo = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($columnID) + $cellDataTableAttributes['number-columns-spanned'] -2);
}
$rowTo = $rowID;
if (isset($cellDataTableAttributes['number-rows-spanned'])) {
$rowTo = $rowTo + $cellDataTableAttributes['number-rows-spanned'] - 1;
}
$cellRange = $columnID.$rowID.':'.$columnTo.$rowTo;
$objPHPExcel->getActiveSheet()->mergeCells($cellRange);
}
$rowTo = $rowID;
if (isset($cellDataTableAttributes['number-rows-spanned'])) {
$rowTo = $rowTo + $cellDataTableAttributes['number-rows-spanned'] - 1;
}
$cellRange = $columnID.$rowID.':'.$columnTo.$rowTo;
$objPHPExcel->getActiveSheet()->mergeCells($cellRange);
}
++$columnID;
}
++$rowID;
$rowID += $rowRepeats;
break;
}
}

View File

@ -88,9 +88,9 @@ class PHPExcel_Shared_Date
if (($baseDate == self::CALENDAR_WINDOWS_1900) ||
($baseDate == self::CALENDAR_MAC_1904)) {
self::$ExcelBaseDate = $baseDate;
return True;
return TRUE;
}
return False;
return FALSE;
} // function setExcelCalendar()
@ -166,12 +166,12 @@ class PHPExcel_Shared_Date
*
* @param mixed $dateValue PHP serialized date/time or date object
* @return mixed Excel date/time value
* or boolean False on failure
* or boolean FALSE on failure
*/
public static function PHPToExcel($dateValue = 0) {
$saveTimeZone = date_default_timezone_get();
date_default_timezone_set('UTC');
$retValue = False;
$retValue = FALSE;
if ((is_object($dateValue)) && ($dateValue instanceof self::$dateTimeObjectType)) {
$retValue = self::FormattedPHPToExcel( $dateValue->format('Y'), $dateValue->format('m'), $dateValue->format('d'),
$dateValue->format('H'), $dateValue->format('i'), $dateValue->format('s')
@ -204,12 +204,12 @@ class PHPExcel_Shared_Date
// Fudge factor for the erroneous fact that the year 1900 is treated as a Leap Year in MS Excel
// This affects every date following 28th February 1900
//
$excel1900isLeapYear = True;
if (($year == 1900) && ($month <= 2)) { $excel1900isLeapYear = False; }
$excel1900isLeapYear = TRUE;
if (($year == 1900) && ($month <= 2)) { $excel1900isLeapYear = FALSE; }
$myExcelBaseDate = 2415020;
} else {
$myExcelBaseDate = 2416481;
$excel1900isLeapYear = False;
$excel1900isLeapYear = FALSE;
}
// Julian base date Adjustment
@ -238,7 +238,11 @@ class PHPExcel_Shared_Date
* @return boolean
*/
public static function isDateTime(PHPExcel_Cell $pCell) {
return self::isDateTimeFormat($pCell->getParent()->getStyle($pCell->getCoordinate())->getNumberFormat());
return self::isDateTimeFormat(
$pCell->getParent()->getStyle(
$pCell->getCoordinate()
)->getNumberFormat()
);
} // function isDateTime()
@ -264,6 +268,10 @@ class PHPExcel_Shared_Date
public static function isDateTimeFormatCode($pFormatCode = '') {
// Switch on formatcode
switch ($pFormatCode) {
// General contains an epoch letter 'e', so we trap for it explicitly here
case PHPExcel_Style_NumberFormat::FORMAT_GENERAL:
return FALSE;
// Explicitly defined date formats
case PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD2:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DDMMYYYY:
@ -286,32 +294,32 @@ class PHPExcel_Shared_Date
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX16:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX17:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX22:
return true;
return TRUE;
}
// Typically number, currency or accounting (or occasionally fraction) formats
if ((substr($pFormatCode,0,1) == '_') || (substr($pFormatCode,0,2) == '0 ')) {
return false;
return FALSE;
}
// Try checking for any of the date formatting characters that don't appear within square braces
if (preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i',$pFormatCode)) {
// We might also have a format mask containing quoted strings...
// we don't want to test for any of our characters within the quoted blocks
if (strpos($pFormatCode,'"') !== false) {
$i = false;
if (strpos($pFormatCode,'"') !== FALSE) {
$i = FALSE;
foreach(explode('"',$pFormatCode) as $subVal) {
// Only test in alternate array entries (the non-quoted blocks)
if (($i = !$i) && (preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i',$subVal))) {
return true;
return TRUE;
}
}
return false;
return FALSE;
}
return true;
return TRUE;
}
// No date...
return false;
return FALSE;
} // function isDateTimeFormatCode()
@ -319,23 +327,23 @@ class PHPExcel_Shared_Date
* Convert a date/time string to Excel time
*
* @param string $dateValue Examples: '2009-12-31', '2009-12-31 15:59', '2009-12-31 15:59:10'
* @return float|false Excel date/time serial value
* @return float|FALSE Excel date/time serial value
*/
public static function stringToExcel($dateValue = '') {
if (strlen($dateValue) < 2)
return false;
return FALSE;
if (!preg_match('/^(\d{1,4}[ \.\/\-][A-Z]{3,9}([ \.\/\-]\d{1,4})?|[A-Z]{3,9}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?|\d{1,4}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?)( \d{1,2}:\d{1,2}(:\d{1,2})?)?$/iu', $dateValue))
return false;
return FALSE;
$dateValueNew = PHPExcel_Calculation_DateTime::DATEVALUE($dateValue);
if ($dateValueNew === PHPExcel_Calculation_Functions::VALUE()) {
return false;
return FALSE;
} else {
if (strpos($dateValue, ':') !== false) {
if (strpos($dateValue, ':') !== FALSE) {
$timeValue = PHPExcel_Calculation_DateTime::TIMEVALUE($dateValue);
if ($timeValue === PHPExcel_Calculation_Functions::VALUE()) {
return false;
return FALSE;
}
$dateValueNew += $timeValue;
}

View File

@ -39,6 +39,11 @@ class PHPExcel_Shared_Font
const AUTOSIZE_METHOD_APPROX = 'approx';
const AUTOSIZE_METHOD_EXACT = 'exact';
private static $_autoSizeMethods = array(
self::AUTOSIZE_METHOD_APPROX,
self::AUTOSIZE_METHOD_EXACT,
);
/** Character set codes used by BIFF5-8 in Font records */
const CHARSET_ANSI_LATIN = 0x00;
const CHARSET_SYSTEM_DEFAULT = 0x01;
@ -187,10 +192,17 @@ class PHPExcel_Shared_Font
* Set autoSize method
*
* @param string $pValue
* @return boolean Success or failure
*/
public static function setAutoSizeMethod($pValue = 'approx')
public static function setAutoSizeMethod($pValue = self::AUTOSIZE_METHOD_APPROX)
{
if (!in_array($pValue,self::$_autoSizeMethods)) {
return FALSE;
}
self::$autoSizeMethod = $pValue;
return TRUE;
}
/**

View File

@ -612,7 +612,7 @@ class PHPExcel_Shared_String
{
if (!isset(self::$_decimalSeparator)) {
$localeconv = localeconv();
self::$_decimalSeparator = $localeconv['decimal_point'] != ''
self::$_decimalSeparator = ($localeconv['decimal_point'] != '')
? $localeconv['decimal_point'] : $localeconv['mon_decimal_point'];
if (self::$_decimalSeparator == '') {
@ -644,7 +644,7 @@ class PHPExcel_Shared_String
{
if (!isset(self::$_thousandsSeparator)) {
$localeconv = localeconv();
self::$_thousandsSeparator = $localeconv['thousands_sep'] != ''
self::$_thousandsSeparator = ($localeconv['thousands_sep'] != '')
? $localeconv['thousands_sep'] : $localeconv['mon_thousands_sep'];
}
return self::$_thousandsSeparator;
@ -671,7 +671,7 @@ class PHPExcel_Shared_String
{
if (!isset(self::$_currencyCode)) {
$localeconv = localeconv();
self::$_currencyCode = $localeconv['currency_symbol'] != ''
self::$_currencyCode = ($localeconv['currency_symbol'] != '')
? $localeconv['currency_symbol'] : $localeconv['int_curr_symbol'];
if (self::$_currencyCode == '') {

View File

@ -114,6 +114,10 @@ class PHPExcel_Shared_XMLWriter extends XMLWriter {
*/
public function writeRawData($text)
{
if (is_array($text)) {
$text = implode("\n",$text);
}
if (method_exists($this, 'writeRaw')) {
return $this->writeRaw(htmlspecialchars($text));
}

View File

@ -213,7 +213,7 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
* @throws Exception
* @return PHPExcel_Style_Color
*/
public function applyFromArray($pStyles = null) {
public function applyFromArray($pStyles = NULL) {
if (is_array($pStyles)) {
if ($this->_isSupervisor) {
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
@ -303,8 +303,8 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
* decimal value
* @return string The extracted colour component
*/
private static function _getColourComponent($RGB,$offset,$hex=true) {
$colour = substr($RGB,$offset,2);
private static function _getColourComponent($RGB,$offset,$hex=TRUE) {
$colour = substr($RGB, $offset, 2);
if (!$hex)
$colour = hexdec($colour);
return $colour;
@ -318,11 +318,11 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
* decimal value
* @return string The red colour component
*/
public static function getRed($RGB,$hex=true) {
public static function getRed($RGB,$hex=TRUE) {
if (strlen($RGB) == 8) {
return self::_getColourComponent($RGB,2,$hex);
return self::_getColourComponent($RGB, 2, $hex);
} elseif (strlen($RGB) == 6) {
return self::_getColourComponent($RGB,0,$hex);
return self::_getColourComponent($RGB, 0, $hex);
}
}
@ -334,11 +334,11 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
* decimal value
* @return string The green colour component
*/
public static function getGreen($RGB,$hex=true) {
public static function getGreen($RGB,$hex=TRUE) {
if (strlen($RGB) == 8) {
return self::_getColourComponent($RGB,4,$hex);
return self::_getColourComponent($RGB, 4, $hex);
} elseif (strlen($RGB) == 6) {
return self::_getColourComponent($RGB,2,$hex);
return self::_getColourComponent($RGB, 2, $hex);
}
}
@ -350,25 +350,27 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
* decimal value
* @return string The blue colour component
*/
public static function getBlue($RGB,$hex=true) {
public static function getBlue($RGB,$hex=TRUE) {
if (strlen($RGB) == 8) {
return self::_getColourComponent($RGB,6,$hex);
return self::_getColourComponent($RGB, 6, $hex);
} elseif (strlen($RGB) == 6) {
return self::_getColourComponent($RGB,4,$hex);
return self::_getColourComponent($RGB, 4, $hex);
}
}
/**
* Adjust the brightness of a color
*
* @param string $hex The colour as an RGB value (e.g. FF00CCCC or CCDDEE
* @param string $hex The colour as an RGBA or RGB value (e.g. FF00CCCC or CCDDEE)
* @param float $adjustPercentage The percentage by which to adjust the colour as a float from -1 to 1
* @return string The adjusted colour as an RGB value (e.g. FF00CCCC or CCDDEE
* @return string The adjusted colour as an RGBA or RGB value (e.g. FF00CCCC or CCDDEE)
*/
public static function changeBrightness($hex, $adjustPercentage) {
$red = self::getRed($hex,false);
$green = self::getGreen($hex,false);
$blue = self::getBlue($hex,false);
$rgba = (strlen($hex) == 8);
$red = self::getRed($hex, FALSE);
$green = self::getGreen($hex, FALSE);
$blue = self::getBlue($hex, FALSE);
if ($adjustPercentage > 0) {
$red += (255 - $red) * $adjustPercentage;
$green += (255 - $green) * $adjustPercentage;
@ -386,10 +388,11 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
if ($blue < 0) $blue = 0;
elseif ($blue > 255) $blue = 255;
return strtoupper( str_pad(dechex($red), 2, '0', 0) .
$rgb = strtoupper( str_pad(dechex($red), 2, '0', 0) .
str_pad(dechex($green), 2, '0', 0) .
str_pad(dechex($blue), 2, '0', 0)
);
return (($rgba) ? 'FF' : '') . $rgb;
}
/**
@ -400,7 +403,7 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
* should be returned if the indexed colour doesn't exist
* @return PHPExcel_Style_Color
*/
public static function indexedColor($pIndex, $background=false) {
public static function indexedColor($pIndex, $background=FALSE) {
// Clean parameter
$pIndex = intval($pIndex);

View File

@ -527,6 +527,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*/
public function addChart(PHPExcel_Chart $pChart = null, $iChartIndex = null)
{
$pChart->setWorksheet($this);
if (is_null($iChartIndex)) {
$this->_chartCollection[] = $pChart;
} else {
@ -1026,11 +1027,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
public function setCellValue($pCoordinate = 'A1', $pValue = null, $returnCell = false)
{
$cell = $this->getCell($pCoordinate)->setValue($pValue);
if ($returnCell) {
return $cell;
}
return $this;
return ($returnCell) ? $cell : $this;
}
/**
@ -1045,11 +1042,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
public function setCellValueByColumnAndRow($pColumn = 0, $pRow = 1, $pValue = null, $returnCell = false)
{
$cell = $this->getCell(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow)->setValue($pValue);
if ($returnCell) {
return $cell;
}
return $this;
return ($returnCell) ? $cell : $this;
}
/**
@ -1058,13 +1051,14 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param string $pCoordinate Coordinate of the cell
* @param mixed $pValue Value of the cell
* @param string $pDataType Explicit data type
* @return PHPExcel_Worksheet
* @param bool $returnCell Return the worksheet (false, default) or the cell (true)
* @return PHPExcel_Worksheet|PHPExcel_Cell Depending on the last parameter being specified
*/
public function setCellValueExplicit($pCoordinate = 'A1', $pValue = null, $pDataType = PHPExcel_Cell_DataType::TYPE_STRING)
public function setCellValueExplicit($pCoordinate = 'A1', $pValue = null, $pDataType = PHPExcel_Cell_DataType::TYPE_STRING, $returnCell = false)
{
// Set value
$this->getCell($pCoordinate)->setValueExplicit($pValue, $pDataType);
return $this;
$cell = $this->getCell($pCoordinate)->setValueExplicit($pValue, $pDataType);
return ($returnCell) ? $cell : $this;
}
/**
@ -1074,11 +1068,13 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param string $pRow Numeric row coordinate of the cell
* @param mixed $pValue Value of the cell
* @param string $pDataType Explicit data type
* @return PHPExcel_Worksheet
* @param bool $returnCell Return the worksheet (false, default) or the cell (true)
* @return PHPExcel_Worksheet|PHPExcel_Cell Depending on the last parameter being specified
*/
public function setCellValueExplicitByColumnAndRow($pColumn = 0, $pRow = 1, $pValue = null, $pDataType = PHPExcel_Cell_DataType::TYPE_STRING)
public function setCellValueExplicitByColumnAndRow($pColumn = 0, $pRow = 1, $pValue = null, $pDataType = PHPExcel_Cell_DataType::TYPE_STRING, $returnCell = false)
{
return $this->getCell(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow)->setValueExplicit($pValue, $pDataType);
$cell = $this->getCell(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow)->setValueExplicit($pValue, $pDataType);
return ($returnCell) ? $cell : $this;
}
/**

View File

@ -83,7 +83,12 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->writeAttribute('val', 0);
$objWriter->endElement();
$this->_writePlotArea($pChart->getPlotArea(), $pChart->getXAxisLabel(), $pChart->getYAxisLabel(), $objWriter);
$this->_writePlotArea($pChart->getPlotArea(),
$pChart->getXAxisLabel(),
$pChart->getYAxisLabel(),
$objWriter,
$pChart->getWorksheet()
);
$this->_writeLegend($pChart->getLegend(), $objWriter);
@ -217,7 +222,8 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
private function _writePlotArea(PHPExcel_Chart_PlotArea $plotArea,
PHPExcel_Chart_Title $xAxisLabel = NULL,
PHPExcel_Chart_Title $yAxisLabel = NULL,
$objWriter)
$objWriter,
PHPExcel_Worksheet $pSheet)
{
if (is_null($plotArea)) {
return;
@ -252,7 +258,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->endElement();
}
$this->_writePlotGroup($plotGroup, $chartType, $objWriter, $catIsMultiLevelSeries, $valIsMultiLevelSeries, $plotGroupingType);
$this->_writePlotGroup($plotGroup, $chartType, $objWriter, $catIsMultiLevelSeries, $valIsMultiLevelSeries, $plotGroupingType, $pSheet);
}
}
@ -438,7 +444,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
if (is_array($caption))
$caption = $caption[0];
$objWriter->startElement('a:t');
$objWriter->writeAttribute('xml:space', 'preserve');
// $objWriter->writeAttribute('xml:space', 'preserve');
$objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML( $caption ));
$objWriter->endElement();
@ -564,7 +570,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
if (is_array($caption))
$caption = $caption[0];
$objWriter->startElement('a:t');
$objWriter->writeAttribute('xml:space', 'preserve');
// $objWriter->writeAttribute('xml:space', 'preserve');
$objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML( $caption ));
$objWriter->endElement();
@ -664,9 +670,17 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
* @param boolean &$catIsMultiLevelSeries Is category a multi-series category
* @param boolean &$valIsMultiLevelSeries Is value set a multi-series set
* @param string &$plotGroupingType Type of grouping for multi-series values
* @param PHPExcel_Worksheet $pSheet
* @throws Exception
*/
private function _writePlotGroup($plotGroup, $groupType, $objWriter, &$catIsMultiLevelSeries, &$valIsMultiLevelSeries, &$plotGroupingType)
private function _writePlotGroup( $plotGroup,
$groupType,
$objWriter,
&$catIsMultiLevelSeries,
&$valIsMultiLevelSeries,
&$plotGroupingType,
PHPExcel_Worksheet $pSheet
)
{
if (is_null($plotGroup)) {
return;
@ -815,7 +829,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->startElement('c:cat');
}
$this->_writePlotSeriesValues($plotSeriesCategory, $objWriter, $groupType, 'str');
$this->_writePlotSeriesValues($plotSeriesCategory, $objWriter, $groupType, 'str', $pSheet);
$objWriter->endElement();
}
@ -830,12 +844,12 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->startElement('c:val');
}
$this->_writePlotSeriesValues($plotSeriesValues, $objWriter, $groupType, 'num');
$this->_writePlotSeriesValues($plotSeriesValues, $objWriter, $groupType, 'num', $pSheet);
$objWriter->endElement();
}
if ($groupType === PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) {
$this->_writeBubbles($plotSeriesValues, $objWriter);
$this->_writeBubbles($plotSeriesValues, $objWriter, $pSheet);
}
$objWriter->endElement();
@ -885,9 +899,15 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
* @param string $groupType Type of plot for dataseries
* @param string $dataType Datatype of series values
* @param PHPExcel_Worksheet $pSheet
* @throws Exception
*/
private function _writePlotSeriesValues($plotSeriesValues, $objWriter, $groupType, $dataType='str')
private function _writePlotSeriesValues( $plotSeriesValues,
$objWriter,
$groupType,
$dataType='str',
PHPExcel_Worksheet $pSheet
)
{
if (is_null($plotSeriesValues)) {
return;
@ -942,7 +962,8 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
($groupType != PHPExcel_Chart_DataSeries::TYPE_PIECHART_3D) &&
($groupType != PHPExcel_Chart_DataSeries::TYPE_DONUTCHART)) {
if ($plotSeriesValues->getFormatCode() !== NULL) {
if (($plotSeriesValues->getFormatCode() !== NULL) &&
($plotSeriesValues->getFormatCode() !== '')) {
$objWriter->startElement('c:formatCode');
$objWriter->writeRawData( $plotSeriesValues->getFormatCode() );
$objWriter->endElement();
@ -955,14 +976,16 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
$dataValues = $plotSeriesValues->getDataValues();
if (!empty($dataValues)) {
foreach($dataValues as $plotSeriesKey => $plotSeriesValue) {
$objWriter->startElement('c:pt');
$objWriter->writeAttribute('idx', $plotSeriesKey );
if (is_array($dataValues)) {
foreach($dataValues as $plotSeriesKey => $plotSeriesValue) {
$objWriter->startElement('c:pt');
$objWriter->writeAttribute('idx', $plotSeriesKey );
$objWriter->startElement('c:v');
$objWriter->writeRawData( $plotSeriesValue );
$objWriter->startElement('c:v');
$objWriter->writeRawData( $plotSeriesValue );
$objWriter->endElement();
$objWriter->endElement();
$objWriter->endElement();
}
}
}
@ -979,7 +1002,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
* @throws Exception
*/
private function _writeBubbles($plotSeriesValues, $objWriter)
private function _writeBubbles($plotSeriesValues, $objWriter, PHPExcel_Worksheet $pSheet)
{
if (is_null($plotSeriesValues)) {
return;
@ -996,13 +1019,18 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->writeAttribute('val', $plotSeriesValues->getPointCount() );
$objWriter->endElement();
foreach($plotSeriesValues->getDataValues() as $plotSeriesKey => $plotSeriesValue) {
$objWriter->startElement('c:pt');
$objWriter->writeAttribute('idx', $plotSeriesKey );
$objWriter->startElement('c:v');
$objWriter->writeRawData( 1 );
$objWriter->endElement();
$objWriter->endElement();
$dataValues = $plotSeriesValues->getDataValues();
if (!empty($dataValues)) {
if (is_array($dataValues)) {
foreach($dataValues as $plotSeriesKey => $plotSeriesValue) {
$objWriter->startElement('c:pt');
$objWriter->writeAttribute('idx', $plotSeriesKey );
$objWriter->startElement('c:v');
$objWriter->writeRawData( 1 );
$objWriter->endElement();
$objWriter->endElement();
}
}
}
$objWriter->endElement();

View File

@ -286,7 +286,7 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
// t
$objWriter->startElement($prefix.'t');
$objWriter->writeAttribute('xml:space', 'preserve');
// $objWriter->writeAttribute('xml:space', 'preserve'); // Excel2010 accepts, Excel2007 complains
$objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML( $element->getText() ));
$objWriter->endElement();

36
README.md Normal file
View File

@ -0,0 +1,36 @@
# PHPExcel - OpenXML - Read, Write and Create spreadsheet documents in PHP - Spreadsheet engine
PHPExcel is a library written in pure PHP and providing a set of classes that allow you to write to and read from different spreadsheet file formats, like Excel (BIFF) .xls, Excel 2007 (OfficeOpenXML) .xlsx, CSV, Libre/OpenOffice Calc .ods, Gnumeric, PDF, HTML, ... This project is built around Microsoft's OpenXML standard and PHP.
## File Formats supported
### Reading
* BIFF 5-8 (.xls) Excel 95 and above
* Office Open XML (.xlsx) Excel 2007 and above
* SpreadsheetML (.xml) Excel 2003
* Open Document Format/OASIS (.ods)
* Gnumeric
* HTML
* SYLK
* CSV
### Writing
* BIFF 8 (.xls) Excel 95 and above
* Office Open XML (.xlsx) Excel 2007 and above
* HTML
* CSV
* PDF (using either the tcPDF, DomPDF or mPDF libraries, which need to be installed separately)
## Requirements
* PHP version 5.2.0 or higher
* PHP extension php_zip enabled (required if you need PHPExcel to handle .xlsx .ods or .gnumeric files)
* PHP extension php_xml enabled
* PHP extension php_gd2 enabled (optional, but required for exact column width autocalculation)
## Want to contribute?
Fork us!
## License
PHPExcel is licensed under [LGPL (GNU LESSER GENERAL PUBLIC LICENSE)](https://github.com/PHPOffice/PHPExcel/blob/master/license.txt)

View File

@ -27,9 +27,13 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Europe/London');
if (PHP_SAPI == 'cli')
die('This example should only be run from a Web Browser');
/** Include PHPExcel */
require_once '../Classes/PHPExcel.php';
@ -84,7 +88,7 @@ if (!PHPExcel_Settings::setPdfRenderer(
)) {
die(
'NOTICE: Please set the $rendererName and $rendererLibraryPath values' .
PHP_EOL .
'<br />' .
'at the top of this script as appropriate for your directory structure'
);
}

View File

@ -27,9 +27,13 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Europe/London');
if (PHP_SAPI == 'cli')
die('This example should only be run from a Web Browser');
/** Include PHPExcel */
require_once '../Classes/PHPExcel.php';

View File

@ -27,9 +27,13 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Europe/London');
if (PHP_SAPI == 'cli')
die('This example should only be run from a Web Browser');
/** Include PHPExcel */
require_once '../Classes/PHPExcel.php';

View File

@ -27,19 +27,22 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Europe/London');
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
/** Include PHPExcel */
require_once '../Classes/PHPExcel.php';
// Create new PHPExcel object
echo date('H:i:s') , " Create new PHPExcel object" , PHP_EOL;
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
$objPHPExcel = new PHPExcel();
// Set document properties
echo date('H:i:s') , " Set document properties" , PHP_EOL;
echo date('H:i:s') , " Set document properties" , EOL;
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
->setLastModifiedBy("Maarten Balliauw")
->setTitle("PHPExcel Test Document")
@ -50,7 +53,7 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
// Add some data
echo date('H:i:s') , " Add some data" , PHP_EOL;
echo date('H:i:s') , " Add some data" , EOL;
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A1', 'Hello')
->setCellValue('B2', 'world!')
@ -63,7 +66,7 @@ $objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');
// Rename worksheet
echo date('H:i:s') , " Rename worksheet" , PHP_EOL;
echo date('H:i:s') , " Rename worksheet" , EOL;
$objPHPExcel->getActiveSheet()->setTitle('Simple');
@ -72,19 +75,20 @@ $objPHPExcel->setActiveSheetIndex(0);
// Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , PHP_EOL;
echo date('H:i:s') , " Write to Excel2007 format" , 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 date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Save Excel5 file
echo date('H:i:s') , " Write to Excel5 format" , PHP_EOL;
echo date('H:i:s') , " Write to Excel5 format" , 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 date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo done
echo date('H:i:s') , " Done writing file" , PHP_EOL;
echo date('H:i:s') , " Done writing files" , EOL;
echo 'Files have been created in ' , getcwd() , EOL;

View File

@ -27,19 +27,22 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Europe/London');
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
/** Include PHPExcel */
require_once '../Classes/PHPExcel.php';
// Create new PHPExcel object
echo date('H:i:s') , " Create new PHPExcel object" , PHP_EOL;
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
$objPHPExcel = new PHPExcel();
// Set document properties
echo date('H:i:s') , " Set document properties" , PHP_EOL;
echo date('H:i:s') , " Set document properties" , EOL;
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
->setLastModifiedBy("Maarten Balliauw")
->setTitle("Office 2007 XLSX Test Document")
@ -49,65 +52,65 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
->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);
echo date('H:i:s') , " Set default font" , EOL;
$objPHPExcel->getDefaultStyle()->getFont()->setName('Arial')
->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');
echo date('H:i:s') , " Add some data" , EOL;
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'String')
->setCellValue('B1', 'Simple')
->setCellValue('C1', 'PHPExcel');
$objPHPExcel->getActiveSheet()->setCellValue('A2', 'String');
$objPHPExcel->getActiveSheet()->setCellValue('B2', 'Symbols');
$objPHPExcel->getActiveSheet()->setCellValue('C2', '!+&=()~§±æþ');
$objPHPExcel->getActiveSheet()->setCellValue('A2', 'String')
->setCellValue('B2', 'Symbols')
->setCellValue('C2', '!+&=()~§±æþ');
$objPHPExcel->getActiveSheet()->setCellValue('A3', 'String');
$objPHPExcel->getActiveSheet()->setCellValue('B3', 'UTF-8');
$objPHPExcel->getActiveSheet()->setCellValue('C3', 'Создать MS Excel Книги из PHP скриптов');
$objPHPExcel->getActiveSheet()->setCellValue('A3', 'String')
->setCellValue('B3', 'UTF-8')
->setCellValue('C3', 'Создать MS Excel Книги из PHP скриптов');
$objPHPExcel->getActiveSheet()->setCellValue('A4', 'Number');
$objPHPExcel->getActiveSheet()->setCellValue('B4', 'Integer');
$objPHPExcel->getActiveSheet()->setCellValue('C4', 12);
$objPHPExcel->getActiveSheet()->setCellValue('A4', 'Number')
->setCellValue('B4', 'Integer')
->setCellValue('C4', 12);
$objPHPExcel->getActiveSheet()->setCellValue('A5', 'Number');
$objPHPExcel->getActiveSheet()->setCellValue('B5', 'Float');
$objPHPExcel->getActiveSheet()->setCellValue('C5', 34.56);
$objPHPExcel->getActiveSheet()->setCellValue('A5', 'Number')
->setCellValue('B5', 'Float')
->setCellValue('C5', 34.56);
$objPHPExcel->getActiveSheet()->setCellValue('A6', 'Number');
$objPHPExcel->getActiveSheet()->setCellValue('B6', 'Negative');
$objPHPExcel->getActiveSheet()->setCellValue('C6', -7.89);
$objPHPExcel->getActiveSheet()->setCellValue('A6', 'Number')
->setCellValue('B6', 'Negative')
->setCellValue('C6', -7.89);
$objPHPExcel->getActiveSheet()->setCellValue('A7', 'Boolean');
$objPHPExcel->getActiveSheet()->setCellValue('B7', 'True');
$objPHPExcel->getActiveSheet()->setCellValue('C7', true);
$objPHPExcel->getActiveSheet()->setCellValue('A7', 'Boolean')
->setCellValue('B7', 'True')
->setCellValue('C7', true);
$objPHPExcel->getActiveSheet()->setCellValue('A8', 'Boolean');
$objPHPExcel->getActiveSheet()->setCellValue('B8', 'False');
$objPHPExcel->getActiveSheet()->setCellValue('C8', false);
$objPHPExcel->getActiveSheet()->setCellValue('A8', 'Boolean')
->setCellValue('B8', 'False')
->setCellValue('C8', false);
$dateTimeNow = time();
$objPHPExcel->getActiveSheet()->setCellValue('A9', 'Date/Time');
$objPHPExcel->getActiveSheet()->setCellValue('B9', 'Date');
$objPHPExcel->getActiveSheet()->setCellValue('C9', PHPExcel_Shared_Date::PHPToExcel( $dateTimeNow ));
$objPHPExcel->getActiveSheet()->setCellValue('A9', 'Date/Time')
->setCellValue('B9', 'Date')
->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()->setCellValue('A10', 'Date/Time')
->setCellValue('B10', 'Time')
->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()->setCellValue('A11', 'Date/Time')
->setCellValue('B11', 'Date and Time')
->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;
echo date('H:i:s') , " Rename worksheet" , EOL;
$objPHPExcel->getActiveSheet()->setTitle('Datatypes');
@ -116,20 +119,21 @@ $objPHPExcel->setActiveSheetIndex(0);
// Save Excel 2007 file
echo date('H:i:s') , " Write to Excel5 format" , PHP_EOL;
echo date('H:i:s') , " Write to Excel5 format" , 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 date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo date('H:i:s') , " Reload workbook from saved file" , PHP_EOL;
echo date('H:i:s') , " Reload workbook from saved file" , EOL;
$objPHPExcel = PHPExcel_IOFactory::load(str_replace('.php', '.xls', __FILE__));
var_dump($objPHPExcel->getActiveSheet()->toArray());
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo done
echo date('H:i:s') , " Done writing file" , PHP_EOL;
echo date('H:i:s') , " Done writing file" , EOL;
echo 'File has been created in ' , getcwd() , EOL;

View File

@ -27,19 +27,22 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Europe/London');
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
/** Include PHPExcel */
require_once '../Classes/PHPExcel.php';
// Create new PHPExcel object
echo date('H:i:s') , " Create new PHPExcel object" , PHP_EOL;
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
$objPHPExcel = new PHPExcel();
// Set document properties
echo date('H:i:s') , " Set document properties" , PHP_EOL;
echo date('H:i:s') , " Set document properties" , EOL;
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
->setLastModifiedBy("Maarten Balliauw")
->setTitle("Office 2007 XLSX Test Document")
@ -49,65 +52,65 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
->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);
echo date('H:i:s') , " Set default font" , EOL;
$objPHPExcel->getDefaultStyle()->getFont()->setName('Arial')
->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');
echo date('H:i:s') , " Add some data" , EOL;
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'String')
->setCellValue('B1', 'Simple')
->setCellValue('C1', 'PHPExcel');
$objPHPExcel->getActiveSheet()->setCellValue('A2', 'String');
$objPHPExcel->getActiveSheet()->setCellValue('B2', 'Symbols');
$objPHPExcel->getActiveSheet()->setCellValue('C2', '!+&=()~§±æþ');
$objPHPExcel->getActiveSheet()->setCellValue('A2', 'String')
->setCellValue('B2', 'Symbols')
->setCellValue('C2', '!+&=()~§±æþ');
$objPHPExcel->getActiveSheet()->setCellValue('A3', 'String');
$objPHPExcel->getActiveSheet()->setCellValue('B3', 'UTF-8');
$objPHPExcel->getActiveSheet()->setCellValue('C3', 'Создать MS Excel Книги из PHP скриптов');
$objPHPExcel->getActiveSheet()->setCellValue('A3', 'String')
->setCellValue('B3', 'UTF-8')
->setCellValue('C3', 'Создать MS Excel Книги из PHP скриптов');
$objPHPExcel->getActiveSheet()->setCellValue('A4', 'Number');
$objPHPExcel->getActiveSheet()->setCellValue('B4', 'Integer');
$objPHPExcel->getActiveSheet()->setCellValue('C4', 12);
$objPHPExcel->getActiveSheet()->setCellValue('A4', 'Number')
->setCellValue('B4', 'Integer')
->setCellValue('C4', 12);
$objPHPExcel->getActiveSheet()->setCellValue('A5', 'Number');
$objPHPExcel->getActiveSheet()->setCellValue('B5', 'Float');
$objPHPExcel->getActiveSheet()->setCellValue('C5', 34.56);
$objPHPExcel->getActiveSheet()->setCellValue('A5', 'Number')
->setCellValue('B5', 'Float')
->setCellValue('C5', 34.56);
$objPHPExcel->getActiveSheet()->setCellValue('A6', 'Number');
$objPHPExcel->getActiveSheet()->setCellValue('B6', 'Negative');
$objPHPExcel->getActiveSheet()->setCellValue('C6', -7.89);
$objPHPExcel->getActiveSheet()->setCellValue('A6', 'Number')
->setCellValue('B6', 'Negative')
->setCellValue('C6', -7.89);
$objPHPExcel->getActiveSheet()->setCellValue('A7', 'Boolean');
$objPHPExcel->getActiveSheet()->setCellValue('B7', 'True');
$objPHPExcel->getActiveSheet()->setCellValue('C7', true);
$objPHPExcel->getActiveSheet()->setCellValue('A7', 'Boolean')
->setCellValue('B7', 'True')
->setCellValue('C7', true);
$objPHPExcel->getActiveSheet()->setCellValue('A8', 'Boolean');
$objPHPExcel->getActiveSheet()->setCellValue('B8', 'False');
$objPHPExcel->getActiveSheet()->setCellValue('C8', false);
$objPHPExcel->getActiveSheet()->setCellValue('A8', 'Boolean')
->setCellValue('B8', 'False')
->setCellValue('C8', false);
$dateTimeNow = time();
$objPHPExcel->getActiveSheet()->setCellValue('A9', 'Date/Time');
$objPHPExcel->getActiveSheet()->setCellValue('B9', 'Date');
$objPHPExcel->getActiveSheet()->setCellValue('C9', PHPExcel_Shared_Date::PHPToExcel( $dateTimeNow ));
$objPHPExcel->getActiveSheet()->setCellValue('A9', 'Date/Time')
->setCellValue('B9', 'Date')
->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()->setCellValue('A10', 'Date/Time')
->setCellValue('B10', 'Time')
->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()->setCellValue('A11', 'Date/Time')
->setCellValue('B11', 'Date and Time')
->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;
echo date('H:i:s') , " Rename worksheet" , EOL;
$objPHPExcel->getActiveSheet()->setTitle('Datatypes');
@ -116,20 +119,21 @@ $objPHPExcel->setActiveSheetIndex(0);
// Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , PHP_EOL;
echo date('H:i:s') , " Write to Excel2007 format" , 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 date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo date('H:i:s') , " Reload workbook from saved file" , PHP_EOL;
echo date('H:i:s') , " Reload workbook from saved file" , EOL;
$objPHPExcel = PHPExcel_IOFactory::load(str_replace('.php', '.xlsx', __FILE__));
var_dump($objPHPExcel->getActiveSheet()->toArray());
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo done
echo date('H:i:s') , " Done writing file" , PHP_EOL;
echo date('H:i:s') , " Done writing file" , EOL;
echo 'File has been created in ' , getcwd() , EOL;

View File

@ -27,19 +27,22 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Europe/London');
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
/** Include PHPExcel */
require_once '../Classes/PHPExcel.php';
// Create new PHPExcel object
echo date('H:i:s') , " Create new PHPExcel object" , PHP_EOL;
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
$objPHPExcel = new PHPExcel();
// Set document properties
echo date('H:i:s') , " Set document properties" , PHP_EOL;
echo date('H:i:s') , " Set document properties" , EOL;
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
->setLastModifiedBy("Maarten Balliauw")
->setTitle("Office 2007 XLSX Test Document")
@ -50,7 +53,7 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
// Add some data, we will use some formulas here
echo date('H:i:s') , " Add some data" , PHP_EOL;
echo date('H:i:s') , " Add some data" , EOL;
$objPHPExcel->getActiveSheet()->setCellValue('A5', 'Sum:');
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Range #1')
@ -59,7 +62,7 @@ $objPHPExcel->getActiveSheet()->setCellValue('B1', 'Range #1')
->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()->getCell('B5')->getCalculatedValue() , EOL;
$objPHPExcel->getActiveSheet()->setCellValue('C1', 'Range #2')
->setCellValue('C2', 5)
@ -67,31 +70,31 @@ $objPHPExcel->getActiveSheet()->setCellValue('C1', 'Range #2')
->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()->getCell('C5')->getCalculatedValue() , 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()->getCell('B7')->getCalculatedValue() , 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()->getCell('B8')->getCalculatedValue() , 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;
$objPHPExcel->getActiveSheet()->getCell('B9')->getCalculatedValue() , EOL;
$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;
$objPHPExcel->getActiveSheet()->getCell('B10')->getCalculatedValue() , EOL;
// Rename worksheet
echo date('H:i:s') , " Rename worksheet" , PHP_EOL;
echo date('H:i:s') , " Rename worksheet" , EOL;
$objPHPExcel->getActiveSheet()->setTitle('Formulas');
@ -100,14 +103,20 @@ $objPHPExcel->setActiveSheetIndex(0);
// Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , PHP_EOL;
echo date('H:i:s') , " Write to Excel2007 format" , 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 date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Save Excel5 file
echo date('H:i:s') , " Write to Excel5 format" , 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', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo done
echo date('H:i:s') , " Done writing file" , PHP_EOL;
echo date('H:i:s') , " Done writing files" , EOL;
echo 'Files have been created in ' , getcwd() , EOL;

View File

@ -27,6 +27,10 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
@ -35,11 +39,11 @@ require_once '../Classes/PHPExcel.php';
// Create new PHPExcel object
echo date('H:i:s') , " Create new PHPExcel object" , PHP_EOL;
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
$objPHPExcel = new PHPExcel();
// Set document properties
echo date('H:i:s') , " Set document properties" , PHP_EOL;
echo date('H:i:s') , " Set document properties" , EOL;
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
->setLastModifiedBy("Maarten Balliauw")
->setTitle("Office 2007 XLSX Test Document")
@ -50,19 +54,19 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
// Add some data, we will use printing features
echo date('H:i:s') , " Add some data" , PHP_EOL;
echo date('H:i:s') , " Add some data" , 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" , PHP_EOL;
echo date('H:i:s') , " Set header/footer" , 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" , PHP_EOL;
echo date('H:i:s') , " Add a drawing to the header" , EOL;
$objDrawing = new PHPExcel_Worksheet_HeaderFooterDrawing();
$objDrawing->setName('PHPExcel logo');
$objDrawing->setPath('./images/phpexcel_logo.gif');
@ -70,12 +74,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" , PHP_EOL;
echo date('H:i:s') , " Set page orientation and size" , EOL;
$objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);
$objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
// Rename worksheet
echo date('H:i:s') , " Rename worksheet" , PHP_EOL;
echo date('H:i:s') , " Rename worksheet" , EOL;
$objPHPExcel->getActiveSheet()->setTitle('Printing');
@ -84,14 +88,20 @@ $objPHPExcel->setActiveSheetIndex(0);
// Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , PHP_EOL;
echo date('H:i:s') , " Write to Excel2007 format" , 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 date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Save Excel5 file
echo date('H:i:s') , " Write to Excel5 format" , 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', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo done
echo date('H:i:s') , " Done writing file" , PHP_EOL;
echo date('H:i:s') , " Done writing files" , EOL;
echo 'Files have been created in ' , getcwd() , EOL;

View File

@ -27,6 +27,10 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
@ -37,13 +41,19 @@ require_once '../Classes/PHPExcel/IOFactory.php';
// Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , PHP_EOL;
echo date('H:i:s') , " Write to Excel2007 format" , 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 date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Save Excel5 file
echo date('H:i:s') , " Write to Excel5 format" , 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', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo done
echo date('H:i:s') , " Done writing file" , PHP_EOL;
echo date('H:i:s') , " Done writing files" , EOL;
echo 'Files have been created in ' , getcwd() , EOL;

View File

@ -27,6 +27,10 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
@ -49,11 +53,11 @@ for writing to Excel2007:
*/
// Create new PHPExcel object
echo date('H:i:s') , " Create new PHPExcel object" , PHP_EOL;
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
$objPHPExcel = new PHPExcel();
// Set document properties
echo date('H:i:s') , " Set properties" , PHP_EOL;
echo date('H:i:s') , " Set properties" , EOL;
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
->setLastModifiedBy("Maarten Balliauw")
->setTitle("Office 2007 XLSX Test Document")
@ -64,7 +68,7 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
// Create a first sheet
echo date('H:i:s') , " Add data" , PHP_EOL;
echo date('H:i:s') , " Add data" , EOL;
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Firstname");
$objPHPExcel->getActiveSheet()->setCellValue('B1', "Lastname");
@ -74,24 +78,24 @@ $objPHPExcel->getActiveSheet()->setCellValue('E1', "Is Client ?");
// Hide "Phone" and "fax" column
echo date('H:i:s') , " Hide 'Phone' and 'fax' columns" , PHP_EOL;
echo date('H:i:s') , " Hide 'Phone' and 'fax' columns" , 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;
echo date('H:i:s') , " Set outline levels" , EOL;
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setOutlineLevel(1)
->setVisible(false)
->setCollapsed(true);
// Freeze panes
echo date('H:i:s') , " Freeze panes" , PHP_EOL;
echo date('H:i:s') , " Freeze panes" , EOL;
$objPHPExcel->getActiveSheet()->freezePane('A2');
// Rows to repeat at top
echo date('H:i:s') , " Rows to repeat at top" , PHP_EOL;
echo date('H:i:s') , " Rows to repeat at top" , EOL;
$objPHPExcel->getActiveSheet()->getPageSetup()->setRowsToRepeatAtTopByStartAndEnd(1, 1);
@ -110,14 +114,15 @@ $objPHPExcel->setActiveSheetIndex(0);
// Save Excel 5 file
echo date('H:i:s') , " Write to Excel5 format" , PHP_EOL;
echo date('H:i:s') , " Write to Excel5 format" , 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 date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo done
echo date('H:i:s') , " Done writing file" , PHP_EOL;
echo date('H:i:s') , " Done writing file" , EOL;
echo 'File has been created in ' , getcwd() , EOL;

View File

@ -27,6 +27,10 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
@ -49,11 +53,11 @@ for writing to Excel2007:
*/
// Create new PHPExcel object
echo date('H:i:s') , " Create new PHPExcel object" , PHP_EOL;
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
$objPHPExcel = new PHPExcel();
// Set document properties
echo date('H:i:s') , " Set properties" , PHP_EOL;
echo date('H:i:s') , " Set properties" , EOL;
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
->setLastModifiedBy("Maarten Balliauw")
->setTitle("Office 2007 XLSX Test Document")
@ -64,7 +68,7 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
// Create a first sheet
echo date('H:i:s') , " Add data" , PHP_EOL;
echo date('H:i:s') , " Add data" , EOL;
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Firstname");
$objPHPExcel->getActiveSheet()->setCellValue('B1', "Lastname");
@ -74,24 +78,24 @@ $objPHPExcel->getActiveSheet()->setCellValue('E1', "Is Client ?");
// Hide "Phone" and "fax" column
echo date('H:i:s') , " Hide 'Phone' and 'fax' columns" , PHP_EOL;
echo date('H:i:s') , " Hide 'Phone' and 'fax' columns" , 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;
echo date('H:i:s') , " Set outline levels" , EOL;
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setOutlineLevel(1)
->setVisible(false)
->setCollapsed(true);
// Freeze panes
echo date('H:i:s') , " Freeze panes" , PHP_EOL;
echo date('H:i:s') , " Freeze panes" , EOL;
$objPHPExcel->getActiveSheet()->freezePane('A2');
// Rows to repeat at top
echo date('H:i:s') , " Rows to repeat at top" , PHP_EOL;
echo date('H:i:s') , " Rows to repeat at top" , EOL;
$objPHPExcel->getActiveSheet()->getPageSetup()->setRowsToRepeatAtTopByStartAndEnd(1, 1);
@ -110,14 +114,15 @@ $objPHPExcel->setActiveSheetIndex(0);
// Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , PHP_EOL;
echo date('H:i:s') , " Write to Excel2007 format" , 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 date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo done
echo date('H:i:s') , " Done writing file" , PHP_EOL;
echo date('H:i:s') , " Done writing file" , EOL;
echo 'File has been created in ' , getcwd() , EOL;

View File

@ -26,6 +26,10 @@
*/
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
@ -34,20 +38,21 @@ require_once '../Classes/PHPExcel/IOFactory.php';
if (!file_exists("05featuredemo.xlsx")) {
exit("Please run 05featuredemo.php first." . PHP_EOL);
exit("Please run 05featuredemo.php first." . EOL);
}
echo date('H:i:s') , " Load from Excel2007 file" , PHP_EOL;
echo date('H:i:s') , " Load from Excel2007 file" , EOL;
$objPHPExcel = PHPExcel_IOFactory::load("05featuredemo.xlsx");
echo date('H:i:s') , " Write to Excel2007 format" , PHP_EOL;
echo date('H:i:s') , " Write to Excel2007 format" , 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 date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo done
echo date('H:i:s') , " Done writing files" , PHP_EOL;
echo date('H:i:s') , " Done writing file" , EOL;
echo 'File has been created in ' , getcwd() , EOL;

View File

@ -27,6 +27,10 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
@ -35,11 +39,11 @@ require_once '../Classes/PHPExcel.php';
// Create new PHPExcel object
echo date('H:i:s') , " Create new PHPExcel object" , PHP_EOL;
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
$objPHPExcel = new PHPExcel();
// Set document properties
echo date('H:i:s') , " Set document properties" , PHP_EOL;
echo date('H:i:s') , " Set document properties" , EOL;
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
->setLastModifiedBy("Maarten Balliauw")
->setTitle("Office 2007 XLSX Test Document")
@ -50,59 +54,59 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
// Create a first sheet, representing sales data
echo date('H:i:s') , " Add some data" , PHP_EOL;
echo date('H:i:s') , " Add some data" , EOL;
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Description');
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Amount');
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Description')
->setCellValue('B1', 'Amount');
$objPHPExcel->getActiveSheet()->setCellValue('A2', 'Paycheck received');
$objPHPExcel->getActiveSheet()->setCellValue('B2', 100);
$objPHPExcel->getActiveSheet()->setCellValue('A2', 'Paycheck received')
->setCellValue('B2', 100);
$objPHPExcel->getActiveSheet()->setCellValue('A3', 'Cup of coffee bought');
$objPHPExcel->getActiveSheet()->setCellValue('B3', -1.5);
$objPHPExcel->getActiveSheet()->setCellValue('A3', 'Cup of coffee bought')
->setCellValue('B3', -1.5);
$objPHPExcel->getActiveSheet()->setCellValue('A4', 'Cup of coffee bought');
$objPHPExcel->getActiveSheet()->setCellValue('B4', -1.5);
$objPHPExcel->getActiveSheet()->setCellValue('A4', 'Cup of coffee bought')
->setCellValue('B4', -1.5);
$objPHPExcel->getActiveSheet()->setCellValue('A5', 'Cup of tea bought');
$objPHPExcel->getActiveSheet()->setCellValue('B5', -1.2);
$objPHPExcel->getActiveSheet()->setCellValue('A5', 'Cup of tea bought')
->setCellValue('B5', -1.2);
$objPHPExcel->getActiveSheet()->setCellValue('A6', 'Found some money');
$objPHPExcel->getActiveSheet()->setCellValue('B6', 8);
$objPHPExcel->getActiveSheet()->setCellValue('A6', 'Found some money')
->setCellValue('B6', 8);
$objPHPExcel->getActiveSheet()->setCellValue('A7', 'Total:');
$objPHPExcel->getActiveSheet()->setCellValue('B7', '=SUM(B2:B6)');
$objPHPExcel->getActiveSheet()->setCellValue('A7', 'Total:')
->setCellValue('B7', '=SUM(B2:B6)');
// Set column widths
echo date('H:i:s') , " Set column widths" , PHP_EOL;
echo date('H:i:s') , " Set column widths" , EOL;
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(30);
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(12);
// Add conditional formatting
echo date('H:i:s') , " Add conditional formatting" , PHP_EOL;
echo date('H:i:s') , " Add conditional formatting" , EOL;
$objConditional1 = new PHPExcel_Style_Conditional();
$objConditional1->setConditionType(PHPExcel_Style_Conditional::CONDITION_CELLIS);
$objConditional1->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_BETWEEN);
$objConditional1->addCondition('200');
$objConditional1->addCondition('400');
$objConditional1->setConditionType(PHPExcel_Style_Conditional::CONDITION_CELLIS)
->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_BETWEEN)
->addCondition('200')
->addCondition('400');
$objConditional1->getStyle()->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_YELLOW);
$objConditional1->getStyle()->getFont()->setBold(true);
$objConditional1->getStyle()->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE);
$objConditional2 = new PHPExcel_Style_Conditional();
$objConditional2->setConditionType(PHPExcel_Style_Conditional::CONDITION_CELLIS);
$objConditional2->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_LESSTHAN);
$objConditional2->addCondition('0');
$objConditional2->setConditionType(PHPExcel_Style_Conditional::CONDITION_CELLIS)
->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_LESSTHAN)
->addCondition('0');
$objConditional2->getStyle()->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_RED);
$objConditional2->getStyle()->getFont()->setBold(true);
$objConditional2->getStyle()->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE);
$objConditional3 = new PHPExcel_Style_Conditional();
$objConditional3->setConditionType(PHPExcel_Style_Conditional::CONDITION_CELLIS);
$objConditional3->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_GREATERTHANOREQUAL);
$objConditional3->addCondition('0');
$objConditional3->setConditionType(PHPExcel_Style_Conditional::CONDITION_CELLIS)
->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_GREATERTHANOREQUAL)
->addCondition('0');
$objConditional3->getStyle()->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_GREEN);
$objConditional3->getStyle()->getFont()->setBold(true);
$objConditional3->getStyle()->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE);
@ -115,15 +119,15 @@ $objPHPExcel->getActiveSheet()->getStyle('B2')->setConditionalStyles($conditiona
// 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;
echo date('H:i:s') , " Duplicate the conditional formatting across a range of cells" , EOL;
$objPHPExcel->getActiveSheet()->duplicateConditionalStyle(
$objPHPExcel->getActiveSheet()->getStyle('B2')->getConditionalStyles(),
'B3:B7'
);
);
// Set fonts
echo date('H:i:s') , " Set fonts" , PHP_EOL;
echo date('H:i:s') , " Set fonts" , EOL;
$objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle('A7')->getFont()->setBold(true);
@ -131,19 +135,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" , PHP_EOL;
echo date('H:i:s') , " Set header/footer" , 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" , PHP_EOL;
echo date('H:i:s') , " Set page orientation and size" , EOL;
$objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT);
$objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
// Rename worksheet
echo date('H:i:s') , " Rename worksheet" , PHP_EOL;
echo date('H:i:s') , " Rename worksheet" , EOL;
$objPHPExcel->getActiveSheet()->setTitle('Invoice');
@ -152,14 +156,15 @@ $objPHPExcel->setActiveSheetIndex(0);
// Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , PHP_EOL;
echo date('H:i:s') , " Write to Excel2007 format" , 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 date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo done
echo date('H:i:s') , " Done writing file" , PHP_EOL;
echo date('H:i:s') , " Done writing file" , EOL;
echo 'File has been created in ' , getcwd() , EOL;

View File

@ -27,6 +27,10 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
@ -35,11 +39,11 @@ require_once '../Classes/PHPExcel.php';
// Create new PHPExcel object
echo date('H:i:s') , " Create new PHPExcel object" , PHP_EOL;
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
$objPHPExcel = new PHPExcel();
// Set document properties
echo date('H:i:s') , " Set document properties" , PHP_EOL;
echo date('H:i:s') , " Set document properties" , EOL;
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
->setLastModifiedBy("Maarten Balliauw")
->setTitle("Office 2007 XLSX Test Document")
@ -50,7 +54,7 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
// Create a first sheet
echo date('H:i:s') , " Add data and page breaks" , PHP_EOL;
echo date('H:i:s') , " Add data and page breaks" , EOL;
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Firstname")
->setCellValue('B1', "Lastname")
@ -80,14 +84,20 @@ $objPHPExcel->setActiveSheetIndex(0);
// Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , PHP_EOL;
echo date('H:i:s') , " Write to Excel2007 format" , 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 date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Save Excel5 file
echo date('H:i:s') , " Write to Excel5 format" , 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', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo done
echo date('H:i:s') , " Done writing file" , PHP_EOL;
echo date('H:i:s') , " Done writing files" , EOL;
echo 'Files have been created in ' , getcwd() , EOL;

View File

@ -27,19 +27,16 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
/** Include PHPExcel */
require_once '../Classes/PHPExcel.php';
if(php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) {
define('EOL',PHP_EOL);
}
else {
define('EOL', '<br />');
}
// Create new PHPExcel object
echo date('H:i:s').' Create new PHPExcel object'.EOL;
$objPHPExcel = new PHPExcel();
@ -139,15 +136,16 @@ $objPHPExcel->setActiveSheetIndex(0);
echo date('H:i:s').' Write to Excel2007 format'.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__).EOL;
echo date('H:i:s').' File written to '.str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)).EOL;
// Save Excel5 file
echo date('H:i:s').' Write to Excel5 format'.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__).EOL;
echo date('H:i:s').' File written to '.str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)).EOL;
// Echo memory peak usage
echo date('H:i:s').' Peak memory usage: '.(memory_get_peak_usage(true) / 1024 / 1024).' MB'.EOL;
// Echo done
echo date('H:i:s').' Done writing file'.EOL;
echo date('H:i:s').' Done writing files'.EOL;
echo 'Files have been created in ' , getcwd() , EOL;

View File

@ -27,6 +27,10 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
@ -35,11 +39,11 @@ require_once '../Classes/PHPExcel.php';
// Create new PHPExcel object
echo date('H:i:s') , " Create new PHPExcel object" , PHP_EOL;
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
$objPHPExcel = new PHPExcel();
// Set document properties
echo date('H:i:s') , " Set document properties" , PHP_EOL;
echo date('H:i:s') , " Set document properties" , EOL;
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
->setLastModifiedBy("Maarten Balliauw")
->setTitle("Office 2007 XLSX Test Document")
@ -50,7 +54,7 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
// Add some data
echo date('H:i:s') , " Add some data" , PHP_EOL;
echo date('H:i:s') , " Add some data" , EOL;
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Hello');
$objPHPExcel->getActiveSheet()->setCellValue('B2', 'world!');
@ -58,19 +62,19 @@ $objPHPExcel->getActiveSheet()->setCellValue('C1', 'Hello');
$objPHPExcel->getActiveSheet()->setCellValue('D2', 'world!');
// Rename worksheet
echo date('H:i:s') , " Rename worksheet" , PHP_EOL;
echo date('H:i:s') , " Rename worksheet" , EOL;
$objPHPExcel->getActiveSheet()->setTitle('Simple');
// Set document security
echo date('H:i:s') , " Set document security" , PHP_EOL;
echo date('H:i:s') , " Set document security" , 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;
echo date('H:i:s') , " Set sheet security" , 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,14 +87,15 @@ $objPHPExcel->setActiveSheetIndex(0);
// Save Excel 2007 file
echo date('H:i:s') , " Write to Excel5 format" , PHP_EOL;
echo date('H:i:s') , " Write to Excel5 format" , 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 date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo done
echo date('H:i:s') , " Done writing file" , PHP_EOL;
echo date('H:i:s') , " Done writing file" , EOL;
echo 'File has been created in ' , getcwd() , EOL;

View File

@ -27,6 +27,10 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
@ -35,11 +39,11 @@ require_once '../Classes/PHPExcel.php';
// Create new PHPExcel object
echo date('H:i:s') , " Create new PHPExcel object" , PHP_EOL;
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
$objPHPExcel = new PHPExcel();
// Set document properties
echo date('H:i:s') , " Set document properties" , PHP_EOL;
echo date('H:i:s') , " Set document properties" , EOL;
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
->setLastModifiedBy("Maarten Balliauw")
->setTitle("Office 2007 XLSX Test Document")
@ -50,7 +54,7 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
// Add some data
echo date('H:i:s') , " Add some data" , PHP_EOL;
echo date('H:i:s') , " Add some data" , EOL;
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Hello');
$objPHPExcel->getActiveSheet()->setCellValue('B2', 'world!');
@ -58,19 +62,19 @@ $objPHPExcel->getActiveSheet()->setCellValue('C1', 'Hello');
$objPHPExcel->getActiveSheet()->setCellValue('D2', 'world!');
// Rename worksheet
echo date('H:i:s') , " Rename worksheet" , PHP_EOL;
echo date('H:i:s') , " Rename worksheet" , EOL;
$objPHPExcel->getActiveSheet()->setTitle('Simple');
// Set document security
echo date('H:i:s') , " Set document security" , PHP_EOL;
echo date('H:i:s') , " Set document security" , 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;
echo date('H:i:s') , " Set sheet security" , 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,14 +87,15 @@ $objPHPExcel->setActiveSheetIndex(0);
// Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , PHP_EOL;
echo date('H:i:s') , " Write to Excel2007 format" , 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 date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo done
echo date('H:i:s') , " Done writing file" , PHP_EOL;
echo date('H:i:s') , " Done writing file" , EOL;
echo 'File has been created in ' , getcwd() , EOL;

View File

@ -27,6 +27,11 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Europe/London');
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
@ -35,177 +40,178 @@ require_once '../Classes/PHPExcel.php';
// List functions
echo date('H:i:s') , " List implemented functions" , PHP_EOL;
echo date('H:i:s') , " List implemented functions" , EOL;
$objCalc = PHPExcel_Calculation::getInstance();
print_r($objCalc->listFunctionNames());
// Create new PHPExcel object
echo date('H:i:s') , " Create new PHPExcel object" , PHP_EOL;
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
$objPHPExcel = new PHPExcel();
// Add some data, we will use some formulas here
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:');
$objPHPExcel->getActiveSheet()->setCellValue('A17', 'Min:');
$objPHPExcel->getActiveSheet()->setCellValue('A18', 'Average:');
$objPHPExcel->getActiveSheet()->setCellValue('A19', 'Median:');
$objPHPExcel->getActiveSheet()->setCellValue('A20', 'Mode:');
echo date('H:i:s') , " Add some data and formulas" , EOL;
$objPHPExcel->getActiveSheet()->setCellValue('A14', 'Count:')
->setCellValue('A15', 'Sum:')
->setCellValue('A16', 'Max:')
->setCellValue('A17', 'Min:')
->setCellValue('A18', 'Average:')
->setCellValue('A19', 'Median:')
->setCellValue('A20', 'Mode:');
$objPHPExcel->getActiveSheet()->setCellValue('A22', 'CountA:');
$objPHPExcel->getActiveSheet()->setCellValue('A23', 'MaxA:');
$objPHPExcel->getActiveSheet()->setCellValue('A24', 'MinA:');
$objPHPExcel->getActiveSheet()->setCellValue('A22', 'CountA:')
->setCellValue('A23', 'MaxA:')
->setCellValue('A24', 'MinA:');
$objPHPExcel->getActiveSheet()->setCellValue('A26', 'StDev:');
$objPHPExcel->getActiveSheet()->setCellValue('A27', 'StDevA:');
$objPHPExcel->getActiveSheet()->setCellValue('A28', 'StDevP:');
$objPHPExcel->getActiveSheet()->setCellValue('A29', 'StDevPA:');
$objPHPExcel->getActiveSheet()->setCellValue('A26', 'StDev:')
->setCellValue('A27', 'StDevA:')
->setCellValue('A28', 'StDevP:')
->setCellValue('A29', 'StDevPA:');
$objPHPExcel->getActiveSheet()->setCellValue('A31', 'DevSq:');
$objPHPExcel->getActiveSheet()->setCellValue('A32', 'Var:');
$objPHPExcel->getActiveSheet()->setCellValue('A33', 'VarA:');
$objPHPExcel->getActiveSheet()->setCellValue('A34', 'VarP:');
$objPHPExcel->getActiveSheet()->setCellValue('A35', 'VarPA:');
$objPHPExcel->getActiveSheet()->setCellValue('A31', 'DevSq:')
->setCellValue('A32', 'Var:')
->setCellValue('A33', 'VarA:')
->setCellValue('A34', 'VarP:')
->setCellValue('A35', 'VarPA:');
$objPHPExcel->getActiveSheet()->setCellValue('A37', 'Date:');
$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', True);
$objPHPExcel->getActiveSheet()->setCellValue('B6', False);
$objPHPExcel->getActiveSheet()->setCellValue('B7', 'Text String');
$objPHPExcel->getActiveSheet()->setCellValue('B9', '22');
$objPHPExcel->getActiveSheet()->setCellValue('B10', 4);
$objPHPExcel->getActiveSheet()->setCellValue('B11', 6);
$objPHPExcel->getActiveSheet()->setCellValue('B12', 12);
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Range 1')
->setCellValue('B2', 2)
->setCellValue('B3', 8)
->setCellValue('B4', 10)
->setCellValue('B5', True)
->setCellValue('B6', False)
->setCellValue('B7', 'Text String')
->setCellValue('B9', '22')
->setCellValue('B10', 4)
->setCellValue('B11', 6)
->setCellValue('B12', 12);
$objPHPExcel->getActiveSheet()->setCellValue('B14', '=COUNT(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B15', '=SUM(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B16', '=MAX(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B17', '=MIN(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B18', '=AVERAGE(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B19', '=MEDIAN(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B20', '=MODE(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B14', '=COUNT(B2:B12)')
->setCellValue('B15', '=SUM(B2:B12)')
->setCellValue('B16', '=MAX(B2:B12)')
->setCellValue('B17', '=MIN(B2:B12)')
->setCellValue('B18', '=AVERAGE(B2:B12)')
->setCellValue('B19', '=MEDIAN(B2:B12)')
->setCellValue('B20', '=MODE(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B22', '=COUNTA(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B23', '=MAXA(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B24', '=MINA(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B22', '=COUNTA(B2:B12)')
->setCellValue('B23', '=MAXA(B2:B12)')
->setCellValue('B24', '=MINA(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B26', '=STDEV(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B27', '=STDEVA(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B28', '=STDEVP(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B29', '=STDEVPA(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B26', '=STDEV(B2:B12)')
->setCellValue('B27', '=STDEVA(B2:B12)')
->setCellValue('B28', '=STDEVP(B2:B12)')
->setCellValue('B29', '=STDEVPA(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B31', '=DEVSQ(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B32', '=VAR(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B33', '=VARA(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B34', '=VARP(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B35', '=VARPA(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B31', '=DEVSQ(B2:B12)')
->setCellValue('B32', '=VAR(B2:B12)')
->setCellValue('B33', '=VARA(B2:B12)')
->setCellValue('B34', '=VARP(B2:B12)')
->setCellValue('B35', '=VARPA(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B37', '=DATE(2007, 12, 21)');
$objPHPExcel->getActiveSheet()->setCellValue('B38', '=DATEDIF( DATE(2007, 12, 21), DATE(2007, 12, 22), "D" )');
$objPHPExcel->getActiveSheet()->setCellValue('B39', '=DATEVALUE("01-Feb-2006 10:06 AM")');
$objPHPExcel->getActiveSheet()->setCellValue('B40', '=DAY( DATE(2006, 1, 2) )');
$objPHPExcel->getActiveSheet()->setCellValue('B41', '=DAYS360( DATE(2002, 2, 3), DATE(2005, 5, 31) )');
$objPHPExcel->getActiveSheet()->setCellValue('B37', '=DATE(2007, 12, 21)')
->setCellValue('B38', '=DATEDIF( DATE(2007, 12, 21), DATE(2007, 12, 22), "D" )')
->setCellValue('B39', '=DATEVALUE("01-Feb-2006 10:06 AM")')
->setCellValue('B40', '=DAY( DATE(2006, 1, 2) )')
->setCellValue('B41', '=DAYS360( DATE(2002, 2, 3), DATE(2005, 5, 31) )');
$objPHPExcel->getActiveSheet()->setCellValue('C1', 'Range 2');
$objPHPExcel->getActiveSheet()->setCellValue('C2', 1);
$objPHPExcel->getActiveSheet()->setCellValue('C3', 2);
$objPHPExcel->getActiveSheet()->setCellValue('C4', 2);
$objPHPExcel->getActiveSheet()->setCellValue('C5', 3);
$objPHPExcel->getActiveSheet()->setCellValue('C6', 3);
$objPHPExcel->getActiveSheet()->setCellValue('C7', 3);
$objPHPExcel->getActiveSheet()->setCellValue('C8', '0');
$objPHPExcel->getActiveSheet()->setCellValue('C9', 4);
$objPHPExcel->getActiveSheet()->setCellValue('C10', 4);
$objPHPExcel->getActiveSheet()->setCellValue('C11', 4);
$objPHPExcel->getActiveSheet()->setCellValue('C12', 4);
$objPHPExcel->getActiveSheet()->setCellValue('C1', 'Range 2')
->setCellValue('C2', 1)
->setCellValue('C3', 2)
->setCellValue('C4', 2)
->setCellValue('C5', 3)
->setCellValue('C6', 3)
->setCellValue('C7', 3)
->setCellValue('C8', '0')
->setCellValue('C9', 4)
->setCellValue('C10', 4)
->setCellValue('C11', 4)
->setCellValue('C12', 4);
$objPHPExcel->getActiveSheet()->setCellValue('C14', '=COUNT(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C15', '=SUM(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C16', '=MAX(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C17', '=MIN(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C18', '=AVERAGE(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C19', '=MEDIAN(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C20', '=MODE(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C14', '=COUNT(C2:C12)')
->setCellValue('C15', '=SUM(C2:C12)')
->setCellValue('C16', '=MAX(C2:C12)')
->setCellValue('C17', '=MIN(C2:C12)')
->setCellValue('C18', '=AVERAGE(C2:C12)')
->setCellValue('C19', '=MEDIAN(C2:C12)')
->setCellValue('C20', '=MODE(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C22', '=COUNTA(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C23', '=MAXA(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C24', '=MINA(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C22', '=COUNTA(C2:C12)')
->setCellValue('C23', '=MAXA(C2:C12)')
->setCellValue('C24', '=MINA(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C26', '=STDEV(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C27', '=STDEVA(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C28', '=STDEVP(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C29', '=STDEVPA(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C26', '=STDEV(C2:C12)')
->setCellValue('C27', '=STDEVA(C2:C12)')
->setCellValue('C28', '=STDEVP(C2:C12)')
->setCellValue('C29', '=STDEVPA(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C31', '=DEVSQ(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C32', '=VAR(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C33', '=VARA(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C34', '=VARP(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C35', '=VARPA(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C31', '=DEVSQ(C2:C12)')
->setCellValue('C32', '=VAR(C2:C12)')
->setCellValue('C33', '=VARA(C2:C12)')
->setCellValue('C34', '=VARP(C2:C12)')
->setCellValue('C35', '=VARPA(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('D1', 'Range 3');
$objPHPExcel->getActiveSheet()->setCellValue('D2', 2);
$objPHPExcel->getActiveSheet()->setCellValue('D3', 3);
$objPHPExcel->getActiveSheet()->setCellValue('D4', 4);
$objPHPExcel->getActiveSheet()->setCellValue('D1', 'Range 3')
->setCellValue('D2', 2)
->setCellValue('D3', 3)
->setCellValue('D4', 4);
$objPHPExcel->getActiveSheet()->setCellValue('D14', '=((D2 * D3) + D4) & " should be 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('E12', 'Other functions')
->setCellValue('E14', '=PI()')
->setCellValue('E15', '=RAND()')
->setCellValue('E16', '=RANDBETWEEN(5, 10)');
$objPHPExcel->getActiveSheet()->setCellValue('E17', 'Count of both ranges:');
$objPHPExcel->getActiveSheet()->setCellValue('F17', '=COUNT(B2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('E17', 'Count of both ranges:')
->setCellValue('F17', '=COUNT(B2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('E18', 'Total of both ranges:');
$objPHPExcel->getActiveSheet()->setCellValue('F18', '=SUM(B2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('E18', 'Total of both ranges:')
->setCellValue('F18', '=SUM(B2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('E19', 'Maximum of both ranges:');
$objPHPExcel->getActiveSheet()->setCellValue('F19', '=MAX(B2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('E19', 'Maximum of both ranges:')
->setCellValue('F19', '=MAX(B2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('E20', 'Minimum of both ranges:');
$objPHPExcel->getActiveSheet()->setCellValue('F20', '=MIN(B2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('E20', 'Minimum of both ranges:')
->setCellValue('F20', '=MIN(B2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('E21', 'Average of both ranges:');
$objPHPExcel->getActiveSheet()->setCellValue('F21', '=AVERAGE(B2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('E21', 'Average of both ranges:')
->setCellValue('F21', '=AVERAGE(B2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('E22', 'Median of both ranges:');
$objPHPExcel->getActiveSheet()->setCellValue('F22', '=MEDIAN(B2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('E22', 'Median of both ranges:')
->setCellValue('F22', '=MEDIAN(B2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('E23', 'Mode of both ranges:');
$objPHPExcel->getActiveSheet()->setCellValue('F23', '=MODE(B2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('E23', 'Mode of both ranges:')
->setCellValue('F23', '=MODE(B2:C12)');
// Calculated data
echo date('H:i:s') , " Calculated data" , PHP_EOL;
echo date('H:i:s') , " Calculated data" , 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;
$objPHPExcel->getActiveSheet()->getCell($col.$row)->getCalculatedValue() . EOL;
}
}
}
// Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , PHP_EOL;
echo date('H:i:s') , " Write to Excel2007 format" , 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 date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo done
echo date('H:i:s') , " Done" , PHP_EOL;
echo date('H:i:s') , " Done writing file" , EOL;
echo 'File has been created in ' , getcwd() , EOL;

View File

@ -27,6 +27,10 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
@ -36,14 +40,15 @@ include "05featuredemo.inc.php";
require_once '../Classes/PHPExcel/IOFactory.php';
echo date('H:i:s') , " Write to Excel5 format" , PHP_EOL;
echo date('H:i:s') , " Write to Excel5 format" , 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 date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo done
echo date('H:i:s') , " Done writing files" , PHP_EOL;
echo date('H:i:s') , " Done writing file" , EOL;
echo 'File has been created in ' , getcwd() , EOL;

View File

@ -27,6 +27,11 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Europe/London');
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
@ -35,12 +40,12 @@ require_once '../Classes/PHPExcel.php';
// Create new PHPExcel object
echo date('H:i:s') , " Create new PHPExcel object" , PHP_EOL;
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
$objPHPExcel = new PHPExcel();
// Set document properties
echo date('H:i:s') , " Set document properties" , PHP_EOL;
echo date('H:i:s') , " Set document properties" , EOL;
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
->setLastModifiedBy("Maarten Balliauw")
->setTitle("Office 2007 XLSX Test Document")
@ -51,17 +56,17 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
// Create a first sheet
echo date('H:i:s') , " Add data" , PHP_EOL;
echo date('H:i:s') , " Add data" , 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");
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Cell B3 and B5 contain data validation...")
->setCellValue('A3', "Number:")
->setCellValue('B3', "10")
->setCellValue('A5', "List:")
->setCellValue('B5', "Item A");
// Set data validation
echo date('H:i:s') , " Set data validation" , PHP_EOL;
echo date('H:i:s') , " Set data validation" , EOL;
$objValidation = $objPHPExcel->getActiveSheet()->getCell('B3')->getDataValidation();
$objValidation->setType( PHPExcel_Cell_DataValidation::TYPE_WHOLE );
$objValidation->setErrorStyle( PHPExcel_Cell_DataValidation::STYLE_STOP );
@ -94,14 +99,15 @@ $objPHPExcel->setActiveSheetIndex(0);
// Save Excel 2007 file
echo date('H:i:s') , " Write to Excel5 format" , PHP_EOL;
echo date('H:i:s') , " Write to Excel5 format" , 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 date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo done
echo date('H:i:s') , " Done writing file" , PHP_EOL;
echo date('H:i:s') , " Done writing file" , EOL;
echo 'File has been created in ' , getcwd() , EOL;

View File

@ -27,6 +27,11 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Europe/London');
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
@ -35,12 +40,12 @@ require_once '../Classes/PHPExcel.php';
// Create new PHPExcel object
echo date('H:i:s') , " Create new PHPExcel object" , PHP_EOL;
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
$objPHPExcel = new PHPExcel();
// Set document properties
echo date('H:i:s') , " Set document properties" , PHP_EOL;
echo date('H:i:s') , " Set document properties" , EOL;
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
->setLastModifiedBy("Maarten Balliauw")
->setTitle("Office 2007 XLSX Test Document")
@ -51,17 +56,17 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
// Create a first sheet
echo date('H:i:s') , " Add data" , PHP_EOL;
echo date('H:i:s') , " Add data" , 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");
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Cell B3 and B5 contain data validation...")
->setCellValue('A3', "Number:")
->setCellValue('B3', "10")
->setCellValue('A5', "List:")
->setCellValue('B5', "Item A");
// Set data validation
echo date('H:i:s') , " Set data validation" , PHP_EOL;
echo date('H:i:s') , " Set data validation" , EOL;
$objValidation = $objPHPExcel->getActiveSheet()->getCell('B3')->getDataValidation();
$objValidation->setType( PHPExcel_Cell_DataValidation::TYPE_WHOLE );
$objValidation->setErrorStyle( PHPExcel_Cell_DataValidation::STYLE_STOP );
@ -94,14 +99,15 @@ $objPHPExcel->setActiveSheetIndex(0);
// Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , PHP_EOL;
echo date('H:i:s') , " Write to Excel2007 format" , 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 date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo done
echo date('H:i:s') , " Done writing file" , PHP_EOL;
echo date('H:i:s') , " Done writing file" , EOL;
echo 'File has been created in ' , getcwd() , EOL;

View File

@ -27,6 +27,11 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Europe/London');
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
@ -36,31 +41,32 @@ include "05featuredemo.inc.php";
require_once '../Classes/PHPExcel/IOFactory.php';
echo date('H:i:s') , " Write to CSV format" , PHP_EOL;
echo date('H:i:s') , " Write to CSV format" , 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') , " File written to " , str_replace('.php', '.csv', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo date('H:i:s') , " Read from CSV format" , PHP_EOL;
echo date('H:i:s') , " Read from CSV format" , 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') , " File read from " , str_replace('.php', '.csv', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo date('H:i:s') , " Write to Excel2007 format" , PHP_EOL;
echo date('H:i:s') , " Write to Excel2007 format" , 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 date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo done
echo date('H:i:s') , " Done writing files" , PHP_EOL;
echo date('H:i:s') , " Done writing files" , EOL;
echo 'Files have been created in ' , getcwd() , EOL;

View File

@ -27,6 +27,11 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Europe/London');
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
@ -36,16 +41,17 @@ include "05featuredemo.inc.php";
require_once '../Classes/PHPExcel/IOFactory.php';
echo date('H:i:s') , " Write to HTML format" , PHP_EOL;
echo date('H:i:s') , " Write to HTML format" , 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 date('H:i:s') , " File written to " , str_replace('.php', '.htm', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo done
echo date('H:i:s') , " Done writing files" , PHP_EOL;
echo date('H:i:s') , " Done writing file" , EOL;
echo 'File has been created in ' , getcwd() , EOL;

View File

@ -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,13 +20,18 @@
*
* @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##
*/
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Europe/London');
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
@ -46,28 +51,6 @@ $objPHPExcel = new PHPExcel();
// Add some data, we will use some formulas here
echo date('H:i:s') . " Add some data\n";
$objPHPExcel->getActiveSheet()->setCellValue('A14', 'Count:');
$objPHPExcel->getActiveSheet()->setCellValue('A15', 'Sum:');
$objPHPExcel->getActiveSheet()->setCellValue('A16', 'Max:');
$objPHPExcel->getActiveSheet()->setCellValue('A17', 'Min:');
$objPHPExcel->getActiveSheet()->setCellValue('A18', 'Average:');
$objPHPExcel->getActiveSheet()->setCellValue('A19', 'Median:');
$objPHPExcel->getActiveSheet()->setCellValue('A20', 'Mode:');
$objPHPExcel->getActiveSheet()->setCellValue('A22', 'CountA:');
$objPHPExcel->getActiveSheet()->setCellValue('A23', 'MaxA:');
$objPHPExcel->getActiveSheet()->setCellValue('A24', 'MinA:');
$objPHPExcel->getActiveSheet()->setCellValue('A26', 'StDev:');
$objPHPExcel->getActiveSheet()->setCellValue('A27', 'StDevA:');
$objPHPExcel->getActiveSheet()->setCellValue('A28', 'StDevP:');
$objPHPExcel->getActiveSheet()->setCellValue('A29', 'StDevPA:');
$objPHPExcel->getActiveSheet()->setCellValue('A31', 'DevSq:');
$objPHPExcel->getActiveSheet()->setCellValue('A32', 'Var:');
$objPHPExcel->getActiveSheet()->setCellValue('A33', 'VarA:');
$objPHPExcel->getActiveSheet()->setCellValue('A34', 'VarP:');
$objPHPExcel->getActiveSheet()->setCellValue('A35', 'VarPA:');
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Range 1');
$objPHPExcel->getActiveSheet()->setCellValue('B2', 2);
@ -82,27 +65,6 @@ $objPHPExcel->getActiveSheet()->setCellValue('B11', 6);
$objPHPExcel->getActiveSheet()->setCellValue('B12', 12);
$objPHPExcel->getActiveSheet()->setCellValue('B14', '=COUNT(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B15', '=SUM(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B16', '=MAX(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B17', '=MIN(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B18', '=AVERAGE(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B19', '=MEDIAN(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B20', '=MODE(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B22', '=COUNTA(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B23', '=MAXA(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B24', '=MINA(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B26', '=STDEV(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B27', '=STDEVA(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B28', '=STDEVP(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B29', '=STDEVPA(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B31', '=DEVSQ(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B32', '=VAR(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B33', '=VARA(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B34', '=VARP(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('B35', '=VARPA(B2:B12)');
$objPHPExcel->getActiveSheet()->setCellValue('C1', 'Range 2');
$objPHPExcel->getActiveSheet()->setCellValue('C2', 1);
@ -118,28 +80,6 @@ $objPHPExcel->getActiveSheet()->setCellValue('C11', 4);
$objPHPExcel->getActiveSheet()->setCellValue('C12', 4);
$objPHPExcel->getActiveSheet()->setCellValue('C14', '=COUNT(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C15', '=SUM(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C16', '=MAX(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C17', '=MIN(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C18', '=AVERAGE(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C19', '=MEDIAN(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C20', '=MODE(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C22', '=COUNTA(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C23', '=MAXA(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C24', '=MINA(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C26', '=STDEV(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C27', '=STDEVA(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C28', '=STDEVP(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C29', '=STDEVPA(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C31', '=DEVSQ(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C32', '=VAR(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C33', '=VARA(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C34', '=VARP(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('C35', '=VARPA(C2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('D1', 'Range 3');
$objPHPExcel->getActiveSheet()->setCellValue('D2', 2);
@ -156,76 +96,13 @@ $objPHPExcel->getActiveSheet()->setCellValue('E4', '=RANDBETWEEN(5, 10)');
$objPHPExcel->getActiveSheet()->setCellValue('E14', 'Count of both ranges:');
$objPHPExcel->getActiveSheet()->setCellValue('F14', '=COUNT(B2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('E15', 'Total of both ranges:');
$objPHPExcel->getActiveSheet()->setCellValue('F15', '=SUM(B2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('E16', 'Maximum of both ranges:');
$objPHPExcel->getActiveSheet()->setCellValue('F16', '=MAX(B2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('E17', 'Minimum of both ranges:');
$objPHPExcel->getActiveSheet()->setCellValue('F17', '=MIN(B2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('E18', 'Average of both ranges:');
$objPHPExcel->getActiveSheet()->setCellValue('F18', '=AVERAGE(B2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('E19', 'Median of both ranges:');
$objPHPExcel->getActiveSheet()->setCellValue('F19', '=MEDIAN(B2:C12)');
$objPHPExcel->getActiveSheet()->setCellValue('E20', 'Mode of both ranges:');
$objPHPExcel->getActiveSheet()->setCellValue('F20', '=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 '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 memory peak usage
echo date('H:i:s') . " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB\r\n";
// Echo done
echo date('H:i:s') . " Done.\r\n";
echo date('H:i:s') . " Done" , EOL;

View File

@ -27,6 +27,11 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Europe/London');
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
@ -35,11 +40,11 @@ require_once '../Classes/PHPExcel.php';
// Create new PHPExcel object
echo date('H:i:s') , " Create new PHPExcel object" , PHP_EOL;
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
$objPHPExcel = new PHPExcel();
// Set document properties
echo date('H:i:s') , " Set document properties" , PHP_EOL;
echo date('H:i:s') , " Set document properties" , EOL;
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
->setLastModifiedBy("Maarten Balliauw")
->setTitle("Office 2007 XLSX Test Document")
@ -50,7 +55,7 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
// Add some data
echo date('H:i:s') , " Add some data" , PHP_EOL;
echo date('H:i:s') , " Add some data" , EOL;
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Firstname:')
->setCellValue('A2', 'Lastname:')
@ -60,25 +65,25 @@ $objPHPExcel->getActiveSheet()->setCellValue('A1', 'Firstname:')
->setCellValue('B3', '=B1 & " " & B2');
// Define named ranges
echo date('H:i:s') , " Define named ranges" , PHP_EOL;
echo date('H:i:s') , " Define named ranges" , EOL;
$objPHPExcel->addNamedRange( new PHPExcel_NamedRange('PersonName', $objPHPExcel->getActiveSheet(), 'B1') );
$objPHPExcel->addNamedRange( new PHPExcel_NamedRange('PersonLN', $objPHPExcel->getActiveSheet(), 'B2') );
// Rename named ranges
echo date('H:i:s') , " Rename named ranges" , PHP_EOL;
echo date('H:i:s') , " Rename named ranges" , EOL;
$objPHPExcel->getNamedRange('PersonName')->setName('PersonFN');
// Rename worksheet
echo date('H:i:s') , " Rename worksheet" , PHP_EOL;
echo date('H:i:s') , " Rename worksheet" , EOL;
$objPHPExcel->getActiveSheet()->setTitle('Person');
// Create a new worksheet, after the default sheet
echo date('H:i:s') , " Create new Worksheet object" , PHP_EOL;
echo date('H:i:s') , " Create new Worksheet object" , EOL;
$objPHPExcel->createSheet();
// Add some data to the second sheet, resembling some different data types
echo date('H:i:s') , " Add some data" , PHP_EOL;
echo date('H:i:s') , " Add some data" , EOL;
$objPHPExcel->setActiveSheetIndex(1);
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Firstname:')
->setCellValue('A2', 'Lastname:')
@ -88,13 +93,13 @@ $objPHPExcel->getActiveSheet()->setCellValue('A1', 'Firstname:')
->setCellValue('B3', '=PersonFN & " " & PersonLN');
// Resolve range
echo date('H:i:s') , " Resolve range" , PHP_EOL;
echo 'Cell B1 {=PersonFN}: ' , $objPHPExcel->getActiveSheet()->getCell('B1')->getCalculatedValue() , PHP_EOL;
echo 'Cell B3 {=PersonFN & " " & PersonLN}: ' , $objPHPExcel->getActiveSheet()->getCell('B3')->getCalculatedValue() , PHP_EOL;
echo 'Cell Person!B1: ' , $objPHPExcel->getActiveSheet()->getCell('Person!B1')->getCalculatedValue() , PHP_EOL;
echo date('H:i:s') , " Resolve range" , EOL;
echo 'Cell B1 {=PersonFN}: ' , $objPHPExcel->getActiveSheet()->getCell('B1')->getCalculatedValue() , EOL;
echo 'Cell B3 {=PersonFN & " " & PersonLN}: ' , $objPHPExcel->getActiveSheet()->getCell('B3')->getCalculatedValue() , EOL;
echo 'Cell Person!B1: ' , $objPHPExcel->getActiveSheet()->getCell('Person!B1')->getCalculatedValue() , EOL;
// Rename worksheet
echo date('H:i:s') , " Rename worksheet" , PHP_EOL;
echo date('H:i:s') , " Rename worksheet" , EOL;
$objPHPExcel->getActiveSheet()->setTitle('Person (cloned)');
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
@ -102,14 +107,15 @@ $objPHPExcel->setActiveSheetIndex(0);
// Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , PHP_EOL;
echo date('H:i:s') , " Write to Excel2007 format" , 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 date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo done
echo date('H:i:s') , " Done writing file" , PHP_EOL;
echo date('H:i:s') , " Done writing file" , EOL;
echo 'File has been created in ' , getcwd() , EOL;

View File

@ -27,6 +27,11 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Europe/London');
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
@ -38,17 +43,18 @@ if (!file_exists("14excel5.xls")) {
exit("Please run 14excel5.php first.\n");
}
echo date('H:i:s') , " Load workbook from Excel5 file" , PHP_EOL;
echo date('H:i:s') , " Load workbook from Excel5 file" , EOL;
$objPHPExcel = PHPExcel_IOFactory::load("14excel5.xls");
echo date('H:i:s') , " Write to Excel2007 format" , PHP_EOL;
echo date('H:i:s') , " Write to Excel2007 format" , 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 date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo done
echo date('H:i:s') , " Done reading file" , PHP_EOL;
echo date('H:i:s') , " Done reading file" , EOL;
echo 'File has been created in ' , getcwd() , EOL;

View File

@ -27,6 +27,11 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Europe/London');
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
@ -46,14 +51,14 @@ $rendererLibrary = 'domPDF0.6.0beta3';
$rendererLibraryPath = dirname(__FILE__).'/../../../libraries/PDF/' . $rendererLibrary;
echo date('H:i:s') , " Hide grid lines" , PHP_EOL;
echo date('H:i:s') , " Hide grid lines" , EOL;
$objPHPExcel->getActiveSheet()->setShowGridLines(false);
echo date('H:i:s') , " Set orientation to landscape" , PHP_EOL;
echo date('H:i:s') , " Set orientation to landscape" , EOL;
$objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);
echo date('H:i:s') , " Write to PDF format using {$rendererName}" , PHP_EOL;
echo date('H:i:s') , " Write to PDF format using {$rendererName}" , EOL;
if (!PHPExcel_Settings::setPdfRenderer(
$rendererName,
@ -61,7 +66,7 @@ if (!PHPExcel_Settings::setPdfRenderer(
)) {
die(
'NOTICE: Please set the $rendererName and $rendererLibraryPath values' .
PHP_EOL .
EOL .
'at the top of this script as appropriate for your directory structure'
);
}
@ -70,11 +75,12 @@ if (!PHPExcel_Settings::setPdfRenderer(
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF');
$objWriter->setSheetIndex(0);
$objWriter->save(str_replace('.php', '_'.$rendererName.'.pdf', __FILE__));
echo date('H:i:s') , " File written to " , str_replace('.php', '_'.$rendererName.'.pdf', __FILE__) , PHP_EOL;
echo date('H:i:s') , " File written to " , str_replace('.php', '_'.$rendererName.'.pdf', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo done
echo date('H:i:s') , " Done writing files" , PHP_EOL;
echo date('H:i:s') , " Done writing files" , EOL;
echo 'File has been created in ' , getcwd() , EOL;

View File

@ -27,6 +27,11 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Europe/London');
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
@ -35,11 +40,11 @@ require_once '../Classes/PHPExcel.php';
// Create new PHPExcel object
echo date('H:i:s') , " Create new PHPExcel object" , PHP_EOL;
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
$objPHPExcel = new PHPExcel();
// Set document properties
echo date('H:i:s') , " Set document properties" , PHP_EOL;
echo date('H:i:s') , " Set document properties" , EOL;
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
->setLastModifiedBy("Maarten Balliauw")
->setTitle("Office 2007 XLSX Test Document")
@ -50,7 +55,7 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
// Add some data
echo date('H:i:s') , " Add some data" , PHP_EOL;
echo date('H:i:s') , " Add some data" , EOL;
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->getStyle('A1:T100')->applyFromArray(
@ -74,14 +79,15 @@ $objPHPExcel->getActiveSheet()->getStyle('C5:R95')->applyFromArray(
);
// Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , PHP_EOL;
echo date('H:i:s') , " Write to Excel2007 format" , 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 date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo done
echo date('H:i:s') , " Done writing file" , PHP_EOL;
echo date('H:i:s') , " Done writing file" , EOL;
echo 'File has been created in ' , getcwd() , EOL;

View File

@ -27,6 +27,11 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Europe/London');
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
@ -35,11 +40,11 @@ require_once '../Classes/PHPExcel.php';
// Create new PHPExcel object
echo date('H:i:s') , " Create new PHPExcel object" , PHP_EOL;
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
$objPHPExcel = new PHPExcel();
// Set document properties
echo date('H:i:s') , " Set document properties" , PHP_EOL;
echo date('H:i:s') , " Set document properties" , EOL;
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
->setLastModifiedBy("Maarten Balliauw")
->setTitle("Office 2007 XLSX Test Document")
@ -50,7 +55,7 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
// Add some data
echo date('H:i:s') , " Add some data" , PHP_EOL;
echo date('H:i:s') , " Add some data" , EOL;
$objPHPExcel->setActiveSheetIndex(0);
$sharedStyle1 = new PHPExcel_Style();
@ -82,14 +87,15 @@ $objPHPExcel->getActiveSheet()->setSharedStyle($sharedStyle1, "A1:T100");
$objPHPExcel->getActiveSheet()->setSharedStyle($sharedStyle2, "C5:R95");
// Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , PHP_EOL;
echo date('H:i:s') , " Write to Excel2007 format" , 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 date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo done
echo date('H:i:s') , " Done writing file" , PHP_EOL;
echo date('H:i:s') , " Done writing file" , EOL;
echo 'File has been created in ' , getcwd() , EOL;

View File

@ -26,6 +26,10 @@
*/
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
@ -51,22 +55,23 @@ class MyReadFilter implements PHPExcel_Reader_IReadFilter
}
echo date('H:i:s') , " Load from Excel2007 file" , PHP_EOL;
echo date('H:i:s') , " Load from Excel2007 file" , EOL;
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objReader->setReadFilter( new MyReadFilter() );
$objPHPExcel = $objReader->load("06largescale.xlsx");
echo date('H:i:s') , " Remove unnecessary rows" , PHP_EOL;
echo date('H:i:s') , " Remove unnecessary rows" , EOL;
$objPHPExcel->getActiveSheet()->removeRow(2, 18);
echo date('H:i:s') , " Write to Excel2007 format" , PHP_EOL;
echo date('H:i:s') , " Write to Excel2007 format" , 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 date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo done
echo date('H:i:s') , " Done writing files" , PHP_EOL;
echo date('H:i:s') , " Done writing file" , EOL;
echo 'File has been created in ' , getcwd() , EOL;

View File

@ -27,6 +27,10 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
@ -35,11 +39,11 @@ require_once '../Classes/PHPExcel.php';
// Create new PHPExcel object
echo date('H:i:s') , " Create new PHPExcel object" , PHP_EOL;
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
$objPHPExcel = new PHPExcel();
// Set document properties
echo date('H:i:s') , " Set document properties" , PHP_EOL;
echo date('H:i:s') , " Set document properties" , EOL;
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
->setLastModifiedBy("Maarten Balliauw")
->setTitle("Office 2007 XLSX Test Document")
@ -49,13 +53,13 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
->setCategory("Test result file");
// Generate an image
echo date('H:i:s') , " Generate an image" , PHP_EOL;
echo date('H:i:s') , " Generate an image" , EOL;
$gdImage = @imagecreatetruecolor(120, 20) or die('Cannot Initialize new GD image stream');
$textColor = imagecolorallocate($gdImage, 255, 255, 255);
imagestring($gdImage, 1, 5, 5, 'Created with PHPExcel', $textColor);
// Add a drawing to the worksheet
echo date('H:i:s') , " Add a drawing to the worksheet" , PHP_EOL;
echo date('H:i:s') , " Add a drawing to the worksheet" , EOL;
$objDrawing = new PHPExcel_Worksheet_MemoryDrawing();
$objDrawing->setName('Sample image');
$objDrawing->setDescription('Sample image');
@ -65,14 +69,15 @@ $objDrawing->setMimeType(PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_DEFAULT);
$objDrawing->setHeight(36);
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
echo date('H:i:s') , " Write to Excel2007 format" , PHP_EOL;
echo date('H:i:s') , " Write to Excel2007 format" , 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 date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo done
echo date('H:i:s') , " Done writing files" , PHP_EOL;
echo date('H:i:s') , " Done writing file" , EOL;
echo 'File has been created in ' , getcwd() , EOL;

View File

@ -27,6 +27,10 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
@ -46,32 +50,32 @@ $rendererLibraryPath = dirname(__FILE__).'/../../../libraries/PDF/' . $rendererL
// Read from Excel2007 (.xlsx) template
echo date('H:i:s') , " Load Excel2007 template file" , PHP_EOL;
echo date('H:i:s') , " Load Excel2007 template file" , EOL;
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objPHPExcel = $objReader->load("templates/26template.xlsx");
/** at this point, we could do some manipulations with the template, but we skip this step */
// Export to Excel2007 (.xlsx)
echo date('H:i:s') , " Write to Excel5 format" , PHP_EOL;
echo date('H:i:s') , " Write to Excel5 format" , 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 date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Export to Excel5 (.xls)
echo date('H:i:s') , " Write to Excel5 format" , PHP_EOL;
echo date('H:i:s') , " Write to Excel5 format" , 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 date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Export to HTML (.html)
echo date('H:i:s') , " Write to HTML format" , PHP_EOL;
echo date('H:i:s') , " Write to HTML format" , EOL;
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'HTML');
$objWriter->save(str_replace('.php', '.htm', __FILE__));
echo date('H:i:s') , " File written to " , str_replace('.php', '.htm', __FILE__) , PHP_EOL;
echo date('H:i:s') , " File written to " , str_replace('.php', '.htm', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Export to PDF (.pdf)
echo date('H:i:s') , " Write to PDF format" , PHP_EOL;
echo date('H:i:s') , " Write to PDF format" , EOL;
try {
if (!PHPExcel_Settings::setPdfRenderer(
$rendererName,
@ -79,38 +83,40 @@ try {
)) {
echo (
'NOTICE: Please set the $rendererName and $rendererLibraryPath values' .
PHP_EOL .
'at the top of this script as appropriate for your directory structure'
EOL .
'at the top of this script as appropriate for your directory structure' .
EOL
);
} else {
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF');
$objWriter->save(str_replace('.php', '.pdf', __FILE__));
echo date('H:i:s') , " File written to " , str_replace('.php', '.pdf', __FILE__) , PHP_EOL;
echo date('H:i:s') , " File written to " , str_replace('.php', '.pdf', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
}
} catch (Exception $e) {
echo date('H:i:s') , ' EXCEPTION: ', $e->getMessage() , PHP_EOL;
echo date('H:i:s') , ' EXCEPTION: ', $e->getMessage() , EOL;
}
// Remove first two rows with field headers before exporting to CSV
echo date('H:i:s') , " Removing first two heading rows for CSV export" , PHP_EOL;
echo date('H:i:s') , " Removing first two heading rows for CSV export" , EOL;
$objWorksheet = $objPHPExcel->getActiveSheet();
$objWorksheet->removeRow(1, 2);
// Export to CSV (.csv)
echo date('H:i:s') , " Write to CSV format" , PHP_EOL;
echo date('H:i:s') , " Write to CSV format" , EOL;
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'CSV');
$objWriter->save(str_replace('.php', '.csv', __FILE__));
echo date('H:i:s') , " File written to " , str_replace('.php', '.csv', __FILE__) , PHP_EOL;
echo date('H:i:s') , " File written to " , str_replace('.php', '.csv', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Export to CSV with BOM (.csv)
echo date('H:i:s') , " Write to CSV format (with BOM)" , PHP_EOL;
echo date('H:i:s') , " Write to CSV format (with BOM)" , EOL;
$objWriter->setUseBOM(true);
$objWriter->save(str_replace('.php', '-bom.csv', __FILE__));
echo date('H:i:s') , " File written to " , str_replace('.php', '-bom.csv', __FILE__) , PHP_EOL;
echo date('H:i:s') , " File written to " , str_replace('.php', '-bom.csv', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo done
echo date('H:i:s') , " Done writing files" , PHP_EOL;
echo date('H:i:s') , " Done writing files" , EOL;
echo 'Files have been created in ' , getcwd() , EOL;

View File

@ -27,6 +27,10 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
@ -35,25 +39,26 @@ require_once '../Classes/PHPExcel.php';
// Read from Excel5 (.xls) template
echo date('H:i:s') , " Load Excel2007 template file" , PHP_EOL;
echo date('H:i:s') , " Load Excel2007 template file" , EOL;
$objReader = PHPExcel_IOFactory::createReader('Excel5');
$objPHPExcel = $objReader->load("templates/27template.xls");
// Export to Excel2007 (.xlsx)
echo date('H:i:s') , " Write to Excel5 format" , PHP_EOL;
echo date('H:i:s') , " Write to Excel5 format" , 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 date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Export to Excel5 (.xls)
echo date('H:i:s') , " Write to Excel5 format" , PHP_EOL;
echo date('H:i:s') , " Write to Excel5 format" , 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 date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo done
echo date('H:i:s') , " Done writing files" , PHP_EOL;
echo date('H:i:s') , " Done writing files" , EOL;
echo 'Files have been created in ' , getcwd() , EOL;

View File

@ -27,6 +27,10 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
@ -35,25 +39,25 @@ require_once '../Classes/PHPExcel/IOFactory.php';
if (!file_exists("05featuredemo.xlsx")) {
exit("Please run 05featuredemo.php first." . PHP_EOL);
exit("Please run 05featuredemo.php first." . EOL);
}
echo date('H:i:s') , " Load from Excel2007 file" , PHP_EOL;
echo date('H:i:s') , " Load from Excel2007 file" , EOL;
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objPHPExcel = $objReader->load("05featuredemo.xlsx");
echo date('H:i:s') , " Iterate worksheets" , PHP_EOL;
echo date('H:i:s') , " Iterate worksheets" , EOL;
foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
echo 'Worksheet - ' , $worksheet->getTitle() , PHP_EOL;
echo 'Worksheet - ' , $worksheet->getTitle() , EOL;
foreach ($worksheet->getRowIterator() as $row) {
echo ' Row number - ' , $row->getRowIndex() , PHP_EOL;
echo ' Row number - ' , $row->getRowIndex() , EOL;
$cellIterator = $row->getCellIterator();
$cellIterator->setIterateOnlyExistingCells(false); // Loop all cells, even if it is not set
foreach ($cellIterator as $cell) {
if (!is_null($cell)) {
echo ' Cell - ' , $cell->getCoordinate() , ' - ' , $cell->getCalculatedValue() , PHP_EOL;
echo ' Cell - ' , $cell->getCoordinate() , ' - ' , $cell->getCalculatedValue() , EOL;
}
}
}
@ -61,4 +65,4 @@ foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;

View File

@ -27,27 +27,29 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Europe/London');
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
/** PHPExcel */
require_once '../Classes/PHPExcel.php';
// Set timezone
echo date('H:i:s') , " Set timezone" , PHP_EOL;
echo date('H:i:s') , " Set timezone" , EOL;
date_default_timezone_set('UTC');
// Set value binder
echo date('H:i:s') , " Set value binder" , PHP_EOL;
echo date('H:i:s') , " Set value binder" , EOL;
PHPExcel_Cell::setValueBinder( new PHPExcel_Cell_AdvancedValueBinder() );
// Create new PHPExcel object
echo date('H:i:s') , " Create new PHPExcel object" , PHP_EOL;
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
$objPHPExcel = new PHPExcel();
// Set document properties
echo date('H:i:s') , " Set document properties" , PHP_EOL;
echo date('H:i:s') , " Set document properties" , EOL;
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
->setLastModifiedBy("Maarten Balliauw")
->setTitle("Office 2007 XLSX Test Document")
@ -57,82 +59,85 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
->setCategory("Test result file");
// Set default font
echo date('H:i:s') , " Set default font" , PHP_EOL;
echo date('H:i:s') , " Set default font" , EOL;
$objPHPExcel->getActiveSheet()->getDefaultStyle()->getFont()->setName('Arial');
$objPHPExcel->getActiveSheet()->getDefaultStyle()->getFont()->setSize(10);
// Set column widths
echo date('H:i:s') , " Set column widths" , PHP_EOL;
echo date('H:i:s') , " Set column widths" , EOL;
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(14);
// Add some data, resembling some different data types
echo date('H:i:s') , " Add some data" , PHP_EOL;
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'String value:');
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Mark Baker');
echo date('H:i:s') , " Add some data" , EOL;
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'String value:')
->setCellValue('B1', 'Mark Baker');
$objPHPExcel->getActiveSheet()->setCellValue('A2', 'Numeric value #1:');
$objPHPExcel->getActiveSheet()->setCellValue('B2', 12345);
$objPHPExcel->getActiveSheet()->setCellValue('A2', 'Numeric value #1:')
->setCellValue('B2', 12345);
$objPHPExcel->getActiveSheet()->setCellValue('A3', 'Numeric value #2:');
$objPHPExcel->getActiveSheet()->setCellValue('B3', -12.345);
$objPHPExcel->getActiveSheet()->setCellValue('A3', 'Numeric value #2:')
->setCellValue('B3', -12.345);
$objPHPExcel->getActiveSheet()->setCellValue('A4', 'Numeric value #3:');
$objPHPExcel->getActiveSheet()->setCellValue('B4', .12345);
$objPHPExcel->getActiveSheet()->setCellValue('A4', 'Numeric value #3:')
->setCellValue('B4', .12345);
$objPHPExcel->getActiveSheet()->setCellValue('A5', 'Numeric value #4:');
$objPHPExcel->getActiveSheet()->setCellValue('B5', '12345');
$objPHPExcel->getActiveSheet()->setCellValue('A5', 'Numeric value #4:')
->setCellValue('B5', '12345');
$objPHPExcel->getActiveSheet()->setCellValue('A6', 'Numeric value #5:');
$objPHPExcel->getActiveSheet()->setCellValue('B6', '1.2345');
$objPHPExcel->getActiveSheet()->setCellValue('A6', 'Numeric value #5:')
->setCellValue('B6', '1.2345');
$objPHPExcel->getActiveSheet()->setCellValue('A7', 'Numeric value #6:');
$objPHPExcel->getActiveSheet()->setCellValue('B7', '.12345');
$objPHPExcel->getActiveSheet()->setCellValue('A7', 'Numeric value #6:')
->setCellValue('B7', '.12345');
$objPHPExcel->getActiveSheet()->setCellValue('A8', 'Numeric value #7:');
$objPHPExcel->getActiveSheet()->setCellValue('B8', '1.234e-5');
$objPHPExcel->getActiveSheet()->setCellValue('A8', 'Numeric value #7:')
->setCellValue('B8', '1.234e-5');
$objPHPExcel->getActiveSheet()->setCellValue('A9', 'Numeric value #8:');
$objPHPExcel->getActiveSheet()->setCellValue('B9', '-1.234e+5');
$objPHPExcel->getActiveSheet()->setCellValue('A9', 'Numeric value #8:')
->setCellValue('B9', '-1.234e+5');
$objPHPExcel->getActiveSheet()->setCellValue('A10', 'Boolean value:');
$objPHPExcel->getActiveSheet()->setCellValue('B10', true);
$objPHPExcel->getActiveSheet()->setCellValue('A10', 'Boolean value:')
->setCellValue('B10', true);
$objPHPExcel->getActiveSheet()->setCellValue('A11', 'Percentage value #1:');
$objPHPExcel->getActiveSheet()->setCellValue('B11', '10%');
$objPHPExcel->getActiveSheet()->setCellValue('A11', 'Percentage value #1:')
->setCellValue('B11', '10%');
$objPHPExcel->getActiveSheet()->setCellValue('A12', 'Percentage value #2:');
$objPHPExcel->getActiveSheet()->setCellValue('B12', '12.5%');
$objPHPExcel->getActiveSheet()->setCellValue('A12', 'Percentage value #2:')
->setCellValue('B12', '12.5%');
$objPHPExcel->getActiveSheet()->setCellValue('A13', 'Date value #1:');
$objPHPExcel->getActiveSheet()->setCellValue('B13', '21 December 1983');
$objPHPExcel->getActiveSheet()->setCellValue('A13', 'Currency value:')
->setCellValue('B13', '$12345');
$objPHPExcel->getActiveSheet()->setCellValue('A14', 'Date value #2:');
$objPHPExcel->getActiveSheet()->setCellValue('B14', '19-Dec-1960');
$objPHPExcel->getActiveSheet()->setCellValue('A14', 'Date value #1:')
->setCellValue('B14', '21 December 1983');
$objPHPExcel->getActiveSheet()->setCellValue('A15', 'Date value #3:');
$objPHPExcel->getActiveSheet()->setCellValue('B15', '19/12/1960');
$objPHPExcel->getActiveSheet()->setCellValue('A15', 'Date value #2:')
->setCellValue('B15', '19-Dec-1960');
$objPHPExcel->getActiveSheet()->setCellValue('A16', 'Date value #4:');
$objPHPExcel->getActiveSheet()->setCellValue('B16', '19-12-1960');
$objPHPExcel->getActiveSheet()->setCellValue('A16', 'Date value #3:')
->setCellValue('B16', '19/12/1960');
$objPHPExcel->getActiveSheet()->setCellValue('A17', 'Date value #5:');
$objPHPExcel->getActiveSheet()->setCellValue('B17', '1-Jan');
$objPHPExcel->getActiveSheet()->setCellValue('A17', 'Date value #4:')
->setCellValue('B17', '19-12-1960');
$objPHPExcel->getActiveSheet()->setCellValue('A18', 'Time value #1:');
$objPHPExcel->getActiveSheet()->setCellValue('B18', '01:30');
$objPHPExcel->getActiveSheet()->setCellValue('A18', 'Date value #5:')
->setCellValue('B18', '1-Jan');
$objPHPExcel->getActiveSheet()->setCellValue('A19', 'Time value #2:');
$objPHPExcel->getActiveSheet()->setCellValue('B19', '01:30:15');
$objPHPExcel->getActiveSheet()->setCellValue('A19', 'Time value #1:')
->setCellValue('B19', '01:30');
$objPHPExcel->getActiveSheet()->setCellValue('A20', 'Date/Time value:');
$objPHPExcel->getActiveSheet()->setCellValue('B20', '19-Dec-1960 01:30');
$objPHPExcel->getActiveSheet()->setCellValue('A20', 'Time value #2:')
->setCellValue('B20', '01:30:15');
$objPHPExcel->getActiveSheet()->setCellValue('A21', 'Formula:');
$objPHPExcel->getActiveSheet()->setCellValue('B21', '=SUM(B2:B9)');
$objPHPExcel->getActiveSheet()->setCellValue('A21', 'Date/Time value:')
->setCellValue('B21', '19-Dec-1960 01:30');
$objPHPExcel->getActiveSheet()->setCellValue('A22', 'Formula:')
->setCellValue('B22', '=SUM(B2:B9)');
// Rename worksheet
echo date('H:i:s') , " Rename worksheet" , PHP_EOL;
echo date('H:i:s') , " Rename worksheet" , EOL;
$objPHPExcel->getActiveSheet()->setTitle('Advanced value binder');
@ -141,14 +146,15 @@ $objPHPExcel->setActiveSheetIndex(0);
// Save Excel 2007 file
echo date('H:i:s') , " Write to Excel5 format" , PHP_EOL;
echo date('H:i:s') , " Write to Excel5 format" , 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 date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo done
echo date('H:i:s') , " Done writing file" , PHP_EOL;
echo date('H:i:s') , " Done writing file" , EOL;
echo 'File has been created in ' , getcwd() , EOL;

View File

@ -27,6 +27,10 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
@ -35,14 +39,14 @@ require_once '../Classes/PHPExcel/IOFactory.php';
echo date('H:i:s') , " Load from Excel5 template" , PHP_EOL;
echo date('H:i:s') , " Load from Excel5 template" , EOL;
$objReader = PHPExcel_IOFactory::createReader('Excel5');
$objPHPExcel = $objReader->load("templates/30template.xls");
echo date('H:i:s') , " Add new data to the template" , PHP_EOL;
echo date('H:i:s') , " Add new data to the template" , EOL;
$data = array(array('title' => 'Excel for dummies',
'price' => 17.99,
'quantity' => 2
@ -64,23 +68,24 @@ foreach($data as $r => $dataRow) {
$row = $baseRow + $r;
$objPHPExcel->getActiveSheet()->insertNewRowBefore($row,1);
$objPHPExcel->getActiveSheet()->setCellValue('A'.$row, $r+1);
$objPHPExcel->getActiveSheet()->setCellValue('B'.$row, $dataRow['title']);
$objPHPExcel->getActiveSheet()->setCellValue('C'.$row, $dataRow['price']);
$objPHPExcel->getActiveSheet()->setCellValue('D'.$row, $dataRow['quantity']);
$objPHPExcel->getActiveSheet()->setCellValue('E'.$row, '=C'.$row.'*D'.$row);
$objPHPExcel->getActiveSheet()->setCellValue('A'.$row, $r+1)
->setCellValue('B'.$row, $dataRow['title'])
->setCellValue('C'.$row, $dataRow['price'])
->setCellValue('D'.$row, $dataRow['quantity'])
->setCellValue('E'.$row, '=C'.$row.'*D'.$row);
}
$objPHPExcel->getActiveSheet()->removeRow($baseRow-1,1);
echo date('H:i:s') , " Write to Excel5 format" , PHP_EOL;
echo date('H:i:s') , " Write to Excel5 format" , 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 date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo done
echo date('H:i:s') , " Done writing file" , PHP_EOL;
echo date('H:i:s') , " Done writing file" , EOL;
echo 'File has been created in ' , getcwd() , EOL;

View File

@ -27,6 +27,10 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
@ -38,7 +42,7 @@ $inputFileType = 'Excel5';
$inputFileName = 'templates/31docproperties.xls';
echo date('H:i:s') , " Load Tests from $inputFileType file" , PHP_EOL;
echo date('H:i:s') , " Load Tests from $inputFileType file" , EOL;
$callStartTime = microtime(true);
$objPHPExcelReader = PHPExcel_IOFactory::createReader($inputFileType);
@ -46,12 +50,12 @@ $objPHPExcel = $objPHPExcelReader->load($inputFileName);
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo 'Call time to read Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , PHP_EOL;
echo 'Call time to read Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
echo date('H:i:s') , " Adjust properties" , PHP_EOL;
echo date('H:i:s') , " Adjust properties" , EOL;
$objPHPExcel->getProperties()->setTitle("Office 95 XLS Test Document")
->setSubject("Office 95 XLS Test Document")
->setDescription("Test XLS document, generated using PHPExcel")
@ -59,57 +63,57 @@ $objPHPExcel->getProperties()->setTitle("Office 95 XLS Test Document")
// Save Excel 95 file
echo date('H:i:s') , " Write to Excel5 format" , PHP_EOL;
echo date('H:i:s') , " Write to Excel5 format" , 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 date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB" , PHP_EOL;
echo date('H:i:s') , " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB" , EOL;
echo PHP_EOL;
echo EOL;
// Reread File
echo date('H:i:s') , " Reread Excel5 file" , PHP_EOL;
echo date('H:i:s') , " Reread Excel5 file" , EOL;
$objPHPExcelRead = PHPExcel_IOFactory::load(str_replace('.php', '.xls', __FILE__));
// Set properties
echo date('H:i:s') , " Get properties" , PHP_EOL;
echo date('H:i:s') , " Get properties" , EOL;
echo 'Core Properties:' , PHP_EOL;
echo ' Created by - ' , $objPHPExcel->getProperties()->getCreator() , PHP_EOL;
echo 'Core Properties:' , EOL;
echo ' Created by - ' , $objPHPExcel->getProperties()->getCreator() , EOL;
echo ' Created on - ' , date('d-M-Y',$objPHPExcel->getProperties()->getCreated()) , ' at ' ,
date('H:i:s',$objPHPExcel->getProperties()->getCreated()) , PHP_EOL;
echo ' Last Modified by - ' , $objPHPExcel->getProperties()->getLastModifiedBy() , PHP_EOL;
date('H:i:s',$objPHPExcel->getProperties()->getCreated()) , EOL;
echo ' Last Modified by - ' , $objPHPExcel->getProperties()->getLastModifiedBy() , EOL;
echo ' Last Modified on - ' , date('d-M-Y',$objPHPExcel->getProperties()->getModified()) , ' at ' ,
date('H:i:s',$objPHPExcel->getProperties()->getModified()) , PHP_EOL;
echo ' Title - ' , $objPHPExcel->getProperties()->getTitle() , PHP_EOL;
echo ' Subject - ' , $objPHPExcel->getProperties()->getSubject() , PHP_EOL;
echo ' Description - ' , $objPHPExcel->getProperties()->getDescription() , PHP_EOL;
echo ' Keywords: - ' , $objPHPExcel->getProperties()->getKeywords() , PHP_EOL;
date('H:i:s',$objPHPExcel->getProperties()->getModified()) , EOL;
echo ' Title - ' , $objPHPExcel->getProperties()->getTitle() , EOL;
echo ' Subject - ' , $objPHPExcel->getProperties()->getSubject() , EOL;
echo ' Description - ' , $objPHPExcel->getProperties()->getDescription() , EOL;
echo ' Keywords: - ' , $objPHPExcel->getProperties()->getKeywords() , EOL;
echo 'Extended (Application) Properties:' , PHP_EOL;
echo ' Category - ' , $objPHPExcel->getProperties()->getCategory() , PHP_EOL;
echo ' Company - ' , $objPHPExcel->getProperties()->getCompany() , PHP_EOL;
echo ' Manager - ' , $objPHPExcel->getProperties()->getManager() , PHP_EOL;
echo 'Extended (Application) Properties:' , EOL;
echo ' Category - ' , $objPHPExcel->getProperties()->getCategory() , EOL;
echo ' Company - ' , $objPHPExcel->getProperties()->getCompany() , EOL;
echo ' Manager - ' , $objPHPExcel->getProperties()->getManager() , EOL;
echo 'Custom Properties:' , PHP_EOL;
echo 'Custom Properties:' , EOL;
$customProperties = $objPHPExcel->getProperties()->getCustomProperties();
foreach($customProperties as $customProperty) {
$propertyValue = $objPHPExcel->getProperties()->getCustomPropertyValue($customProperty);
$propertyType = $objPHPExcel->getProperties()->getCustomPropertyType($customProperty);
echo ' ' , $customProperty , ' - (' , $propertyType , ') - ';
if ($propertyType == PHPExcel_DocumentProperties::PROPERTY_TYPE_DATE) {
echo date('d-M-Y H:i:s',$propertyValue) , PHP_EOL;
echo date('d-M-Y H:i:s',$propertyValue) , EOL;
} elseif ($propertyType == PHPExcel_DocumentProperties::PROPERTY_TYPE_BOOLEAN) {
echo (($propertyValue) ? 'TRUE' : 'FALSE') , PHP_EOL;
echo (($propertyValue) ? 'TRUE' : 'FALSE') , EOL;
} else {
echo $propertyValue , PHP_EOL;
echo $propertyValue , EOL;
}
}
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) . " MB" , PHP_EOL;
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) . " MB" , EOL;

View File

@ -27,6 +27,10 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
@ -38,7 +42,7 @@ $inputFileType = 'Excel2007';
$inputFileName = 'templates/31docproperties.xlsx';
echo date('H:i:s') , " Load Tests from $inputFileType file" , PHP_EOL;
echo date('H:i:s') , " Load Tests from $inputFileType file" , EOL;
$callStartTime = microtime(true);
$objPHPExcelReader = PHPExcel_IOFactory::createReader($inputFileType);
@ -46,12 +50,12 @@ $objPHPExcel = $objPHPExcelReader->load($inputFileName);
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo 'Call time to read Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , PHP_EOL;
echo 'Call time to read Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
echo date('H:i:s') , " Adjust properties" , PHP_EOL;
echo date('H:i:s') , " Adjust properties" , EOL;
$objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document")
->setSubject("Office 2007 XLSX Test Document")
->setDescription("Test XLSX document, generated using PHPExcel")
@ -59,57 +63,57 @@ $objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document")
// Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , PHP_EOL;
echo date('H:i:s') , " Write to Excel2007 format" , 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 date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB" , PHP_EOL;
echo date('H:i:s') , " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB" , EOL;
echo PHP_EOL;
echo EOL;
// Reread File
echo date('H:i:s') , " Reread Excel2007 file" , PHP_EOL;
echo date('H:i:s') , " Reread Excel2007 file" , EOL;
$objPHPExcelRead = PHPExcel_IOFactory::load(str_replace('.php', '.xlsx', __FILE__));
// Set properties
echo date('H:i:s') , " Get properties" , PHP_EOL;
echo date('H:i:s') , " Get properties" , EOL;
echo 'Core Properties:' , PHP_EOL;
echo ' Created by - ' , $objPHPExcel->getProperties()->getCreator() , PHP_EOL;
echo 'Core Properties:' , EOL;
echo ' Created by - ' , $objPHPExcel->getProperties()->getCreator() , EOL;
echo ' Created on - ' , date('d-M-Y',$objPHPExcel->getProperties()->getCreated()) , ' at ' ,
date('H:i:s',$objPHPExcel->getProperties()->getCreated()) , PHP_EOL;
echo ' Last Modified by - ' , $objPHPExcel->getProperties()->getLastModifiedBy() , PHP_EOL;
date('H:i:s',$objPHPExcel->getProperties()->getCreated()) , EOL;
echo ' Last Modified by - ' , $objPHPExcel->getProperties()->getLastModifiedBy() , EOL;
echo ' Last Modified on - ' , date('d-M-Y',$objPHPExcel->getProperties()->getModified()) , ' at ' ,
date('H:i:s',$objPHPExcel->getProperties()->getModified()) , PHP_EOL;
echo ' Title - ' , $objPHPExcel->getProperties()->getTitle() , PHP_EOL;
echo ' Subject - ' , $objPHPExcel->getProperties()->getSubject() , PHP_EOL;
echo ' Description - ' , $objPHPExcel->getProperties()->getDescription() , PHP_EOL;
echo ' Keywords: - ' , $objPHPExcel->getProperties()->getKeywords() , PHP_EOL;
date('H:i:s',$objPHPExcel->getProperties()->getModified()) , EOL;
echo ' Title - ' , $objPHPExcel->getProperties()->getTitle() , EOL;
echo ' Subject - ' , $objPHPExcel->getProperties()->getSubject() , EOL;
echo ' Description - ' , $objPHPExcel->getProperties()->getDescription() , EOL;
echo ' Keywords: - ' , $objPHPExcel->getProperties()->getKeywords() , EOL;
echo 'Extended (Application) Properties:' , PHP_EOL;
echo ' Category - ' , $objPHPExcel->getProperties()->getCategory() , PHP_EOL;
echo ' Company - ' , $objPHPExcel->getProperties()->getCompany() , PHP_EOL;
echo ' Manager - ' , $objPHPExcel->getProperties()->getManager() , PHP_EOL;
echo 'Extended (Application) Properties:' , EOL;
echo ' Category - ' , $objPHPExcel->getProperties()->getCategory() , EOL;
echo ' Company - ' , $objPHPExcel->getProperties()->getCompany() , EOL;
echo ' Manager - ' , $objPHPExcel->getProperties()->getManager() , EOL;
echo 'Custom Properties:' , PHP_EOL;
echo 'Custom Properties:' , EOL;
$customProperties = $objPHPExcel->getProperties()->getCustomProperties();
foreach($customProperties as $customProperty) {
$propertyValue = $objPHPExcel->getProperties()->getCustomPropertyValue($customProperty);
$propertyType = $objPHPExcel->getProperties()->getCustomPropertyType($customProperty);
echo ' ' , $customProperty , ' - (' , $propertyType , ') - ';
if ($propertyType == PHPExcel_DocumentProperties::PROPERTY_TYPE_DATE) {
echo date('d-M-Y H:i:s',$propertyValue) , PHP_EOL;
echo date('d-M-Y H:i:s',$propertyValue) , EOL;
} elseif ($propertyType == PHPExcel_DocumentProperties::PROPERTY_TYPE_BOOLEAN) {
echo (($propertyValue) ? 'TRUE' : 'FALSE') , PHP_EOL;
echo (($propertyValue) ? 'TRUE' : 'FALSE') , EOL;
} else {
echo $propertyValue , PHP_EOL;
echo $propertyValue , EOL;
}
}
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) . " MB" , PHP_EOL;
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) . " MB" , EOL;

View File

@ -2,6 +2,11 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Europe/London');
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
@ -52,25 +57,25 @@ foreach($inputFileNames as $inputFileName) {
$inputFileNameShort = basename($inputFileName);
if (!file_exists($inputFileName)) {
echo date('H:i:s') , " File " , $inputFileNameShort , ' does not exist' , PHP_EOL;
echo date('H:i:s') , " File " , $inputFileNameShort , ' does not exist' , EOL;
continue;
}
echo date('H:i:s') , " Load Test from $inputFileType file " , $inputFileNameShort , PHP_EOL;
echo date('H:i:s') , " Load Test from $inputFileType file " , $inputFileNameShort , EOL;
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objReader->setIncludeCharts(TRUE);
$objPHPExcel = $objReader->load($inputFileName);
echo date('H:i:s') , " Iterate worksheets looking at the charts" , PHP_EOL;
echo date('H:i:s') , " Iterate worksheets looking at the charts" , EOL;
foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
$sheetName = $worksheet->getTitle();
echo 'Worksheet: ' , $sheetName , PHP_EOL;
echo 'Worksheet: ' , $sheetName , EOL;
$chartNames = $worksheet->getChartNames();
if(empty($chartNames)) {
echo ' There are no charts in this worksheet' , PHP_EOL;
echo ' There are no charts in this worksheet' , EOL;
} else {
natsort($chartNames);
foreach($chartNames as $i => $chartName) {
@ -80,12 +85,12 @@ foreach($inputFileNames as $inputFileName) {
} else {
$caption = 'Untitled';
}
echo ' ' , $chartName , ' - ' , $caption , PHP_EOL;
echo ' ' , $chartName , ' - ' , $caption , EOL;
echo str_repeat(' ',strlen($chartName)+3);
$groupCount = $chart->getPlotArea()->getPlotGroupCount();
if ($groupCount == 1) {
$chartType = $chart->getPlotArea()->getPlotGroupByIndex(0)->getPlotType();
echo ' ' , $chartType , PHP_EOL;
echo ' ' , $chartType , EOL;
} else {
$chartTypes = array();
for($i = 0; $i < $groupCount; ++$i) {
@ -94,11 +99,11 @@ foreach($inputFileNames as $inputFileName) {
$chartTypes = array_unique($chartTypes);
if (count($chartTypes) == 1) {
$chartType = 'Multiple Plot ' . array_pop($chartTypes);
echo ' ' , $chartType , PHP_EOL;
echo ' ' , $chartType , EOL;
} elseif (count($chartTypes) == 0) {
echo ' *** Type not yet implemented' , PHP_EOL;
echo ' *** Type not yet implemented' , EOL;
} else {
echo ' Combination Chart' , PHP_EOL;
echo ' Combination Chart' , EOL;
}
}
}
@ -108,18 +113,19 @@ foreach($inputFileNames as $inputFileName) {
$outputFileName = basename($inputFileName);
echo date('H:i:s') , " Write Tests to Excel2007 file " , PHP_EOL;
echo date('H:i:s') , " Write Tests to Excel2007 file " , EOL;
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->setIncludeCharts(TRUE);
$objWriter->save($outputFileName);
echo date('H:i:s') , " File written to " , $outputFileName , PHP_EOL;
echo date('H:i:s') , " File written to " , $outputFileName , EOL;
$objPHPExcel->disconnectWorksheets();
unset($objPHPExcel);
}
// Echo memory peak usage
echo date('H:i:s') , ' Peak memory usage: ' , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
echo date('H:i:s') , ' Peak memory usage: ' , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo done
echo date('H:i:s') , " Done writing files" , PHP_EOL;
echo date('H:i:s') , " Done writing files" , EOL;
echo 'Files have been created in ' , getcwd() , EOL;

View File

@ -2,6 +2,11 @@
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Europe/London');
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
@ -28,7 +33,7 @@ date_default_timezone_set('Europe/London');
* @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 1.7.7, 2012-05-19
* @version ##VERSION##, ##DATE##
*/
/** Include path **/
@ -50,16 +55,34 @@ $objWorksheet->fromArray(
);
// Set the Labels for each data series we want to plot
// Datatype
// Cell reference for data
// Format Code
// Number of datapoints in series
// Data values
// Data Marker
$dataseriesLabels = array(
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$B$1', null, 1), // 2010
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 2011
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$D$1', null, 1), // 2012
);
// Set the X-Axis Labels
// Datatype
// Cell reference for data
// Format Code
// Number of datapoints in series
// Data values
// Data Marker
$xAxisTickValues = array(
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4
);
// Set the Data values for each data series we want to plot
// Datatype
// Cell reference for data
// Format Code
// Number of datapoints in series
// Data values
// Data Marker
$dataSeriesValues = array(
new PHPExcel_Chart_DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', null, 4),
new PHPExcel_Chart_DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', null, 4),
@ -76,6 +99,7 @@ $series = new PHPExcel_Chart_DataSeries(
$dataSeriesValues // plotValues
);
// Set additional dataseries parameters
// Make it a vertical column rather than a horizontal bar graph
$series->setPlotDirection(PHPExcel_Chart_DataSeries::DIRECTION_COL);
// Set the series in the plot area
@ -108,15 +132,16 @@ $objWorksheet->addChart($chart);
// Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , PHP_EOL;
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->setIncludeCharts(TRUE);
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', __FILE__) , PHP_EOL;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo done
echo date('H:i:s') , " Done writing file" , PHP_EOL;
echo date('H:i:s') , " Done writing file" , EOL;
echo 'File has been created in ' , getcwd() , EOL;

81
Tests/34chartupdate.php Normal file
View File

@ -0,0 +1,81 @@
<?php
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Europe/London');
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
/**
* 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##
*/
/** Include path **/
set_include_path(get_include_path() . PATH_SEPARATOR . '../Classes/');
/** PHPExcel */
include 'PHPExcel.php';
if (!file_exists("33chartcreate.xlsx")) {
exit("Please run 33chartcreate.php first." . EOL);
}
echo date('H:i:s') , " Load from Excel2007 file" , EOL;
$objReader = PHPExcel_IOFactory::createReader("Excel2007");
$objReader->setIncludeCharts(TRUE);
$objPHPExcel = $objReader->load("33chartcreate.xlsx");
echo date('H:i:s') , " Update cell data values that are displayed in the chart" , EOL;
$objWorksheet = $objPHPExcel->getActiveSheet();
$objWorksheet->fromArray(
array(
array(50-12, 50-15, 50-21),
array(50-56, 50-73, 50-86),
array(50-52, 50-61, 50-69),
array(50-30, 50-32, 50),
),
NULL,
'B2'
);
// Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->setIncludeCharts(TRUE);
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo done
echo date('H:i:s') , " Done writing file" , EOL;
echo 'File has been created in ' , getcwd() , EOL;

View File

@ -79,6 +79,10 @@ Fixed in develop branch:
- Feature: (MBaker) Initial version of HTML Reader
- Feature: (Progi1984) & (blazzy) Work items 9605 - Implement support for AutoFilter in PHPExcel_Writer_Excel5
- Feature: (MBaker) Modified ERF and ERFC Engineering functions to accept Excel 2010's modified acceptance of negative arguments
- General: (alexgann) Add Currency detection to the Advanced Value Binder
- General: (MBaker) Work item 18404 - setCellValueExplicitByColumnAndRow() do not return PHPExcel_Worksheet
- General: (MBaker) Work item 18324 - Reader factory doesn't read anymore XLTX and XLT files
- General: (MBaker) Magic __toString() method added to Cell object to return raw data value as a string
- Bugfix: (cyberconte) Patch 12318 - OOCalc cells containing <text:span> inside the <text:p> tag
- Bugfix: (schir1964) Fix to listWorksheetInfo() method for OOCalc Reader
- Bugfix: (MBaker) Support for "e" (epoch) date format mask
@ -87,7 +91,17 @@ Fixed in develop branch:
- Bugfix: (MBaker) Work items 15905 and 18183 - Allow "no impact" to formats on Conditional Formatting
- Bugfix: (wackonline) OOCalc Reader fix for NULL cells
- Bugfix: (seltzlab) Fix to excel2007 Chart Writer when a $plotSeriesValues is empty
- Bugfix: (MBaker) Various fixes to Chart handling
- Bugfix: (MBaker) Work item 18370 - Error loading xlsx file with column breaks
- Bugfix: (MBaker) OOCalc Reader now handles percentage and currency data types
- Bugfix: (MBaker) Work Item 18415 - mb_stripos empty delimiter
- Bugfix: (takaakik) Work Item 15455 - getNestingLevel() Error on Excel5 Read
- Bugfix: (MBaker) Fix to Excel5 Reader when cell annotations are defined before their referenced text objects
- Bugfix: (MBaker) OOCalc Reader modified to process number-rows-repeated
- Bugfix: (MBaker) Work item 18377 - Chart Title compatibility on Excel 2007
- Bugfix: (MBaker) Work item 18146 - Chart Refresh returning cell reference rather than values
- Bugfix: (MBaker) Work item 18145 - Autoshape being identified in twoCellAnchor when includeCharts is TRUE triggering load error
- Bugfix: (MBaker) Work item 18325 - v-type texts for series labels now recognised and parsed correctly
2012-05-19 (v1.7.7):

View File

@ -17,7 +17,7 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @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##
**************************************************************************************

View File

@ -1,56 +1,56 @@
<?php
class AutoloaderTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
if (!defined('PHPEXCEL_ROOT'))
{
define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
}
require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
public function testAutoloaderNonPHPExcelClass()
{
$className = 'InvalidClass';
$result = PHPExcel_Autoloader::Load($className);
// Must return a boolean...
$this->assertTrue(is_bool($result));
// ... indicating failure
$this->assertFalse($result);
}
public function testAutoloaderInvalidPHPExcelClass()
{
$className = 'PHPExcel_Invalid_Class';
$result = PHPExcel_Autoloader::Load($className);
// Must return a boolean...
$this->assertTrue(is_bool($result));
// ... indicating failure
$this->assertFalse($result);
}
public function testAutoloadValidPHPExcelClass()
{
$className = 'PHPExcel_IOFactory';
$result = PHPExcel_Autoloader::Load($className);
// Check that class has been loaded
$this->assertTrue(class_exists($className));
}
public function testAutoloadInstantiateSuccess()
{
$result = new PHPExcel_Calculation_Function(1,2,3);
// Must return an object...
$this->assertTrue(is_object($result));
// ... of the correct type
$this->assertTrue(is_a($result,'PHPExcel_Calculation_Function'));
}
<?php
class AutoloaderTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
if (!defined('PHPEXCEL_ROOT'))
{
define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
}
require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
public function testAutoloaderNonPHPExcelClass()
{
$className = 'InvalidClass';
$result = PHPExcel_Autoloader::Load($className);
// Must return a boolean...
$this->assertTrue(is_bool($result));
// ... indicating failure
$this->assertFalse($result);
}
public function testAutoloaderInvalidPHPExcelClass()
{
$className = 'PHPExcel_Invalid_Class';
$result = PHPExcel_Autoloader::Load($className);
// Must return a boolean...
$this->assertTrue(is_bool($result));
// ... indicating failure
$this->assertFalse($result);
}
public function testAutoloadValidPHPExcelClass()
{
$className = 'PHPExcel_IOFactory';
$result = PHPExcel_Autoloader::Load($className);
// Check that class has been loaded
$this->assertTrue(class_exists($className));
}
public function testAutoloadInstantiateSuccess()
{
$result = new PHPExcel_Calculation_Function(1,2,3);
// Must return an object...
$this->assertTrue(is_object($result));
// ... of the correct type
$this->assertTrue(is_a($result,'PHPExcel_Calculation_Function'));
}
}

View File

@ -1,464 +1,464 @@
<?php
require_once 'testDataFileIterator.php';
class DateTimeTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
if (!defined('PHPEXCEL_ROOT'))
{
define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
}
require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* @dataProvider providerDATE
*/
public function testDATE()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','DATE'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerDATE()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/DATE.data');
}
public function testDATEtoPHP()
{
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC);
$result = PHPExcel_Calculation_DateTime::DATE(2012,1,31);
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
$this->assertEquals(1327968000, $result, NULL, 1E-8);
}
public function testDATEtoPHPObject()
{
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT);
$result = PHPExcel_Calculation_DateTime::DATE(2012,1,31);
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
// Must return an object...
$this->assertTrue(is_object($result));
// ... of the correct type
$this->assertTrue(is_a($result,'DateTime'));
// ... with the correct value
$this->assertEquals($result->format('d-M-Y'),'31-Jan-2012');
}
public function testDATEwith1904Calendar()
{
PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_MAC_1904);
$result = PHPExcel_Calculation_DateTime::DATE(1918,11,11);
PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900);
$this->assertEquals($result,5428);
}
public function testDATEwith1904CalendarError()
{
PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_MAC_1904);
$result = PHPExcel_Calculation_DateTime::DATE(1901,1,31);
PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900);
$this->assertEquals($result,'#NUM!');
}
/**
* @dataProvider providerDATEVALUE
*/
public function testDATEVALUE()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','DATEVALUE'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerDATEVALUE()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/DATEVALUE.data');
}
public function testDATEVALUEtoPHP()
{
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC);
$result = PHPExcel_Calculation_DateTime::DATEVALUE('2012-1-31');
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
$this->assertEquals(1327968000, $result, NULL, 1E-8);
}
public function testDATEVALUEtoPHPObject()
{
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT);
$result = PHPExcel_Calculation_DateTime::DATEVALUE('2012-1-31');
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
// Must return an object...
$this->assertTrue(is_object($result));
// ... of the correct type
$this->assertTrue(is_a($result,'DateTime'));
// ... with the correct value
$this->assertEquals($result->format('d-M-Y'),'31-Jan-2012');
}
/**
* @dataProvider providerYEAR
*/
public function testYEAR()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','YEAR'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerYEAR()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/YEAR.data');
}
/**
* @dataProvider providerMONTH
*/
public function testMONTH()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','MONTHOFYEAR'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerMONTH()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/MONTH.data');
}
/**
* @dataProvider providerWEEKNUM
*/
public function testWEEKNUM()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','WEEKOFYEAR'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerWEEKNUM()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/WEEKNUM.data');
}
/**
* @dataProvider providerWEEKDAY
*/
public function testWEEKDAY()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','DAYOFWEEK'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerWEEKDAY()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/WEEKDAY.data');
}
/**
* @dataProvider providerDAY
*/
public function testDAY()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','DAYOFMONTH'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerDAY()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/DAY.data');
}
/**
* @dataProvider providerTIME
*/
public function testTIME()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','TIME'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerTIME()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/TIME.data');
}
public function testTIMEtoPHP()
{
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC);
$result = PHPExcel_Calculation_DateTime::TIME(7,30,20);
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
$this->assertEquals(27020, $result, NULL, 1E-8);
}
public function testTIMEtoPHPObject()
{
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT);
$result = PHPExcel_Calculation_DateTime::TIME(7,30,20);
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
// Must return an object...
$this->assertTrue(is_object($result));
// ... of the correct type
$this->assertTrue(is_a($result,'DateTime'));
// ... with the correct value
$this->assertEquals($result->format('H:i:s'),'07:30:20');
}
/**
* @dataProvider providerTIMEVALUE
*/
public function testTIMEVALUE()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','TIMEVALUE'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerTIMEVALUE()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/TIMEVALUE.data');
}
public function testTIMEVALUEtoPHP()
{
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC);
$result = PHPExcel_Calculation_DateTime::TIMEVALUE('7:30:20');
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
$this->assertEquals(23420, $result, NULL, 1E-8);
}
public function testTIMEVALUEtoPHPObject()
{
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT);
$result = PHPExcel_Calculation_DateTime::TIMEVALUE('7:30:20');
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
// Must return an object...
$this->assertTrue(is_object($result));
// ... of the correct type
$this->assertTrue(is_a($result,'DateTime'));
// ... with the correct value
$this->assertEquals($result->format('H:i:s'),'07:30:20');
}
/**
* @dataProvider providerHOUR
*/
public function testHOUR()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','HOUROFDAY'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerHOUR()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/HOUR.data');
}
/**
* @dataProvider providerMINUTE
*/
public function testMINUTE()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','MINUTEOFHOUR'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerMINUTE()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/MINUTE.data');
}
/**
* @dataProvider providerSECOND
*/
public function testSECOND()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','SECONDOFMINUTE'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerSECOND()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/SECOND.data');
}
/**
* @dataProvider providerNETWORKDAYS
*/
public function testNETWORKDAYS()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','NETWORKDAYS'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerNETWORKDAYS()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/NETWORKDAYS.data');
}
/**
* @dataProvider providerWORKDAY
*/
public function testWORKDAY()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','WORKDAY'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerWORKDAY()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/WORKDAY.data');
}
/**
* @dataProvider providerEDATE
*/
public function testEDATE()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','EDATE'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerEDATE()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/EDATE.data');
}
public function testEDATEtoPHP()
{
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC);
$result = PHPExcel_Calculation_DateTime::EDATE('2012-1-26',-1);
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
$this->assertEquals(1324857600, $result, NULL, 1E-8);
}
public function testEDATEtoPHPObject()
{
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT);
$result = PHPExcel_Calculation_DateTime::EDATE('2012-1-26',-1);
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
// Must return an object...
$this->assertTrue(is_object($result));
// ... of the correct type
$this->assertTrue(is_a($result,'DateTime'));
// ... with the correct value
$this->assertEquals($result->format('d-M-Y'),'26-Dec-2011');
}
/**
* @dataProvider providerEOMONTH
*/
public function testEOMONTH()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','EOMONTH'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerEOMONTH()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/EOMONTH.data');
}
public function testEOMONTHtoPHP()
{
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC);
$result = PHPExcel_Calculation_DateTime::EOMONTH('2012-1-26',-1);
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
$this->assertEquals(1325289600, $result, NULL, 1E-8);
}
public function testEOMONTHtoPHPObject()
{
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT);
$result = PHPExcel_Calculation_DateTime::EOMONTH('2012-1-26',-1);
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
// Must return an object...
$this->assertTrue(is_object($result));
// ... of the correct type
$this->assertTrue(is_a($result,'DateTime'));
// ... with the correct value
$this->assertEquals($result->format('d-M-Y'),'31-Dec-2011');
}
/**
* @dataProvider providerDATEDIF
*/
public function testDATEDIF()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','DATEDIF'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerDATEDIF()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/DATEDIF.data');
}
/**
* @dataProvider providerDAYS360
*/
public function testDAYS360()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','DAYS360'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerDAYS360()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/DAYS360.data');
}
/**
* @dataProvider providerYEARFRAC
*/
public function testYEARFRAC()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','YEARFRAC'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerYEARFRAC()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/YEARFRAC.data');
}
}
<?php
require_once 'testDataFileIterator.php';
class DateTimeTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
if (!defined('PHPEXCEL_ROOT'))
{
define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
}
require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* @dataProvider providerDATE
*/
public function testDATE()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','DATE'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerDATE()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/DATE.data');
}
public function testDATEtoPHP()
{
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC);
$result = PHPExcel_Calculation_DateTime::DATE(2012,1,31);
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
$this->assertEquals(1327968000, $result, NULL, 1E-8);
}
public function testDATEtoPHPObject()
{
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT);
$result = PHPExcel_Calculation_DateTime::DATE(2012,1,31);
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
// Must return an object...
$this->assertTrue(is_object($result));
// ... of the correct type
$this->assertTrue(is_a($result,'DateTime'));
// ... with the correct value
$this->assertEquals($result->format('d-M-Y'),'31-Jan-2012');
}
public function testDATEwith1904Calendar()
{
PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_MAC_1904);
$result = PHPExcel_Calculation_DateTime::DATE(1918,11,11);
PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900);
$this->assertEquals($result,5428);
}
public function testDATEwith1904CalendarError()
{
PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_MAC_1904);
$result = PHPExcel_Calculation_DateTime::DATE(1901,1,31);
PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900);
$this->assertEquals($result,'#NUM!');
}
/**
* @dataProvider providerDATEVALUE
*/
public function testDATEVALUE()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','DATEVALUE'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerDATEVALUE()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/DATEVALUE.data');
}
public function testDATEVALUEtoPHP()
{
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC);
$result = PHPExcel_Calculation_DateTime::DATEVALUE('2012-1-31');
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
$this->assertEquals(1327968000, $result, NULL, 1E-8);
}
public function testDATEVALUEtoPHPObject()
{
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT);
$result = PHPExcel_Calculation_DateTime::DATEVALUE('2012-1-31');
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
// Must return an object...
$this->assertTrue(is_object($result));
// ... of the correct type
$this->assertTrue(is_a($result,'DateTime'));
// ... with the correct value
$this->assertEquals($result->format('d-M-Y'),'31-Jan-2012');
}
/**
* @dataProvider providerYEAR
*/
public function testYEAR()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','YEAR'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerYEAR()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/YEAR.data');
}
/**
* @dataProvider providerMONTH
*/
public function testMONTH()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','MONTHOFYEAR'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerMONTH()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/MONTH.data');
}
/**
* @dataProvider providerWEEKNUM
*/
public function testWEEKNUM()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','WEEKOFYEAR'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerWEEKNUM()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/WEEKNUM.data');
}
/**
* @dataProvider providerWEEKDAY
*/
public function testWEEKDAY()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','DAYOFWEEK'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerWEEKDAY()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/WEEKDAY.data');
}
/**
* @dataProvider providerDAY
*/
public function testDAY()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','DAYOFMONTH'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerDAY()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/DAY.data');
}
/**
* @dataProvider providerTIME
*/
public function testTIME()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','TIME'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerTIME()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/TIME.data');
}
public function testTIMEtoPHP()
{
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC);
$result = PHPExcel_Calculation_DateTime::TIME(7,30,20);
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
$this->assertEquals(27020, $result, NULL, 1E-8);
}
public function testTIMEtoPHPObject()
{
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT);
$result = PHPExcel_Calculation_DateTime::TIME(7,30,20);
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
// Must return an object...
$this->assertTrue(is_object($result));
// ... of the correct type
$this->assertTrue(is_a($result,'DateTime'));
// ... with the correct value
$this->assertEquals($result->format('H:i:s'),'07:30:20');
}
/**
* @dataProvider providerTIMEVALUE
*/
public function testTIMEVALUE()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','TIMEVALUE'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerTIMEVALUE()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/TIMEVALUE.data');
}
public function testTIMEVALUEtoPHP()
{
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC);
$result = PHPExcel_Calculation_DateTime::TIMEVALUE('7:30:20');
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
$this->assertEquals(23420, $result, NULL, 1E-8);
}
public function testTIMEVALUEtoPHPObject()
{
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT);
$result = PHPExcel_Calculation_DateTime::TIMEVALUE('7:30:20');
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
// Must return an object...
$this->assertTrue(is_object($result));
// ... of the correct type
$this->assertTrue(is_a($result,'DateTime'));
// ... with the correct value
$this->assertEquals($result->format('H:i:s'),'07:30:20');
}
/**
* @dataProvider providerHOUR
*/
public function testHOUR()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','HOUROFDAY'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerHOUR()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/HOUR.data');
}
/**
* @dataProvider providerMINUTE
*/
public function testMINUTE()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','MINUTEOFHOUR'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerMINUTE()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/MINUTE.data');
}
/**
* @dataProvider providerSECOND
*/
public function testSECOND()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','SECONDOFMINUTE'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerSECOND()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/SECOND.data');
}
/**
* @dataProvider providerNETWORKDAYS
*/
public function testNETWORKDAYS()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','NETWORKDAYS'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerNETWORKDAYS()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/NETWORKDAYS.data');
}
/**
* @dataProvider providerWORKDAY
*/
public function testWORKDAY()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','WORKDAY'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerWORKDAY()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/WORKDAY.data');
}
/**
* @dataProvider providerEDATE
*/
public function testEDATE()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','EDATE'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerEDATE()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/EDATE.data');
}
public function testEDATEtoPHP()
{
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC);
$result = PHPExcel_Calculation_DateTime::EDATE('2012-1-26',-1);
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
$this->assertEquals(1324857600, $result, NULL, 1E-8);
}
public function testEDATEtoPHPObject()
{
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT);
$result = PHPExcel_Calculation_DateTime::EDATE('2012-1-26',-1);
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
// Must return an object...
$this->assertTrue(is_object($result));
// ... of the correct type
$this->assertTrue(is_a($result,'DateTime'));
// ... with the correct value
$this->assertEquals($result->format('d-M-Y'),'26-Dec-2011');
}
/**
* @dataProvider providerEOMONTH
*/
public function testEOMONTH()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','EOMONTH'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerEOMONTH()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/EOMONTH.data');
}
public function testEOMONTHtoPHP()
{
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC);
$result = PHPExcel_Calculation_DateTime::EOMONTH('2012-1-26',-1);
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
$this->assertEquals(1325289600, $result, NULL, 1E-8);
}
public function testEOMONTHtoPHPObject()
{
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT);
$result = PHPExcel_Calculation_DateTime::EOMONTH('2012-1-26',-1);
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
// Must return an object...
$this->assertTrue(is_object($result));
// ... of the correct type
$this->assertTrue(is_a($result,'DateTime'));
// ... with the correct value
$this->assertEquals($result->format('d-M-Y'),'31-Dec-2011');
}
/**
* @dataProvider providerDATEDIF
*/
public function testDATEDIF()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','DATEDIF'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerDATEDIF()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/DATEDIF.data');
}
/**
* @dataProvider providerDAYS360
*/
public function testDAYS360()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','DAYS360'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerDAYS360()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/DAYS360.data');
}
/**
* @dataProvider providerYEARFRAC
*/
public function testYEARFRAC()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_DateTime','YEARFRAC'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerYEARFRAC()
{
return new testDataFileIterator('rawTestData/Calculation/DateTime/YEARFRAC.data');
}
}

View File

@ -1,274 +1,274 @@
<?php
require_once 'testDataFileIterator.php';
class FunctionsTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
if (!defined('PHPEXCEL_ROOT'))
{
define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
}
require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
public function testDUMMY()
{
$result = PHPExcel_Calculation_Functions::DUMMY();
$this->assertEquals('#Not Yet Implemented', $result);
}
public function testDIV0()
{
$result = PHPExcel_Calculation_Functions::DIV0();
$this->assertEquals('#DIV/0!', $result);
}
public function testNA()
{
$result = PHPExcel_Calculation_Functions::NA();
$this->assertEquals('#N/A', $result);
}
public function testNaN()
{
$result = PHPExcel_Calculation_Functions::NaN();
$this->assertEquals('#NUM!', $result);
}
public function testNAME()
{
$result = PHPExcel_Calculation_Functions::NAME();
$this->assertEquals('#NAME?', $result);
}
public function testREF()
{
$result = PHPExcel_Calculation_Functions::REF();
$this->assertEquals('#REF!', $result);
}
public function testNULL()
{
$result = PHPExcel_Calculation_Functions::NULL();
$this->assertEquals('#NULL!', $result);
}
public function testVALUE()
{
$result = PHPExcel_Calculation_Functions::VALUE();
$this->assertEquals('#VALUE!', $result);
}
/**
* @dataProvider providerIS_BLANK
*/
public function testIS_BLANK()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_BLANK'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerIS_BLANK()
{
return new testDataFileIterator('rawTestData/Calculation/Functions/IS_BLANK.data');
}
/**
* @dataProvider providerIS_ERR
*/
public function testIS_ERR()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_ERR'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerIS_ERR()
{
return new testDataFileIterator('rawTestData/Calculation/Functions/IS_ERR.data');
}
/**
* @dataProvider providerIS_ERROR
*/
public function testIS_ERROR()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_ERROR'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerIS_ERROR()
{
return new testDataFileIterator('rawTestData/Calculation/Functions/IS_ERROR.data');
}
/**
* @dataProvider providerERROR_TYPE
*/
public function testERROR_TYPE()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','ERROR_TYPE'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerERROR_TYPE()
{
return new testDataFileIterator('rawTestData/Calculation/Functions/ERROR_TYPE.data');
}
/**
* @dataProvider providerIS_LOGICAL
*/
public function testIS_LOGICAL()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_LOGICAL'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerIS_LOGICAL()
{
return new testDataFileIterator('rawTestData/Calculation/Functions/IS_LOGICAL.data');
}
/**
* @dataProvider providerIS_NA
*/
public function testIS_NA()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_NA'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerIS_NA()
{
return new testDataFileIterator('rawTestData/Calculation/Functions/IS_NA.data');
}
/**
* @dataProvider providerIS_NUMBER
*/
public function testIS_NUMBER()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_NUMBER'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerIS_NUMBER()
{
return new testDataFileIterator('rawTestData/Calculation/Functions/IS_NUMBER.data');
}
/**
* @dataProvider providerIS_TEXT
*/
public function testIS_TEXT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_TEXT'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerIS_TEXT()
{
return new testDataFileIterator('rawTestData/Calculation/Functions/IS_TEXT.data');
}
/**
* @dataProvider providerIS_NONTEXT
*/
public function testIS_NONTEXT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_NONTEXT'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerIS_NONTEXT()
{
return new testDataFileIterator('rawTestData/Calculation/Functions/IS_NONTEXT.data');
}
/**
* @dataProvider providerIS_EVEN
*/
public function testIS_EVEN()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_EVEN'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerIS_EVEN()
{
return new testDataFileIterator('rawTestData/Calculation/Functions/IS_EVEN.data');
}
/**
* @dataProvider providerIS_ODD
*/
public function testIS_ODD()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_ODD'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerIS_ODD()
{
return new testDataFileIterator('rawTestData/Calculation/Functions/IS_ODD.data');
}
/**
* @dataProvider providerTYPE
*/
public function testTYPE()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','TYPE'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerTYPE()
{
return new testDataFileIterator('rawTestData/Calculation/Functions/TYPE.data');
}
/**
* @dataProvider providerN
*/
public function testN()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','N'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerN()
{
return new testDataFileIterator('rawTestData/Calculation/Functions/N.data');
}
}
<?php
require_once 'testDataFileIterator.php';
class FunctionsTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
if (!defined('PHPEXCEL_ROOT'))
{
define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
}
require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
public function testDUMMY()
{
$result = PHPExcel_Calculation_Functions::DUMMY();
$this->assertEquals('#Not Yet Implemented', $result);
}
public function testDIV0()
{
$result = PHPExcel_Calculation_Functions::DIV0();
$this->assertEquals('#DIV/0!', $result);
}
public function testNA()
{
$result = PHPExcel_Calculation_Functions::NA();
$this->assertEquals('#N/A', $result);
}
public function testNaN()
{
$result = PHPExcel_Calculation_Functions::NaN();
$this->assertEquals('#NUM!', $result);
}
public function testNAME()
{
$result = PHPExcel_Calculation_Functions::NAME();
$this->assertEquals('#NAME?', $result);
}
public function testREF()
{
$result = PHPExcel_Calculation_Functions::REF();
$this->assertEquals('#REF!', $result);
}
public function testNULL()
{
$result = PHPExcel_Calculation_Functions::NULL();
$this->assertEquals('#NULL!', $result);
}
public function testVALUE()
{
$result = PHPExcel_Calculation_Functions::VALUE();
$this->assertEquals('#VALUE!', $result);
}
/**
* @dataProvider providerIS_BLANK
*/
public function testIS_BLANK()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_BLANK'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerIS_BLANK()
{
return new testDataFileIterator('rawTestData/Calculation/Functions/IS_BLANK.data');
}
/**
* @dataProvider providerIS_ERR
*/
public function testIS_ERR()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_ERR'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerIS_ERR()
{
return new testDataFileIterator('rawTestData/Calculation/Functions/IS_ERR.data');
}
/**
* @dataProvider providerIS_ERROR
*/
public function testIS_ERROR()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_ERROR'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerIS_ERROR()
{
return new testDataFileIterator('rawTestData/Calculation/Functions/IS_ERROR.data');
}
/**
* @dataProvider providerERROR_TYPE
*/
public function testERROR_TYPE()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','ERROR_TYPE'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerERROR_TYPE()
{
return new testDataFileIterator('rawTestData/Calculation/Functions/ERROR_TYPE.data');
}
/**
* @dataProvider providerIS_LOGICAL
*/
public function testIS_LOGICAL()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_LOGICAL'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerIS_LOGICAL()
{
return new testDataFileIterator('rawTestData/Calculation/Functions/IS_LOGICAL.data');
}
/**
* @dataProvider providerIS_NA
*/
public function testIS_NA()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_NA'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerIS_NA()
{
return new testDataFileIterator('rawTestData/Calculation/Functions/IS_NA.data');
}
/**
* @dataProvider providerIS_NUMBER
*/
public function testIS_NUMBER()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_NUMBER'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerIS_NUMBER()
{
return new testDataFileIterator('rawTestData/Calculation/Functions/IS_NUMBER.data');
}
/**
* @dataProvider providerIS_TEXT
*/
public function testIS_TEXT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_TEXT'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerIS_TEXT()
{
return new testDataFileIterator('rawTestData/Calculation/Functions/IS_TEXT.data');
}
/**
* @dataProvider providerIS_NONTEXT
*/
public function testIS_NONTEXT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_NONTEXT'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerIS_NONTEXT()
{
return new testDataFileIterator('rawTestData/Calculation/Functions/IS_NONTEXT.data');
}
/**
* @dataProvider providerIS_EVEN
*/
public function testIS_EVEN()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_EVEN'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerIS_EVEN()
{
return new testDataFileIterator('rawTestData/Calculation/Functions/IS_EVEN.data');
}
/**
* @dataProvider providerIS_ODD
*/
public function testIS_ODD()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','IS_ODD'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerIS_ODD()
{
return new testDataFileIterator('rawTestData/Calculation/Functions/IS_ODD.data');
}
/**
* @dataProvider providerTYPE
*/
public function testTYPE()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','TYPE'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerTYPE()
{
return new testDataFileIterator('rawTestData/Calculation/Functions/TYPE.data');
}
/**
* @dataProvider providerN
*/
public function testN()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_Functions','N'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-8);
}
public function providerN()
{
return new testDataFileIterator('rawTestData/Calculation/Functions/N.data');
}
}

View File

@ -1,110 +1,110 @@
<?php
require_once 'testDataFileIterator.php';
class LogicalTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
if (!defined('PHPEXCEL_ROOT'))
{
define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
}
require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
public function testTRUE()
{
$result = PHPExcel_Calculation_Logical::TRUE();
$this->assertEquals(TRUE, $result);
}
public function testFALSE()
{
$result = PHPExcel_Calculation_Logical::FALSE();
$this->assertEquals(FALSE, $result);
}
/**
* @dataProvider providerAND
*/
public function testAND()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_Logical','LOGICAL_AND'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerAND()
{
return new testDataFileIterator('rawTestData/Calculation/Logical/AND.data');
}
/**
* @dataProvider providerOR
*/
public function testOR()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_Logical','LOGICAL_OR'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerOR()
{
return new testDataFileIterator('rawTestData/Calculation/Logical/OR.data');
}
/**
* @dataProvider providerNOT
*/
public function testNOT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_Logical','NOT'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerNOT()
{
return new testDataFileIterator('rawTestData/Calculation/Logical/NOT.data');
}
/**
* @dataProvider providerIF
*/
public function testIF()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_Logical','STATEMENT_IF'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerIF()
{
return new testDataFileIterator('rawTestData/Calculation/Logical/IF.data');
}
/**
* @dataProvider providerIFERROR
*/
public function testIFERROR()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_Logical','IFERROR'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerIFERROR()
{
return new testDataFileIterator('rawTestData/Calculation/Logical/IFERROR.data');
}
}
<?php
require_once 'testDataFileIterator.php';
class LogicalTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
if (!defined('PHPEXCEL_ROOT'))
{
define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
}
require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
public function testTRUE()
{
$result = PHPExcel_Calculation_Logical::TRUE();
$this->assertEquals(TRUE, $result);
}
public function testFALSE()
{
$result = PHPExcel_Calculation_Logical::FALSE();
$this->assertEquals(FALSE, $result);
}
/**
* @dataProvider providerAND
*/
public function testAND()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_Logical','LOGICAL_AND'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerAND()
{
return new testDataFileIterator('rawTestData/Calculation/Logical/AND.data');
}
/**
* @dataProvider providerOR
*/
public function testOR()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_Logical','LOGICAL_OR'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerOR()
{
return new testDataFileIterator('rawTestData/Calculation/Logical/OR.data');
}
/**
* @dataProvider providerNOT
*/
public function testNOT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_Logical','NOT'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerNOT()
{
return new testDataFileIterator('rawTestData/Calculation/Logical/NOT.data');
}
/**
* @dataProvider providerIF
*/
public function testIF()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_Logical','STATEMENT_IF'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerIF()
{
return new testDataFileIterator('rawTestData/Calculation/Logical/IF.data');
}
/**
* @dataProvider providerIFERROR
*/
public function testIFERROR()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_Logical','IFERROR'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerIFERROR()
{
return new testDataFileIterator('rawTestData/Calculation/Logical/IFERROR.data');
}
}

View File

@ -1,484 +1,484 @@
<?php
require_once 'testDataFileIterator.php';
class MathTrigTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
if (!defined('PHPEXCEL_ROOT'))
{
define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
}
require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* @dataProvider providerATAN2
*/
public function testATAN2()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','ATAN2'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerATAN2()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/ATAN2.data');
}
/**
* @dataProvider providerCEILING
*/
public function testCEILING()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','CEILING'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerCEILING()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/CEILING.data');
}
/**
* @dataProvider providerCOMBIN
*/
public function testCOMBIN()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','COMBIN'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerCOMBIN()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/COMBIN.data');
}
/**
* @dataProvider providerEVEN
*/
public function testEVEN()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','EVEN'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerEVEN()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/EVEN.data');
}
/**
* @dataProvider providerODD
*/
public function testODD()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','ODD'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerODD()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/ODD.data');
}
/**
* @dataProvider providerFACT
*/
public function testFACT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','FACT'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerFACT()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/FACT.data');
}
/**
* @dataProvider providerFACTDOUBLE
*/
public function testFACTDOUBLE()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','FACTDOUBLE'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerFACTDOUBLE()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/FACTDOUBLE.data');
}
/**
* @dataProvider providerFLOOR
*/
public function testFLOOR()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','FLOOR'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerFLOOR()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/FLOOR.data');
}
/**
* @dataProvider providerGCD
*/
public function testGCD()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','GCD'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerGCD()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/GCD.data');
}
/**
* @dataProvider providerLCM
*/
public function testLCM()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','LCM'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerLCM()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/LCM.data');
}
/**
* @dataProvider providerINT
*/
public function testINT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','INT'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerINT()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/INT.data');
}
/**
* @dataProvider providerSIGN
*/
public function testSIGN()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','SIGN'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerSIGN()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/SIGN.data');
}
/**
* @dataProvider providerPOWER
*/
public function testPOWER()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','POWER'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerPOWER()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/POWER.data');
}
/**
* @dataProvider providerLOG
*/
public function testLOG()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','LOG_BASE'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerLOG()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/LOG.data');
}
/**
* @dataProvider providerMOD
*/
public function testMOD()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MOD'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerMOD()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/MOD.data');
}
/**
* @dataProvider providerMDETERM
*/
public function testMDETERM()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MDETERM'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerMDETERM()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/MDETERM.data');
}
/**
* @dataProvider providerMINVERSE
*/
public function testMINVERSE()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MINVERSE'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerMINVERSE()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/MINVERSE.data');
}
/**
* @dataProvider providerMMULT
*/
public function testMMULT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MMULT'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerMMULT()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/MMULT.data');
}
/**
* @dataProvider providerMULTINOMIAL
*/
public function testMULTINOMIAL()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MULTINOMIAL'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerMULTINOMIAL()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/MULTINOMIAL.data');
}
/**
* @dataProvider providerMROUND
*/
public function testMROUND()
{
$args = func_get_args();
$expectedResult = array_pop($args);
PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MROUND'),$args);
PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_ARRAY);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerMROUND()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/MROUND.data');
}
/**
* @dataProvider providerPRODUCT
*/
public function testPRODUCT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','PRODUCT'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerPRODUCT()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/PRODUCT.data');
}
/**
* @dataProvider providerQUOTIENT
*/
public function testQUOTIENT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','QUOTIENT'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerQUOTIENT()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/QUOTIENT.data');
}
/**
* @dataProvider providerROUNDUP
*/
public function testROUNDUP()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','ROUNDUP'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerROUNDUP()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/ROUNDUP.data');
}
/**
* @dataProvider providerROUNDDOWN
*/
public function testROUNDDOWN()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','ROUNDDOWN'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerROUNDDOWN()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/ROUNDDOWN.data');
}
/**
* @dataProvider providerSERIESSUM
*/
public function testSERIESSUM()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','SERIESSUM'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerSERIESSUM()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/SERIESSUM.data');
}
/**
* @dataProvider providerSUMSQ
*/
public function testSUMSQ()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','SUMSQ'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerSUMSQ()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/SUMSQ.data');
}
/**
* @dataProvider providerTRUNC
*/
public function testTRUNC()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','TRUNC'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerTRUNC()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/TRUNC.data');
}
/**
* @dataProvider providerROMAN
*/
public function testROMAN()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','ROMAN'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerROMAN()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/ROMAN.data');
}
/**
* @dataProvider providerSQRTPI
*/
public function testSQRTPI()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','SQRTPI'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerSQRTPI()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/SQRTPI.data');
}
}
<?php
require_once 'testDataFileIterator.php';
class MathTrigTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
if (!defined('PHPEXCEL_ROOT'))
{
define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
}
require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* @dataProvider providerATAN2
*/
public function testATAN2()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','ATAN2'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerATAN2()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/ATAN2.data');
}
/**
* @dataProvider providerCEILING
*/
public function testCEILING()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','CEILING'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerCEILING()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/CEILING.data');
}
/**
* @dataProvider providerCOMBIN
*/
public function testCOMBIN()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','COMBIN'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerCOMBIN()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/COMBIN.data');
}
/**
* @dataProvider providerEVEN
*/
public function testEVEN()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','EVEN'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerEVEN()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/EVEN.data');
}
/**
* @dataProvider providerODD
*/
public function testODD()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','ODD'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerODD()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/ODD.data');
}
/**
* @dataProvider providerFACT
*/
public function testFACT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','FACT'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerFACT()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/FACT.data');
}
/**
* @dataProvider providerFACTDOUBLE
*/
public function testFACTDOUBLE()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','FACTDOUBLE'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerFACTDOUBLE()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/FACTDOUBLE.data');
}
/**
* @dataProvider providerFLOOR
*/
public function testFLOOR()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','FLOOR'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerFLOOR()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/FLOOR.data');
}
/**
* @dataProvider providerGCD
*/
public function testGCD()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','GCD'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerGCD()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/GCD.data');
}
/**
* @dataProvider providerLCM
*/
public function testLCM()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','LCM'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerLCM()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/LCM.data');
}
/**
* @dataProvider providerINT
*/
public function testINT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','INT'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerINT()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/INT.data');
}
/**
* @dataProvider providerSIGN
*/
public function testSIGN()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','SIGN'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerSIGN()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/SIGN.data');
}
/**
* @dataProvider providerPOWER
*/
public function testPOWER()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','POWER'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerPOWER()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/POWER.data');
}
/**
* @dataProvider providerLOG
*/
public function testLOG()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','LOG_BASE'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerLOG()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/LOG.data');
}
/**
* @dataProvider providerMOD
*/
public function testMOD()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MOD'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerMOD()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/MOD.data');
}
/**
* @dataProvider providerMDETERM
*/
public function testMDETERM()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MDETERM'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerMDETERM()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/MDETERM.data');
}
/**
* @dataProvider providerMINVERSE
*/
public function testMINVERSE()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MINVERSE'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerMINVERSE()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/MINVERSE.data');
}
/**
* @dataProvider providerMMULT
*/
public function testMMULT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MMULT'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerMMULT()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/MMULT.data');
}
/**
* @dataProvider providerMULTINOMIAL
*/
public function testMULTINOMIAL()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MULTINOMIAL'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerMULTINOMIAL()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/MULTINOMIAL.data');
}
/**
* @dataProvider providerMROUND
*/
public function testMROUND()
{
$args = func_get_args();
$expectedResult = array_pop($args);
PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MROUND'),$args);
PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_ARRAY);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerMROUND()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/MROUND.data');
}
/**
* @dataProvider providerPRODUCT
*/
public function testPRODUCT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','PRODUCT'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerPRODUCT()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/PRODUCT.data');
}
/**
* @dataProvider providerQUOTIENT
*/
public function testQUOTIENT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','QUOTIENT'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerQUOTIENT()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/QUOTIENT.data');
}
/**
* @dataProvider providerROUNDUP
*/
public function testROUNDUP()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','ROUNDUP'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerROUNDUP()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/ROUNDUP.data');
}
/**
* @dataProvider providerROUNDDOWN
*/
public function testROUNDDOWN()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','ROUNDDOWN'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerROUNDDOWN()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/ROUNDDOWN.data');
}
/**
* @dataProvider providerSERIESSUM
*/
public function testSERIESSUM()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','SERIESSUM'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerSERIESSUM()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/SERIESSUM.data');
}
/**
* @dataProvider providerSUMSQ
*/
public function testSUMSQ()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','SUMSQ'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerSUMSQ()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/SUMSQ.data');
}
/**
* @dataProvider providerTRUNC
*/
public function testTRUNC()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','TRUNC'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerTRUNC()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/TRUNC.data');
}
/**
* @dataProvider providerROMAN
*/
public function testROMAN()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','ROMAN'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerROMAN()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/ROMAN.data');
}
/**
* @dataProvider providerSQRTPI
*/
public function testSQRTPI()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','SQRTPI'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-12);
}
public function providerSQRTPI()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/SQRTPI.data');
}
}

View File

@ -1,343 +1,343 @@
<?php
require_once 'testDataFileIterator.php';
class TextDataTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
if (!defined('PHPEXCEL_ROOT'))
{
define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
}
require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* @dataProvider providerCHAR
*/
public function testCHAR()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','CHARACTER'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerCHAR()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/CHAR.data');
}
/**
* @dataProvider providerCODE
*/
public function testCODE()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','ASCIICODE'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerCODE()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/CODE.data');
}
/**
* @dataProvider providerCONCATENATE
*/
public function testCONCATENATE()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','CONCATENATE'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerCONCATENATE()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/CONCATENATE.data');
}
/**
* @dataProvider providerLEFT
*/
public function testLEFT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','LEFT'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerLEFT()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/LEFT.data');
}
/**
* @dataProvider providerMID
*/
public function testMID()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','MID'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerMID()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/MID.data');
}
/**
* @dataProvider providerRIGHT
*/
public function testRIGHT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','RIGHT'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerRIGHT()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/RIGHT.data');
}
/**
* @dataProvider providerLOWER
*/
public function testLOWER()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','LOWERCASE'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerLOWER()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/LOWER.data');
}
/**
* @dataProvider providerUPPER
*/
public function testUPPER()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','UPPERCASE'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerUPPER()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/UPPER.data');
}
/**
* @dataProvider providerPROPER
*/
public function testPROPER()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','PROPERCASE'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerPROPER()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/PROPER.data');
}
/**
* @dataProvider providerLEN
*/
public function testLEN()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','STRINGLENGTH'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerLEN()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/LEN.data');
}
/**
* @dataProvider providerSEARCH
*/
public function testSEARCH()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','SEARCHINSENSITIVE'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerSEARCH()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/SEARCH.data');
}
/**
* @dataProvider providerFIND
*/
public function testFIND()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','SEARCHSENSITIVE'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerFIND()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/FIND.data');
}
/**
* @dataProvider providerREPLACE
*/
public function testREPLACE()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','REPLACE'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerREPLACE()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/REPLACE.data');
}
/**
* @dataProvider providerSUBSTITUTE
*/
public function testSUBSTITUTE()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','SUBSTITUTE'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerSUBSTITUTE()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/SUBSTITUTE.data');
}
/**
* @dataProvider providerTRIM
*/
public function testTRIM()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','TRIMSPACES'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerTRIM()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/TRIM.data');
}
/**
* @dataProvider providerCLEAN
*/
public function testCLEAN()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','TRIMNONPRINTABLE'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerCLEAN()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/CLEAN.data');
}
/**
* @dataProvider providerDOLLAR
*/
public function testDOLLAR()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','DOLLAR'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerDOLLAR()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/DOLLAR.data');
}
/**
* @dataProvider providerFIXED
*/
public function testFIXED()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','FIXEDFORMAT'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerFIXED()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/FIXED.data');
}
/**
* @dataProvider providerT
*/
public function testT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','RETURNSTRING'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerT()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/T.data');
}
/**
* @dataProvider providerTEXT
*/
public function testTEXT()
{
// Enforce decimal and thousands separator values to UK/US, and currency code to USD
call_user_func(array('PHPExcel_Shared_String','setDecimalSeparator'),'.');
call_user_func(array('PHPExcel_Shared_String','setThousandsSeparator'),',');
call_user_func(array('PHPExcel_Shared_String','setCurrencyCode'),'$');
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','TEXTFORMAT'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerTEXT()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/TEXT.data');
}
}
<?php
require_once 'testDataFileIterator.php';
class TextDataTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
if (!defined('PHPEXCEL_ROOT'))
{
define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
}
require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* @dataProvider providerCHAR
*/
public function testCHAR()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','CHARACTER'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerCHAR()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/CHAR.data');
}
/**
* @dataProvider providerCODE
*/
public function testCODE()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','ASCIICODE'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerCODE()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/CODE.data');
}
/**
* @dataProvider providerCONCATENATE
*/
public function testCONCATENATE()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','CONCATENATE'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerCONCATENATE()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/CONCATENATE.data');
}
/**
* @dataProvider providerLEFT
*/
public function testLEFT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','LEFT'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerLEFT()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/LEFT.data');
}
/**
* @dataProvider providerMID
*/
public function testMID()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','MID'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerMID()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/MID.data');
}
/**
* @dataProvider providerRIGHT
*/
public function testRIGHT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','RIGHT'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerRIGHT()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/RIGHT.data');
}
/**
* @dataProvider providerLOWER
*/
public function testLOWER()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','LOWERCASE'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerLOWER()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/LOWER.data');
}
/**
* @dataProvider providerUPPER
*/
public function testUPPER()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','UPPERCASE'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerUPPER()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/UPPER.data');
}
/**
* @dataProvider providerPROPER
*/
public function testPROPER()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','PROPERCASE'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerPROPER()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/PROPER.data');
}
/**
* @dataProvider providerLEN
*/
public function testLEN()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','STRINGLENGTH'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerLEN()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/LEN.data');
}
/**
* @dataProvider providerSEARCH
*/
public function testSEARCH()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','SEARCHINSENSITIVE'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerSEARCH()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/SEARCH.data');
}
/**
* @dataProvider providerFIND
*/
public function testFIND()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','SEARCHSENSITIVE'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerFIND()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/FIND.data');
}
/**
* @dataProvider providerREPLACE
*/
public function testREPLACE()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','REPLACE'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerREPLACE()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/REPLACE.data');
}
/**
* @dataProvider providerSUBSTITUTE
*/
public function testSUBSTITUTE()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','SUBSTITUTE'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerSUBSTITUTE()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/SUBSTITUTE.data');
}
/**
* @dataProvider providerTRIM
*/
public function testTRIM()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','TRIMSPACES'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerTRIM()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/TRIM.data');
}
/**
* @dataProvider providerCLEAN
*/
public function testCLEAN()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','TRIMNONPRINTABLE'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerCLEAN()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/CLEAN.data');
}
/**
* @dataProvider providerDOLLAR
*/
public function testDOLLAR()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','DOLLAR'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerDOLLAR()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/DOLLAR.data');
}
/**
* @dataProvider providerFIXED
*/
public function testFIXED()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','FIXEDFORMAT'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerFIXED()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/FIXED.data');
}
/**
* @dataProvider providerT
*/
public function testT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','RETURNSTRING'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerT()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/T.data');
}
/**
* @dataProvider providerTEXT
*/
public function testTEXT()
{
// Enforce decimal and thousands separator values to UK/US, and currency code to USD
call_user_func(array('PHPExcel_Shared_String','setDecimalSeparator'),'.');
call_user_func(array('PHPExcel_Shared_String','setThousandsSeparator'),',');
call_user_func(array('PHPExcel_Shared_String','setCurrencyCode'),'$');
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_TextData','TEXTFORMAT'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerTEXT()
{
return new testDataFileIterator('rawTestData/Calculation/TextData/TEXT.data');
}
}

View File

@ -0,0 +1,24 @@
<?php
class DataTypeTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
if (!defined('PHPEXCEL_ROOT'))
{
define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
}
require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
public function testGetErrorCodes()
{
$result = call_user_func(array('PHPExcel_Cell_DataType','getErrorCodes'));
$this->assertInternalType('array', $result);
$this->assertGreaterThan(0, count($result));
$this->assertArrayHasKey('#NULL!', $result);
}
}

View File

@ -0,0 +1,88 @@
<?php
class HyperlinkTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
if (!defined('PHPEXCEL_ROOT'))
{
define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
}
require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
public function testGetUrl()
{
$urlValue = 'http://www.phpexcel.net';
$testInstance = new PHPExcel_Cell_Hyperlink($urlValue);
$result = $testInstance->getUrl();
$this->assertEquals($urlValue,$result);
}
public function testSetUrl()
{
$initialUrlValue = 'http://www.phpexcel.net';
$newUrlValue = 'http://github.com/PHPOffice/PHPExcel';
$testInstance = new PHPExcel_Cell_Hyperlink($initialUrlValue);
$result = $testInstance->setUrl($newUrlValue);
$this->assertTrue($result instanceof PHPExcel_Cell_Hyperlink);
$result = $testInstance->getUrl();
$this->assertEquals($newUrlValue,$result);
}
public function testGetTooltip()
{
$tooltipValue = 'PHPExcel Web Site';
$testInstance = new PHPExcel_Cell_Hyperlink(NULL, $tooltipValue);
$result = $testInstance->getTooltip();
$this->assertEquals($tooltipValue,$result);
}
public function testSetTooltip()
{
$initialTooltipValue = 'PHPExcel Web Site';
$newTooltipValue = 'PHPExcel Repository on Github';
$testInstance = new PHPExcel_Cell_Hyperlink(NULL, $initialTooltipValue);
$result = $testInstance->setTooltip($newTooltipValue);
$this->assertTrue($result instanceof PHPExcel_Cell_Hyperlink);
$result = $testInstance->getTooltip();
$this->assertEquals($newTooltipValue,$result);
}
public function testIsInternal()
{
$initialUrlValue = 'http://www.phpexcel.net';
$newUrlValue = 'sheet://Worksheet1!A1';
$testInstance = new PHPExcel_Cell_Hyperlink($initialUrlValue);
$result = $testInstance->isInternal();
$this->assertFalse($result);
$testInstance->setUrl($newUrlValue);
$result = $testInstance->isInternal();
$this->assertTrue($result);
}
public function testGetHashCode()
{
$urlValue = 'http://www.phpexcel.net';
$tooltipValue = 'PHPExcel Web Site';
$initialExpectedHash = 'd84d713aed1dbbc8a7c5af183d6c7dbb';
$testInstance = new PHPExcel_Cell_Hyperlink($urlValue, $tooltipValue);
$result = $testInstance->getHashCode();
$this->assertEquals($initialExpectedHash,$result);
}
}

View File

@ -0,0 +1,295 @@
<?php
require_once 'testDataFileIterator.php';
class CellTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
if (!defined('PHPEXCEL_ROOT')) {
define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
}
require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* @dataProvider providerColumnString
*/
public function testColumnIndexFromString()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Cell','columnIndexFromString'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerColumnString()
{
return new testDataFileIterator('rawTestData/ColumnString.data');
}
public function testColumnIndexFromStringTooLong()
{
$cellAddress = 'ABCD';
try {
$result = call_user_func(array('PHPExcel_Cell','columnIndexFromString'),$cellAddress);
} catch (PHPExcel_Exception $e) {
$this->assertEquals($e->getMessage(), 'Column string index can not be longer than 3 characters');
return;
}
$this->fail('An expected exception has not been raised.');
}
public function testColumnIndexFromStringTooShort()
{
$cellAddress = '';
try {
$result = call_user_func(array('PHPExcel_Cell','columnIndexFromString'),$cellAddress);
} catch (PHPExcel_Exception $e) {
$this->assertEquals($e->getMessage(), 'Column string index can not be empty');
return;
}
$this->fail('An expected exception has not been raised.');
}
/**
* @dataProvider providerColumnIndex
*/
public function testStringFromColumnIndex()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Cell','stringFromColumnIndex'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerColumnIndex()
{
return new testDataFileIterator('rawTestData/ColumnIndex.data');
}
/**
* @dataProvider providerCoordinates
*/
public function testCoordinateFromString()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Cell','coordinateFromString'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerCoordinates()
{
return new testDataFileIterator('rawTestData/CellCoordinates.data');
}
public function testCoordinateFromStringWithRangeAddress()
{
$cellAddress = 'A1:AI2012';
try {
$result = call_user_func(array('PHPExcel_Cell','coordinateFromString'),$cellAddress);
} catch (PHPExcel_Exception $e) {
$this->assertEquals($e->getMessage(), 'Cell coordinate string can not be a range of cells');
return;
}
$this->fail('An expected exception has not been raised.');
}
public function testCoordinateFromStringWithEmptyAddress()
{
$cellAddress = '';
try {
$result = call_user_func(array('PHPExcel_Cell','coordinateFromString'),$cellAddress);
} catch (PHPExcel_Exception $e) {
$this->assertEquals($e->getMessage(), 'Cell coordinate can not be zero-length string');
return;
}
$this->fail('An expected exception has not been raised.');
}
public function testCoordinateFromStringWithInvalidAddress()
{
$cellAddress = 'AI';
try {
$result = call_user_func(array('PHPExcel_Cell','coordinateFromString'),$cellAddress);
} catch (PHPExcel_Exception $e) {
$this->assertEquals($e->getMessage(), 'Invalid cell coordinate '.$cellAddress);
return;
}
$this->fail('An expected exception has not been raised.');
}
/**
* @dataProvider providerAbsoluteCoordinates
*/
public function testAbsoluteCoordinateFromString()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Cell','absoluteCoordinate'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerAbsoluteCoordinates()
{
return new testDataFileIterator('rawTestData/CellAbsoluteCoordinate.data');
}
public function testAbsoluteCoordinateFromStringWithRangeAddress()
{
$cellAddress = 'A1:AI2012';
try {
$result = call_user_func(array('PHPExcel_Cell','absoluteCoordinate'),$cellAddress);
} catch (PHPExcel_Exception $e) {
$this->assertEquals($e->getMessage(), 'Cell coordinate string can not be a range of cells');
return;
}
$this->fail('An expected exception has not been raised.');
}
/**
* @dataProvider providerAbsoluteReferences
*/
public function testAbsoluteReferenceFromString()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Cell','absoluteReference'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerAbsoluteReferences()
{
return new testDataFileIterator('rawTestData/CellAbsoluteReference.data');
}
public function testAbsoluteReferenceFromStringWithRangeAddress()
{
$cellAddress = 'A1:AI2012';
try {
$result = call_user_func(array('PHPExcel_Cell','absoluteReference'),$cellAddress);
} catch (PHPExcel_Exception $e) {
$this->assertEquals($e->getMessage(), 'Cell coordinate string can not be a range of cells');
return;
}
$this->fail('An expected exception has not been raised.');
}
/**
* @dataProvider providerSplitRange
*/
public function testSplitRange()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Cell','splitRange'),$args);
foreach($result as $key => $split) {
if (!is_array($expectedResult[$key])) {
$this->assertEquals($expectedResult[$key], $split[0]);
} else {
$this->assertEquals($expectedResult[$key], $split);
}
}
}
public function providerSplitRange()
{
return new testDataFileIterator('rawTestData/CellSplitRange.data');
}
/**
* @dataProvider providerBuildRange
*/
public function testBuildRange()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Cell','buildRange'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerBuildRange()
{
return new testDataFileIterator('rawTestData/CellBuildRange.data');
}
public function testBuildRangeInvalid()
{
$cellRange = '';
try {
$result = call_user_func(array('PHPExcel_Cell','buildRange'),$cellRange);
} catch (PHPExcel_Exception $e) {
$this->assertEquals($e->getMessage(), 'Range does not contain any information');
return;
}
$this->fail('An expected exception has not been raised.');
}
/**
* @dataProvider providerRangeBoundaries
*/
public function testRangeBoundaries()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Cell','rangeBoundaries'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerRangeBoundaries()
{
return new testDataFileIterator('rawTestData/CellRangeBoundaries.data');
}
/**
* @dataProvider providerRangeDimension
*/
public function testRangeDimension()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Cell','rangeDimension'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerRangeDimension()
{
return new testDataFileIterator('rawTestData/CellRangeDimension.data');
}
/**
* @dataProvider providerGetRangeBoundaries
*/
public function testGetRangeBoundaries()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Cell','getRangeBoundaries'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerGetRangeBoundaries()
{
return new testDataFileIterator('rawTestData/CellGetRangeBoundaries.data');
}
/**
* @dataProvider providerExtractAllCellReferencesInRange
*/
public function testExtractAllCellReferencesInRange()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Cell','extractAllCellReferencesInRange'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerExtractAllCellReferencesInRange()
{
return new testDataFileIterator('rawTestData/CellExtractAllCellReferencesInRange.data');
}
}

View File

@ -46,6 +46,9 @@ class DateTest extends PHPUnit_Framework_TestCase
$args = func_get_args();
$expectedResult = array_pop($args);
if ($args[0] < 1) {
$expectedResult += gmmktime(0,0,0);
}
$result = call_user_func_array(array('PHPExcel_Shared_Date','ExcelToPHP'),$args);
$this->assertEquals($expectedResult, $result);
}
@ -55,6 +58,48 @@ class DateTest extends PHPUnit_Framework_TestCase
return new testDataFileIterator('rawTestData/Shared/DateTimeExcelToPHP1900.data');
}
/**
* @dataProvider providerDateTimePHPToExcel1900
*/
public function testDateTimePHPToExcel1900()
{
$result = call_user_func(
array('PHPExcel_Shared_Date','setExcelCalendar'),
PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900
);
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Shared_Date','PHPToExcel'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-5);
}
public function providerDateTimePHPToExcel1900()
{
return new testDataFileIterator('rawTestData/Shared/DateTimePHPToExcel1900.data');
}
/**
* @dataProvider providerDateTimeFormattedPHPToExcel1900
*/
public function testDateTimeFormattedPHPToExcel1900()
{
$result = call_user_func(
array('PHPExcel_Shared_Date','setExcelCalendar'),
PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900
);
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Shared_Date','FormattedPHPToExcel'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-5);
}
public function providerDateTimeFormattedPHPToExcel1900()
{
return new testDataFileIterator('rawTestData/Shared/DateTimeFormattedPHPToExcel1900.data');
}
/**
* @dataProvider providerDateTimeExcelToPHP1904
*/
@ -67,6 +112,9 @@ class DateTest extends PHPUnit_Framework_TestCase
$args = func_get_args();
$expectedResult = array_pop($args);
if ($args[0] < 1) {
$expectedResult += gmmktime(0,0,0);
}
$result = call_user_func_array(array('PHPExcel_Shared_Date','ExcelToPHP'),$args);
$this->assertEquals($expectedResult, $result);
}
@ -76,6 +124,27 @@ class DateTest extends PHPUnit_Framework_TestCase
return new testDataFileIterator('rawTestData/Shared/DateTimeExcelToPHP1904.data');
}
/**
* @dataProvider providerDateTimePHPToExcel1904
*/
public function testDateTimePHPToExcel1904()
{
$result = call_user_func(
array('PHPExcel_Shared_Date','setExcelCalendar'),
PHPExcel_Shared_Date::CALENDAR_MAC_1904
);
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Shared_Date','PHPToExcel'),$args);
$this->assertEquals($expectedResult, $result, NULL, 1E-5);
}
public function providerDateTimePHPToExcel1904()
{
return new testDataFileIterator('rawTestData/Shared/DateTimePHPToExcel1904.data');
}
/**
* @dataProvider providerIsDateTimeFormatCode
*/

View File

@ -0,0 +1,94 @@
<?php
require_once 'testDataFileIterator.php';
class FontTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
if (!defined('PHPEXCEL_ROOT')) {
define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
}
require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
public function testGetAutoSizeMethod()
{
$expectedResult = PHPExcel_Shared_Font::AUTOSIZE_METHOD_APPROX;
$result = call_user_func(array('PHPExcel_Shared_Font','getAutoSizeMethod'));
$this->assertEquals($expectedResult, $result);
}
public function testSetAutoSizeMethod()
{
$autosizeMethodValues = array(
PHPExcel_Shared_Font::AUTOSIZE_METHOD_EXACT,
PHPExcel_Shared_Font::AUTOSIZE_METHOD_APPROX,
);
foreach($autosizeMethodValues as $autosizeMethodValue) {
$result = call_user_func(array('PHPExcel_Shared_Font','setAutoSizeMethod'),$autosizeMethodValue);
$this->assertTrue($result);
}
}
public function testSetAutoSizeMethodWithInvalidValue()
{
$unsupportedAutosizeMethod = 'guess';
$result = call_user_func(array('PHPExcel_Shared_Font','setAutoSizeMethod'),$unsupportedAutosizeMethod);
$this->assertFalse($result);
}
/**
* @dataProvider providerFontSizeToPixels
*/
public function testFontSizeToPixels()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Shared_Font','fontSizeToPixels'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerFontSizeToPixels()
{
return new testDataFileIterator('rawTestData/Shared/FontSizeToPixels.data');
}
/**
* @dataProvider providerInchSizeToPixels
*/
public function testInchSizeToPixels()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Shared_Font','inchSizeToPixels'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerInchSizeToPixels()
{
return new testDataFileIterator('rawTestData/Shared/InchSizeToPixels.data');
}
/**
* @dataProvider providerCentimeterSizeToPixels
*/
public function testCentimeterSizeToPixels()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Shared_Font','centimeterSizeToPixels'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerCentimeterSizeToPixels()
{
return new testDataFileIterator('rawTestData/Shared/CentimeterSizeToPixels.data');
}
}

View File

@ -0,0 +1,33 @@
<?php
require_once 'testDataFileIterator.php';
class PasswordHasherTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
if (!defined('PHPEXCEL_ROOT')) {
define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
}
require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* @dataProvider providerHashPassword
*/
public function testHashPassword()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Shared_PasswordHasher','hashPassword'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerHashPassword()
{
return new testDataFileIterator('rawTestData/Shared/PasswordHashes.data');
}
}

View File

@ -0,0 +1,81 @@
<?php
require_once 'testDataFileIterator.php';
class ColorTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
if (!defined('PHPEXCEL_ROOT')) {
define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
}
require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* @dataProvider providerColorGetRed
*/
public function testGetRed()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Style_Color','getRed'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerColorGetRed()
{
return new testDataFileIterator('rawTestData/Style/ColorGetRed.data');
}
/**
* @dataProvider providerColorGetGreen
*/
public function testGetGreen()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Style_Color','getGreen'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerColorGetGreen()
{
return new testDataFileIterator('rawTestData/Style/ColorGetGreen.data');
}
/**
* @dataProvider providerColorGetBlue
*/
public function testGetBlue()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Style_Color','getBlue'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerColorGetBlue()
{
return new testDataFileIterator('rawTestData/Style/ColorGetBlue.data');
}
/**
* @dataProvider providerColorChangeBrightness
*/
public function testChangeBrightness()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Style_Color','changeBrightness'),$args);
$this->assertEquals($expectedResult, $result);
}
public function providerColorChangeBrightness()
{
return new testDataFileIterator('rawTestData/Style/ColorChangeBrightness.data');
}
}

View File

@ -2,7 +2,7 @@
/**
* $Id: bootstrap.php 2892 2011-08-14 15:11:50Z markbaker@phpexcel.net $
*
* @copyright Copyright (C) 2011 PHPExcel. All rights reserved.
* @copyright Copyright (C) 2011-2012 PHPExcel. All rights reserved.
* @package PHPExcel
* @subpackage PHPExcel Unit Tests
* @author Mark Baker

View File

@ -17,7 +17,7 @@
<ini name="memory_limit" value="2048M"/>
</php>
<testsuite name="PHPExcel Unit Test Suite">
<directory suffix="Test.php">./PHPExcel</directory>
<directory suffix="Test.php">./Classes</directory>
</testsuite>
<filter>
<whitelist>

View File

@ -9,3 +9,5 @@
"k", "Mark Baker", 5, 8
"a", "Mark Baker", 3, 7
"BITE", "BIT", "#VALUE!"
"", "Mark Baker", 1
"", "Mark Baker", 8, 8

View File

@ -0,0 +1,12 @@
"A1", "$A$1"
"A12", "$A$12"
"J1", "$J$1"
"J20", "$J$20"
"AI1", "$AI$1"
"AI2012", "$AI$2012"
"'Worksheet1'!AI256", "'Worksheet1'!$AI$256"
"Worksheet1!AI256", "Worksheet1!$AI$256"
"'Data Worksheet'!AI256", "'Data Worksheet'!$AI$256"
"'Worksheet1'!$AI256", "'Worksheet1'!$AI$256"
"'Worksheet1'!AI$256", "'Worksheet1'!$AI$256"
"'Worksheet1'!$AI$256", "'Worksheet1'!$AI$256"

View File

@ -0,0 +1,16 @@
"A1", "$A$1"
"A12", "$A$12"
"J1", "$J$1"
"J20", "$J$20"
"AI1", "$AI$1"
"AI2012", "$AI$2012"
"'Worksheet1'!AI256", "'Worksheet1'!$AI$256"
"Worksheet1!AI256", "Worksheet1!$AI$256"
"'Data Worksheet'!AI256", "'Data Worksheet'!$AI$256"
"AI", "$AI"
2012, "$2012"
"Worksheet1!AI", "Worksheet1!$AI"
"Worksheet1!256", "Worksheet1!$256"
"'Worksheet1'!$AI256", "'Worksheet1'!$AI$256"
"'Worksheet1'!AI$256", "'Worksheet1'!$AI$256"
"'Worksheet1'!$AI$256", "'Worksheet1'!$AI$256"

View File

@ -0,0 +1,2 @@
{"B4"|"E9"}, "B4:E9"
{"B4"|"E9";"H2"|"O11"}, '"B4:E9,H2:O11"'

View File

@ -0,0 +1,6 @@
"A1", {"A";1}
"A12", {"A";12}
"J1", {"J";1}
"J20", {"J";20}
"AI1", {"AI";1}
"AI2012", {"AI";2012}

View File

@ -0,0 +1,9 @@
"B4:B6", {"B4";"B5";"B6"}
'"B4:B6,D4:D6"', {"B4";"B5";"B6";"D4";"D5";"D6"}
'"B4:B6 D4:D6"', {"B4";"B5";"B6";"D4";"D5";"D6"}
"B4:D6", {"B4";"B5";"B6";"C4";"C5";"C6";"D4";"D5";"D6"}
'"B4:D6,C5:E7"', {"B4";"B5";"B6";"C4";"C5";"C6";"C7";"D4";"D5";"D6";"D7";"E5";"E6";"E7"}
'"B4:D6 C5:E7"', {"B4";"B5";"B6";"C4";"C5";"C6";"C7";"D4";"D5";"D6";"D7";"E5";"E6";"E7"}
"B2:D4 C5:D5 E3:E5 D6:E6 F4:F6", {"B2";"B3";"B4";"C2";"C3";"C4";"C5";"D2";"D3";"D4";"D5";"D6";"E3";"E4";"E5";"E6";"F4";"F5";"F6"}
"B2:D4 C3:E5 D4:F6", {"B2";"B3";"B4";"C2";"C3";"C4";"C5";"D2";"D3";"D4";"D5";"D6";"E3";"E4";"E5";"E6";"F4";"F5";"F6"}
"B4:B6 B8", {"B4";"B5";"B6";"B8"}

View File

@ -0,0 +1,2 @@
"B4:E9", {"B"|4;"E"|9}
"B4", {"B"|4;"B"|4}

View File

@ -0,0 +1,2 @@
"B4:E9", {2|4;5|9}
"B4", {2|4;2|4}

View File

@ -0,0 +1,2 @@
"B4:E9", {4;6}
"B4", {1;1}

Some files were not shown because too many files have changed in this diff Show More