mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2024-11-30 01:06:03 +03:00
Merge branch 'develop' of https://github.com/PHPOffice/PHPExcel into autofilter
This commit is contained in:
commit
b694241de6
@ -239,9 +239,12 @@ class PHPExcel_Calculation_TextData {
|
|||||||
$haystack = ($haystack) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
|
$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')) {
|
if (function_exists('mb_strpos')) {
|
||||||
$pos = mb_strpos($haystack, $needle, --$offset,'UTF-8');
|
$pos = mb_strpos($haystack, $needle, --$offset, 'UTF-8');
|
||||||
} else {
|
} else {
|
||||||
$pos = strpos($haystack, $needle, --$offset);
|
$pos = strpos($haystack, $needle, --$offset);
|
||||||
}
|
}
|
||||||
@ -272,7 +275,10 @@ class PHPExcel_Calculation_TextData {
|
|||||||
$haystack = ($haystack) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
|
$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')) {
|
if (function_exists('mb_stripos')) {
|
||||||
$pos = mb_stripos($haystack, $needle, --$offset,'UTF-8');
|
$pos = mb_stripos($haystack, $needle, --$offset,'UTF-8');
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,108 +1,112 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2012 PHPExcel
|
* Copyright (c) 2006 - 2012 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
* License as published by the Free Software Foundation; either
|
* License as published by the Free Software Foundation; either
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
* 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,
|
* This library is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* Lesser General Public License for more details.
|
* Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Cell
|
* @package PHPExcel_Cell
|
||||||
* @copyright Copyright (c) 2006 - 2012 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
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel_Cell
|
* PHPExcel_Cell
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Cell
|
* @package PHPExcel_Cell
|
||||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
*/
|
*/
|
||||||
class PHPExcel_Cell
|
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;
|
private $_column;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Row of the cell
|
* Row of the cell
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $_row;
|
private $_row;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Value of the cell
|
* Value of the cell
|
||||||
*
|
*
|
||||||
* @var mixed
|
* @var mixed
|
||||||
*/
|
*/
|
||||||
private $_value;
|
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;
|
private $_dataType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parent worksheet
|
* Parent worksheet
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Worksheet
|
* @var PHPExcel_Worksheet
|
||||||
*/
|
*/
|
||||||
private $_parent;
|
private $_parent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Index to cellXf
|
* Index to cellXf
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $_xfIndex;
|
private $_xfIndex;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attributes of the formula
|
* Attributes of the formula
|
||||||
*
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private $_formulaAttributes;
|
private $_formulaAttributes;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send notification to the cache controller
|
* Send notification to the cache controller
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
**/
|
**/
|
||||||
public function notifyCacheController() {
|
public function notifyCacheController() {
|
||||||
$this->_parent->getCellCacheController()->updateCacheData($this);
|
$this->_parent->getCellCacheController()->updateCacheData($this);
|
||||||
@ -110,7 +114,7 @@ class PHPExcel_Cell
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function detach() {
|
public function detach() {
|
||||||
$this->_parent = null;
|
$this->_parent = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function attach($parent) {
|
public function attach($parent) {
|
||||||
@ -119,16 +123,16 @@ class PHPExcel_Cell
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new Cell
|
* Create a new Cell
|
||||||
*
|
*
|
||||||
* @param string $pColumn
|
* @param string $pColumn
|
||||||
* @param int $pRow
|
* @param int $pRow
|
||||||
* @param mixed $pValue
|
* @param mixed $pValue
|
||||||
* @param string $pDataType
|
* @param string $pDataType
|
||||||
* @param PHPExcel_Worksheet $pSheet
|
* @param PHPExcel_Worksheet $pSheet
|
||||||
* @throws Exception
|
* @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
|
// Initialise cell coordinate
|
||||||
$this->_column = strtoupper($pColumn);
|
$this->_column = strtoupper($pColumn);
|
||||||
@ -141,13 +145,13 @@ class PHPExcel_Cell
|
|||||||
$this->_parent = $pSheet;
|
$this->_parent = $pSheet;
|
||||||
|
|
||||||
// Set datatype?
|
// Set datatype?
|
||||||
if ($pDataType !== null) {
|
if ($pDataType !== NULL) {
|
||||||
if ($pDataType == PHPExcel_Cell_DataType::TYPE_STRING2)
|
if ($pDataType == PHPExcel_Cell_DataType::TYPE_STRING2)
|
||||||
$pDataType = PHPExcel_Cell_DataType::TYPE_STRING;
|
$pDataType = PHPExcel_Cell_DataType::TYPE_STRING;
|
||||||
$this->_dataType = $pDataType;
|
$this->_dataType = $pDataType;
|
||||||
} else {
|
} else {
|
||||||
if (!self::getValueBinder()->bindValue($this, $pValue)) {
|
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()
|
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()
|
public function getRow()
|
||||||
{
|
{
|
||||||
@ -176,9 +180,9 @@ class PHPExcel_Cell
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get cell coordinate
|
* Get cell coordinate
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getCoordinate()
|
public function getCoordinate()
|
||||||
{
|
{
|
||||||
@ -186,9 +190,9 @@ class PHPExcel_Cell
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get cell value
|
* Get cell value
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getValue()
|
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()
|
public function getFormattedValue()
|
||||||
{
|
{
|
||||||
return (string) PHPExcel_Style_NumberFormat::toFormattedString( $this->getCalculatedValue(),
|
return (string) PHPExcel_Style_NumberFormat::toFormattedString(
|
||||||
$this->_parent->getParent()->getCellXfByIndex($this->getXfIndex())->getNumberFormat()->getFormatCode()
|
$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
|
* @param mixed $pValue Value
|
||||||
* @return PHPExcel_Cell
|
* @return PHPExcel_Cell
|
||||||
|
* @throws PHPExcel_Exception
|
||||||
*/
|
*/
|
||||||
public function setValue($pValue = null)
|
public function setValue($pValue = NULL)
|
||||||
{
|
{
|
||||||
if (!self::getValueBinder()->bindValue($this, $pValue)) {
|
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;
|
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 mixed $pValue Value
|
||||||
* @param string $pDataType Explicit data type
|
* @param string $pDataType Explicit data type
|
||||||
* @return PHPExcel_Cell
|
* @return PHPExcel_Cell
|
||||||
* @throws Exception
|
* @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
|
// set the value according to data type
|
||||||
switch ($pDataType) {
|
switch ($pDataType) {
|
||||||
@ -242,25 +249,20 @@ class PHPExcel_Cell
|
|||||||
case PHPExcel_Cell_DataType::TYPE_INLINE:
|
case PHPExcel_Cell_DataType::TYPE_INLINE:
|
||||||
$this->_value = PHPExcel_Cell_DataType::checkString($pValue);
|
$this->_value = PHPExcel_Cell_DataType::checkString($pValue);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PHPExcel_Cell_DataType::TYPE_NUMERIC:
|
case PHPExcel_Cell_DataType::TYPE_NUMERIC:
|
||||||
$this->_value = (float)$pValue;
|
$this->_value = (float)$pValue;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PHPExcel_Cell_DataType::TYPE_FORMULA:
|
case PHPExcel_Cell_DataType::TYPE_FORMULA:
|
||||||
$this->_value = (string)$pValue;
|
$this->_value = (string)$pValue;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PHPExcel_Cell_DataType::TYPE_BOOL:
|
case PHPExcel_Cell_DataType::TYPE_BOOL:
|
||||||
$this->_value = (bool)$pValue;
|
$this->_value = (bool)$pValue;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PHPExcel_Cell_DataType::TYPE_ERROR:
|
case PHPExcel_Cell_DataType::TYPE_ERROR:
|
||||||
$this->_value = PHPExcel_Cell_DataType::checkErrorCode($pValue);
|
$this->_value = PHPExcel_Cell_DataType::checkErrorCode($pValue);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new Exception('Invalid datatype: ' . $pDataType);
|
throw new PHPExcel_Exception('Invalid datatype: ' . $pDataType);
|
||||||
break;
|
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
|
* @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 />';
|
// echo 'Cell '.$this->getCoordinate().' value is a '.$this->_dataType.' with a value of '.$this->getValue().'<br />';
|
||||||
if ($this->_dataType == PHPExcel_Cell_DataType::TYPE_FORMULA) {
|
if ($this->_dataType == PHPExcel_Cell_DataType::TYPE_FORMULA) {
|
||||||
@ -292,7 +295,11 @@ class PHPExcel_Cell
|
|||||||
}
|
}
|
||||||
// echo 'Calculation Exception: '.$ex->getMessage().'<br />';
|
// echo 'Calculation Exception: '.$ex->getMessage().'<br />';
|
||||||
$result = '#N/A';
|
$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') {
|
if ($result === '#Not Yet Implemented') {
|
||||||
@ -305,21 +312,19 @@ class PHPExcel_Cell
|
|||||||
|
|
||||||
// if ($this->_value === NULL) {
|
// if ($this->_value === NULL) {
|
||||||
// echo 'Cell '.$this->getCoordinate().' has no value, formula or otherwise<br />';
|
// 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 />';
|
// echo 'Cell value for '.$this->getCoordinate().' is not a formula: Returning data value of '.$this->_value.'<br />';
|
||||||
return $this->_value;
|
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) {
|
if ($pValue !== NULL) {
|
||||||
$this->_calculatedValue = (is_numeric($pValue)) ? (float) $pValue : $pValue;
|
$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()
|
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()
|
public function getDataType()
|
||||||
{
|
{
|
||||||
@ -349,10 +359,10 @@ class PHPExcel_Cell
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set cell data type
|
* Set cell data type
|
||||||
*
|
*
|
||||||
* @param string $pDataType
|
* @param string $pDataType
|
||||||
* @return PHPExcel_Cell
|
* @return PHPExcel_Cell
|
||||||
*/
|
*/
|
||||||
public function setDataType($pDataType = PHPExcel_Cell_DataType::TYPE_STRING)
|
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()
|
public function hasDataValidation()
|
||||||
{
|
{
|
||||||
if (!isset($this->_parent)) {
|
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());
|
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()
|
public function getDataValidation()
|
||||||
{
|
{
|
||||||
if (!isset($this->_parent)) {
|
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());
|
return $this->_parent->getDataValidation($this->getCoordinate());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Data validation
|
* Set Data validation rules
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Cell_DataValidation $pDataValidation
|
* @param PHPExcel_Cell_DataValidation $pDataValidation
|
||||||
* @throws Exception
|
* @return PHPExcel_Cell
|
||||||
* @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)) {
|
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);
|
$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()
|
public function hasHyperlink()
|
||||||
{
|
{
|
||||||
if (!isset($this->_parent)) {
|
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());
|
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()
|
public function getHyperlink()
|
||||||
{
|
{
|
||||||
if (!isset($this->_parent)) {
|
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());
|
return $this->_parent->getHyperlink($this->getCoordinate());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Hyperlink
|
* Set Hyperlink
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Cell_Hyperlink $pHyperlink
|
* @param PHPExcel_Cell_Hyperlink $pHyperlink
|
||||||
* @throws Exception
|
* @return PHPExcel_Cell
|
||||||
* @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)) {
|
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);
|
$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() {
|
public function getParent() {
|
||||||
return $this->_parent;
|
return $this->_parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Re-bind parent
|
* Re-bind parent
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Worksheet $parent
|
* @param PHPExcel_Worksheet $parent
|
||||||
* @return PHPExcel_Cell
|
* @return PHPExcel_Cell
|
||||||
*/
|
*/
|
||||||
public function rebindParent(PHPExcel_Worksheet $parent) {
|
public function rebindParent(PHPExcel_Worksheet $parent) {
|
||||||
$this->_parent = $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)
|
* @param string $pRange Cell range (e.g. A1:A1)
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function isInRange($pRange = 'A1:A1')
|
public function isInRange($pRange = 'A1:A1')
|
||||||
{
|
{
|
||||||
list($rangeStart,$rangeEnd) = PHPExcel_Cell::rangeBoundaries($pRange);
|
list($rangeStart,$rangeEnd) = self::rangeBoundaries($pRange);
|
||||||
|
|
||||||
// Translate properties
|
// Translate properties
|
||||||
$myColumn = PHPExcel_Cell::columnIndexFromString($this->getColumn());
|
$myColumn = self::columnIndexFromString($this->getColumn());
|
||||||
$myRow = $this->getRow();
|
$myRow = $this->getRow();
|
||||||
|
|
||||||
// Verify if cell is in range
|
// Verify if cell is in range
|
||||||
@ -499,80 +512,91 @@ class PHPExcel_Cell
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Coordinate from string
|
* Coordinate from string
|
||||||
*
|
*
|
||||||
* @param string $pCoordinateString
|
* @param string $pCoordinateString
|
||||||
* @return array Array containing column and row (indexes 0 and 1)
|
* @return array Array containing column and row (indexes 0 and 1)
|
||||||
* @throws Exception
|
* @throws PHPExcel_Exception
|
||||||
*/
|
*/
|
||||||
public static function coordinateFromString($pCoordinateString = 'A1')
|
public static function coordinateFromString($pCoordinateString = 'A1')
|
||||||
{
|
{
|
||||||
if (preg_match("/^([$]?[A-Z]{1,3})([$]?\d{1,7})$/", $pCoordinateString, $matches)) {
|
if (preg_match("/^([$]?[A-Z]{1,3})([$]?\d{1,7})$/", $pCoordinateString, $matches)) {
|
||||||
return array($matches[1],$matches[2]);
|
return array($matches[1],$matches[2]);
|
||||||
} elseif ((strpos($pCoordinateString,':') !== false) || (strpos($pCoordinateString,',') !== false)) {
|
} elseif ((strpos($pCoordinateString,':') !== FALSE) || (strpos($pCoordinateString,',') !== FALSE)) {
|
||||||
throw new Exception('Cell coordinate string can not be a range of cells.');
|
throw new PHPExcel_Exception('Cell coordinate string can not be a range of cells');
|
||||||
} elseif ($pCoordinateString == '') {
|
} elseif ($pCoordinateString == '') {
|
||||||
throw new Exception('Cell coordinate can not be zero-length string.');
|
throw new PHPExcel_Exception('Cell coordinate can not be zero-length string');
|
||||||
} else {
|
|
||||||
throw new Exception('Invalid cell coordinate '.$pCoordinateString);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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'
|
* @param string $pCoordinateString e.g. 'A' or '1' or 'A1'
|
||||||
* @return string Absolute coordinate e.g. '$A' or '$1' or '$A$1'
|
* Note that this value can be a row or column reference as well as a cell reference
|
||||||
* @throws Exception
|
* @return string Absolute coordinate e.g. '$A' or '$1' or '$A$1'
|
||||||
|
* @throws PHPExcel_Exception
|
||||||
*/
|
*/
|
||||||
public static function absoluteReference($pCoordinateString = 'A1')
|
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
|
// Create absolute coordinate
|
||||||
if (ctype_digit($pCoordinateString)) {
|
if (ctype_digit($pCoordinateString)) {
|
||||||
return '$'.$pCoordinateString;
|
return $worksheet . '$' . $pCoordinateString;
|
||||||
} elseif (ctype_alpha($pCoordinateString)) {
|
} elseif (ctype_alpha($pCoordinateString)) {
|
||||||
return '$'.strtoupper($pCoordinateString);
|
return $worksheet . '$' . strtoupper($pCoordinateString);
|
||||||
}
|
}
|
||||||
return self::absoluteCoordinate($pCoordinateString);
|
return $worksheet . self::absoluteCoordinate($pCoordinateString);
|
||||||
} 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');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make string coordinate absolute
|
* Make string coordinate absolute
|
||||||
*
|
*
|
||||||
* @param string $pCoordinateString e.g. 'A1'
|
* @param string $pCoordinateString e.g. 'A1'
|
||||||
* @return string Absolute coordinate e.g. '$A$1'
|
* @return string Absolute coordinate e.g. '$A$1'
|
||||||
* @throws Exception
|
* @throws PHPExcel_Exception
|
||||||
*/
|
*/
|
||||||
public static function absoluteCoordinate($pCoordinateString = 'A1')
|
public static function absoluteCoordinate($pCoordinateString = 'A1')
|
||||||
{
|
{
|
||||||
if (strpos($pCoordinateString,':') === false && strpos($pCoordinateString,',') === false) {
|
if (strpos($pCoordinateString,':') === FALSE && strpos($pCoordinateString,',') === FALSE) {
|
||||||
// Create absolute coordinate
|
// Split out any worksheet name from the coordinate
|
||||||
$worksheet = '';
|
$worksheet = '';
|
||||||
$cellAddress = explode('!',$pCoordinateString);
|
$cellAddress = explode('!',$pCoordinateString);
|
||||||
if (count($cellAddress) == 2) {
|
if (count($cellAddress) > 1) {
|
||||||
list($worksheet,$pCoordinateString) = $cellAddress;
|
list($worksheet,$pCoordinateString) = $cellAddress;
|
||||||
}
|
}
|
||||||
|
if ($worksheet > '') $worksheet .= '!';
|
||||||
|
|
||||||
list($column, $row) = PHPExcel_Cell::coordinateFromString($pCoordinateString);
|
// Create absolute coordinate
|
||||||
if ($column[0] == '$') $column = substr($column,1);
|
list($column, $row) = self::coordinateFromString($pCoordinateString);
|
||||||
if ($row[0] == '$') $row = substr($row,1);
|
$column = ltrim($column,'$');
|
||||||
if ($worksheet > '')
|
$row = ltrim($row,'$');
|
||||||
$worksheet .= '!';
|
|
||||||
return $worksheet . '$' . $column . '$' . $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
|
* @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
|
* @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')
|
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
|
* @param array $pRange Array containg one or more arrays containing one or two coordinate strings
|
||||||
* @return string String representation of $pRange
|
* @return string String representation of $pRange
|
||||||
* @throws Exception
|
* @throws PHPExcel_Exception
|
||||||
*/
|
*/
|
||||||
public static function buildRange($pRange)
|
public static function buildRange($pRange)
|
||||||
{
|
{
|
||||||
// Verify range
|
// Verify range
|
||||||
if (!is_array($pRange) || empty($pRange) || !is_array($pRange[0])) {
|
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
|
// Build range
|
||||||
@ -610,10 +634,11 @@ class PHPExcel_Cell
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate range boundaries
|
* Calculate range boundaries
|
||||||
*
|
*
|
||||||
* @param string $pRange Cell range (e.g. A1:A1)
|
* @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)
|
* @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')
|
public static function rangeBoundaries($pRange = 'A1:A1')
|
||||||
{
|
{
|
||||||
@ -621,42 +646,43 @@ class PHPExcel_Cell
|
|||||||
$pRange = strtoupper($pRange);
|
$pRange = strtoupper($pRange);
|
||||||
|
|
||||||
// Extract range
|
// Extract range
|
||||||
if (strpos($pRange, ':') === false) {
|
if (strpos($pRange, ':') === FALSE) {
|
||||||
$rangeA = $rangeB = $pRange;
|
$rangeA = $rangeB = $pRange;
|
||||||
} else {
|
} else {
|
||||||
list($rangeA, $rangeB) = explode(':', $pRange);
|
list($rangeA, $rangeB) = explode(':', $pRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate range outer borders
|
// Calculate range outer borders
|
||||||
$rangeStart = PHPExcel_Cell::coordinateFromString($rangeA);
|
$rangeStart = self::coordinateFromString($rangeA);
|
||||||
$rangeEnd = PHPExcel_Cell::coordinateFromString($rangeB);
|
$rangeEnd = self::coordinateFromString($rangeB);
|
||||||
|
|
||||||
// Translate column into index
|
// Translate column into index
|
||||||
$rangeStart[0] = PHPExcel_Cell::columnIndexFromString($rangeStart[0]);
|
$rangeStart[0] = self::columnIndexFromString($rangeStart[0]);
|
||||||
$rangeEnd[0] = PHPExcel_Cell::columnIndexFromString($rangeEnd[0]);
|
$rangeEnd[0] = self::columnIndexFromString($rangeEnd[0]);
|
||||||
|
|
||||||
return array($rangeStart, $rangeEnd);
|
return array($rangeStart, $rangeEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate range dimension
|
* Calculate range dimension
|
||||||
*
|
*
|
||||||
* @param string $pRange Cell range (e.g. A1:A1)
|
* @param string $pRange Cell range (e.g. A1:A1)
|
||||||
* @return array Range dimension (width, height)
|
* @return array Range dimension (width, height)
|
||||||
*/
|
*/
|
||||||
public static function rangeDimension($pRange = 'A1:A1')
|
public static function rangeDimension($pRange = 'A1:A1')
|
||||||
{
|
{
|
||||||
// Calculate range outer borders
|
// 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) );
|
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)
|
* @param string $pRange Cell range (e.g. A1:A1)
|
||||||
* @return array Range boundaries (staring Column, starting Row, Final Column, Final Row)
|
* @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')
|
public static function getRangeBoundaries($pRange = 'A1:A1')
|
||||||
{
|
{
|
||||||
@ -664,7 +690,7 @@ class PHPExcel_Cell
|
|||||||
$pRange = strtoupper($pRange);
|
$pRange = strtoupper($pRange);
|
||||||
|
|
||||||
// Extract range
|
// Extract range
|
||||||
if (strpos($pRange, ':') === false) {
|
if (strpos($pRange, ':') === FALSE) {
|
||||||
$rangeA = $rangeB = $pRange;
|
$rangeA = $rangeB = $pRange;
|
||||||
} else {
|
} else {
|
||||||
list($rangeA, $rangeB) = explode(':', $pRange);
|
list($rangeA, $rangeB) = explode(':', $pRange);
|
||||||
@ -674,11 +700,11 @@ class PHPExcel_Cell
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Column index from string
|
* Column index from string
|
||||||
*
|
*
|
||||||
* @param string $pString
|
* @param string $pString
|
||||||
* @return int Column index (base 1 !!!)
|
* @return int Column index (base 1 !!!)
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static function columnIndexFromString($pString = 'A')
|
public static function columnIndexFromString($pString = 'A')
|
||||||
{
|
{
|
||||||
@ -714,14 +740,14 @@ class PHPExcel_Cell
|
|||||||
return $_indexCache[$pString];
|
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 !!!)
|
* @param int $pColumnIndex Column index (base 0 !!!)
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function stringFromColumnIndex($pColumnIndex = 0)
|
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)
|
* @param string $pRange Range (e.g. A1 or A1:C10 or A1:E10 A20:E25)
|
||||||
* @return array Array containing single cell references
|
* @return array Array containing single cell references
|
||||||
*/
|
*/
|
||||||
public static function extractAllCellReferencesInRange($pRange = 'A1') {
|
public static function extractAllCellReferencesInRange($pRange = 'A1') {
|
||||||
// Returnvalue
|
// Returnvalue
|
||||||
@ -760,13 +786,13 @@ class PHPExcel_Cell
|
|||||||
$cellBlocks = explode(' ', str_replace('$', '', strtoupper($pRange)));
|
$cellBlocks = explode(' ', str_replace('$', '', strtoupper($pRange)));
|
||||||
foreach ($cellBlocks as $cellBlock) {
|
foreach ($cellBlocks as $cellBlock) {
|
||||||
// Single cell?
|
// Single cell?
|
||||||
if (strpos($cellBlock,':') === false && strpos($cellBlock,',') === false) {
|
if (strpos($cellBlock,':') === FALSE && strpos($cellBlock,',') === FALSE) {
|
||||||
$returnValue[] = $cellBlock;
|
$returnValue[] = $cellBlock;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Range...
|
// Range...
|
||||||
$ranges = PHPExcel_Cell::splitRange($cellBlock);
|
$ranges = self::splitRange($cellBlock);
|
||||||
foreach($ranges as $range) {
|
foreach($ranges as $range) {
|
||||||
// Single cell?
|
// Single cell?
|
||||||
if (!isset($range[1])) {
|
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 value
|
||||||
return $returnValue;
|
return array_values($sortKeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -813,7 +847,7 @@ class PHPExcel_Cell
|
|||||||
return -1;
|
return -1;
|
||||||
} elseif ($a->_row > $b->_row) {
|
} elseif ($a->_row > $b->_row) {
|
||||||
return 1;
|
return 1;
|
||||||
} elseif (PHPExcel_Cell::columnIndexFromString($a->_column) < PHPExcel_Cell::columnIndexFromString($b->_column)) {
|
} elseif (self::columnIndexFromString($a->_column) < self::columnIndexFromString($b->_column)) {
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
return 1;
|
return 1;
|
||||||
@ -839,7 +873,7 @@ class PHPExcel_Cell
|
|||||||
* @param PHPExcel_Cell_IValueBinder $binder
|
* @param PHPExcel_Cell_IValueBinder $binder
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static function setValueBinder(PHPExcel_Cell_IValueBinder $binder = null) {
|
public static function setValueBinder(PHPExcel_Cell_IValueBinder $binder = NULL) {
|
||||||
if ($binder === NULL) {
|
if ($binder === NULL) {
|
||||||
throw new Exception("A PHPExcel_Cell_IValueBinder is required for PHPExcel to function correctly.");
|
throw new Exception("A PHPExcel_Cell_IValueBinder is required for PHPExcel to function correctly.");
|
||||||
}
|
}
|
||||||
@ -901,5 +935,15 @@ class PHPExcel_Cell
|
|||||||
return $this->_formulaAttributes;
|
return $this->_formulaAttributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert to string
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function __toString()
|
||||||
|
{
|
||||||
|
return (string) $this->getValue();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,6 +88,26 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
|
|||||||
return true;
|
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'
|
// 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)) {
|
if (preg_match('/^(\d|[0-1]\d|2[0-3]):[0-5]\d$/', $value)) {
|
||||||
list($h, $m) = explode(':', $value);
|
list($h, $m) = explode(':', $value);
|
||||||
|
@ -146,6 +146,7 @@ class PHPExcel_Chart_DataSeries
|
|||||||
if ((count($plotLabel) == 0) || (is_null($plotLabel[$keys[0]]))) {
|
if ((count($plotLabel) == 0) || (is_null($plotLabel[$keys[0]]))) {
|
||||||
$plotLabel[$keys[0]] = new PHPExcel_Chart_DataSeriesValues();
|
$plotLabel[$keys[0]] = new PHPExcel_Chart_DataSeriesValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_plotLabel = $plotLabel;
|
$this->_plotLabel = $plotLabel;
|
||||||
if ((count($plotCategory) == 0) || (is_null($plotCategory[$keys[0]]))) {
|
if ((count($plotCategory) == 0) || (is_null($plotCategory[$keys[0]]))) {
|
||||||
$plotCategory[$keys[0]] = new PHPExcel_Chart_DataSeriesValues();
|
$plotCategory[$keys[0]] = new PHPExcel_Chart_DataSeriesValues();
|
||||||
@ -337,7 +338,16 @@ class PHPExcel_Chart_DataSeries
|
|||||||
|
|
||||||
public function refresh(PHPExcel_Worksheet $worksheet) {
|
public function refresh(PHPExcel_Worksheet $worksheet) {
|
||||||
foreach($this->_plotValues as $plotValues) {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,14 +273,22 @@ class PHPExcel_Chart_DataSeriesValues
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function _stripNulls($var) {
|
||||||
|
return $var !== NULL;
|
||||||
|
}
|
||||||
|
|
||||||
public function refresh(PHPExcel_Worksheet $worksheet) {
|
public function refresh(PHPExcel_Worksheet $worksheet) {
|
||||||
if ($this->_dataSource !== NULL) {
|
if ($this->_dataSource !== NULL) {
|
||||||
$calcEngine = PHPExcel_Calculation::getInstance();
|
$calcEngine = PHPExcel_Calculation::getInstance();
|
||||||
$this->_dataValues = PHPExcel_Calculation::_unwrapResult(
|
$newDataValues = PHPExcel_Calculation::_unwrapResult(
|
||||||
$calcEngine->_calculateFormulaValue(
|
$calcEngine->_calculateFormulaValue(
|
||||||
$this->_dataSource
|
'='.$this->_dataSource,
|
||||||
|
NULL,
|
||||||
|
$worksheet->getCell('A1')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
52
Classes/PHPExcel/Exception.php
Normal file
52
Classes/PHPExcel/Exception.php
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
@ -51,7 +51,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
|
|||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_readDataOnly = false;
|
private $_readDataOnly = FALSE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read charts that are defined in the workbook?
|
* Read charts that are defined in the workbook?
|
||||||
@ -59,7 +59,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
|
|||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_includeCharts = false;
|
private $_includeCharts = FALSE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restrict which sheets should be loaded?
|
* Restrict which sheets should be loaded?
|
||||||
@ -67,28 +67,28 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
|
|||||||
*
|
*
|
||||||
* @var array of string
|
* @var array of string
|
||||||
*/
|
*/
|
||||||
private $_loadSheetsOnly = null;
|
private $_loadSheetsOnly = NULL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel_Reader_IReadFilter instance
|
* PHPExcel_Reader_IReadFilter instance
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Reader_IReadFilter
|
* @var PHPExcel_Reader_IReadFilter
|
||||||
*/
|
*/
|
||||||
private $_readFilter = null;
|
private $_readFilter = NULL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel_ReferenceHelper instance
|
* PHPExcel_ReferenceHelper instance
|
||||||
*
|
*
|
||||||
* @var PHPExcel_ReferenceHelper
|
* @var PHPExcel_ReferenceHelper
|
||||||
*/
|
*/
|
||||||
private $_referenceHelper = null;
|
private $_referenceHelper = NULL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel_Reader_Excel2007_Theme instance
|
* PHPExcel_Reader_Excel2007_Theme instance
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Reader_Excel2007_Theme
|
* @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
|
* @return PHPExcel_Reader_Excel2007
|
||||||
*/
|
*/
|
||||||
public function setReadDataOnly($pValue = false) {
|
public function setReadDataOnly($pValue = FALSE) {
|
||||||
$this->_readDataOnly = $pValue;
|
$this->_readDataOnly = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -150,7 +150,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
|
|||||||
*
|
*
|
||||||
* @return PHPExcel_Reader_Excel2007
|
* @return PHPExcel_Reader_Excel2007
|
||||||
*/
|
*/
|
||||||
public function setIncludeCharts($pValue = false) {
|
public function setIncludeCharts($pValue = FALSE) {
|
||||||
$this->_includeCharts = (boolean) $pValue;
|
$this->_includeCharts = (boolean) $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -178,7 +178,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
|
|||||||
*
|
*
|
||||||
* @return PHPExcel_Reader_Excel2007
|
* @return PHPExcel_Reader_Excel2007
|
||||||
*/
|
*/
|
||||||
public function setLoadSheetsOnly($value = null)
|
public function setLoadSheetsOnly($value = NULL)
|
||||||
{
|
{
|
||||||
$this->_loadSheetsOnly = is_array($value) ?
|
$this->_loadSheetsOnly = is_array($value) ?
|
||||||
$value : array($value);
|
$value : array($value);
|
||||||
@ -194,7 +194,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
|
|||||||
*/
|
*/
|
||||||
public function setLoadAllSheets()
|
public function setLoadAllSheets()
|
||||||
{
|
{
|
||||||
$this->_loadSheetsOnly = null;
|
$this->_loadSheetsOnly = NULL;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,11 +342,11 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
|
|||||||
|
|
||||||
private static function _castToBool($c) {
|
private static function _castToBool($c) {
|
||||||
// echo 'Initial Cast to Boolean<br />';
|
// 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') {
|
if ($value == '0') {
|
||||||
return false;
|
return FALSE;
|
||||||
} elseif ($value == '1') {
|
} elseif ($value == '1') {
|
||||||
return true;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
return (bool)$c->v;
|
return (bool)$c->v;
|
||||||
}
|
}
|
||||||
@ -356,18 +356,18 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
|
|||||||
|
|
||||||
private static function _castToError($c) {
|
private static function _castToError($c) {
|
||||||
// echo 'Initial Cast to Error<br />';
|
// echo 'Initial Cast to Error<br />';
|
||||||
return isset($c->v) ? (string) $c->v : null;;
|
return isset($c->v) ? (string) $c->v : NULL;
|
||||||
} // function _castToError()
|
} // function _castToError()
|
||||||
|
|
||||||
|
|
||||||
private static function _castToString($c) {
|
private static function _castToString($c) {
|
||||||
// echo 'Initial Cast to String<br />';
|
// echo 'Initial Cast to String<br />';
|
||||||
return isset($c->v) ? (string) $c->v : null;;
|
return isset($c->v) ? (string) $c->v : NULL;
|
||||||
} // function _castToString()
|
} // function _castToString()
|
||||||
|
|
||||||
|
|
||||||
private function _castToFormula($c,$r,&$cellDataType,&$value,&$calculatedValue,&$sharedFormulas,$castBaseType) {
|
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 />';
|
// echo '$c->f is '.$c->f.'<br />';
|
||||||
$cellDataType = 'f';
|
$cellDataType = 'f';
|
||||||
$value = "={$c->f}";
|
$value = "={$c->f}";
|
||||||
@ -375,7 +375,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
|
|||||||
|
|
||||||
// Shared formula?
|
// Shared formula?
|
||||||
if (isset($c->f['t']) && strtolower((string)$c->f['t']) == 'shared') {
|
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'];
|
$instance = (string)$c->f['si'];
|
||||||
|
|
||||||
// echo 'Instance ID = '.$instance.'<br />';
|
// echo 'Instance ID = '.$instance.'<br />';
|
||||||
@ -384,7 +384,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
|
|||||||
// print_r($sharedFormulas);
|
// print_r($sharedFormulas);
|
||||||
// echo '</pre>';
|
// echo '</pre>';
|
||||||
if (!isset($sharedFormulas[(string)$c->f['si']])) {
|
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 'Master is '.$r.'<br />';
|
||||||
// echo 'Formula is '.$value.'<br />';
|
// echo 'Formula is '.$value.'<br />';
|
||||||
$sharedFormulas[$instance] = array( 'master' => $r,
|
$sharedFormulas[$instance] = array( 'master' => $r,
|
||||||
@ -394,7 +394,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
|
|||||||
// print_r($sharedFormulas);
|
// print_r($sharedFormulas);
|
||||||
// echo '</pre>';
|
// echo '</pre>';
|
||||||
} else {
|
} else {
|
||||||
// echo '<font color="darkgreen">GETTING SHARED FORMULA</font><br />';
|
// echo 'GETTING SHARED FORMULA<br />';
|
||||||
// echo 'Master is '.$sharedFormulas[$instance]['master'].'<br />';
|
// echo 'Master is '.$sharedFormulas[$instance]['master'].'<br />';
|
||||||
// echo 'Formula is '.$sharedFormulas[$instance]['formula'].'<br />';
|
// echo 'Formula is '.$sharedFormulas[$instance]['formula'].'<br />';
|
||||||
$master = PHPExcel_Cell::coordinateFromString($sharedFormulas[$instance]['master']);
|
$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")) {
|
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");
|
$relsWorksheet = simplexml_load_string($this->_getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels") ); //~ http://schemas.openxmlformats.org/package/2006/relationships");
|
||||||
$drawings = array();
|
$drawings = array();
|
||||||
@ -1469,6 +1469,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
|
|||||||
}
|
}
|
||||||
$objDrawing->setWorksheet($docSheet);
|
$objDrawing->setWorksheet($docSheet);
|
||||||
} else {
|
} else {
|
||||||
|
// ? Can charts be positioned with a oneCellAnchor ?
|
||||||
$coordinates = PHPExcel_Cell::stringFromColumnIndex((string) $oneCellAnchor->from->col) . ($oneCellAnchor->from->row + 1);
|
$coordinates = PHPExcel_Cell::stringFromColumnIndex((string) $oneCellAnchor->from->col) . ($oneCellAnchor->from->row + 1);
|
||||||
$offsetX = PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->colOff);
|
$offsetX = PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->colOff);
|
||||||
$offsetY = PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->rowOff);
|
$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);
|
$shadow->setAlpha(self::array_item($outerShdw->srgbClr->alpha->attributes(), "val") / 1000);
|
||||||
}
|
}
|
||||||
$objDrawing->setWorksheet($docSheet);
|
$objDrawing->setWorksheet($docSheet);
|
||||||
} elseif($this->_includeCharts) {
|
} elseif(($this->_includeCharts) && ($twoCellAnchor->graphicFrame)) {
|
||||||
$fromCoordinate = PHPExcel_Cell::stringFromColumnIndex((string) $twoCellAnchor->from->col) . ($twoCellAnchor->from->row + 1);
|
$fromCoordinate = PHPExcel_Cell::stringFromColumnIndex((string) $twoCellAnchor->from->col) . ($twoCellAnchor->from->row + 1);
|
||||||
$fromOffsetX = PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->colOff);
|
$fromOffsetX = PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->colOff);
|
||||||
$fromOffsetY = PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->rowOff);
|
$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"])) {
|
if (isset($color["rgb"])) {
|
||||||
return (string)$color["rgb"];
|
return (string)$color["rgb"];
|
||||||
} else if (isset($color["indexed"])) {
|
} else if (isset($color["indexed"])) {
|
||||||
|
@ -64,7 +64,8 @@ class PHPExcel_Reader_Excel2007_Chart
|
|||||||
$namespacesChartMeta = $chartElements->getNamespaces(true);
|
$namespacesChartMeta = $chartElements->getNamespaces(true);
|
||||||
$chartElementsC = $chartElements->children($namespacesChartMeta['c']);
|
$chartElementsC = $chartElements->children($namespacesChartMeta['c']);
|
||||||
|
|
||||||
$XaxisLabel = $YaxisLabel = $legend = $title = null;
|
$XaxisLabel = $YaxisLabel = $legend = $title = NULL;
|
||||||
|
$dispBlanksAs = $plotVisOnly = NULL;
|
||||||
|
|
||||||
foreach($chartElementsC as $chartElementKey => $chartElement) {
|
foreach($chartElementsC as $chartElementKey => $chartElement) {
|
||||||
switch ($chartElementKey) {
|
switch ($chartElementKey) {
|
||||||
@ -304,6 +305,13 @@ class PHPExcel_Reader_Excel2007_Chart
|
|||||||
$seriesData['pointCount'] = count($seriesData['dataValues']);
|
$seriesData['pointCount'] = count($seriesData['dataValues']);
|
||||||
|
|
||||||
return new PHPExcel_Chart_DataSeriesValues('String',$seriesSource,$seriesData['formatCode'],$seriesData['pointCount'],$seriesData['dataValues'],$marker,$smoothLine);
|
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;
|
return null;
|
||||||
} // function _chartDataSeriesValueSet()
|
} // function _chartDataSeriesValueSet()
|
||||||
|
@ -944,101 +944,92 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
|
|||||||
// echo '<br />';
|
// echo '<br />';
|
||||||
|
|
||||||
// the first shape container never has a corresponding OBJ record, hence $n + 1
|
// 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
|
// we skip all spContainers that are a part of a group shape since we cannot yet handle those
|
||||||
if ($spContainer->getNestingLevel() > 1) {
|
if ($spContainer->getNestingLevel() > 1) {
|
||||||
continue;
|
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());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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:
|
$startOffsetX = $spContainer->getStartOffsetX();
|
||||||
// other object type
|
$startOffsetY = $spContainer->getStartOffsetY();
|
||||||
break;
|
$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)) {
|
if (!empty($this->_cellNotes)) {
|
||||||
foreach($this->_cellNotes as $note => $noteDetails) {
|
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 />';
|
// echo '<b>Cell annotation ',$note,'</b><br />';
|
||||||
// var_dump($noteDetails);
|
// var_dump($noteDetails);
|
||||||
// echo '<br />';
|
// echo '<br />';
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2011 PHPExcel
|
* Copyright (c) 2006 - 2012 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Reader
|
* @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
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
@ -40,7 +40,7 @@ if (!defined('PHPEXCEL_ROOT')) {
|
|||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Reader
|
* @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
|
class PHPExcel_Reader_HTML implements PHPExcel_Reader_IReader
|
||||||
{
|
{
|
||||||
|
@ -319,14 +319,23 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
|
|||||||
foreach ($worksheetData as $key => $rowData) {
|
foreach ($worksheetData as $key => $rowData) {
|
||||||
switch ($key) {
|
switch ($key) {
|
||||||
case 'table-row' :
|
case 'table-row' :
|
||||||
|
$rowDataTableAttributes = $rowData->attributes($namespacesContent['table']);
|
||||||
|
$rowRepeats = (isset($rowDataTableAttributes['number-rows-repeated'])) ?
|
||||||
|
$rowDataTableAttributes['number-rows-repeated'] : 1;
|
||||||
$columnIndex = 0;
|
$columnIndex = 0;
|
||||||
|
|
||||||
foreach ($rowData as $key => $cellData) {
|
foreach ($rowData as $key => $cellData) {
|
||||||
$tmpInfo['lastColumnIndex'] = max($tmpInfo['lastColumnIndex'], $columnIndex);
|
$cellDataTableAttributes = $cellData->attributes($namespacesContent['table']);
|
||||||
++$columnIndex;
|
$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;
|
$rowIndex += $rowRepeats;
|
||||||
$tmpInfo['totalRows'] = max($tmpInfo['totalRows'], $rowIndex);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -492,6 +501,9 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'table-row' :
|
case 'table-row' :
|
||||||
|
$rowDataTableAttributes = $rowData->attributes($namespacesContent['table']);
|
||||||
|
$rowRepeats = (isset($rowDataTableAttributes['number-rows-repeated'])) ?
|
||||||
|
$rowDataTableAttributes['number-rows-repeated'] : 1;
|
||||||
$columnID = 'A';
|
$columnID = 'A';
|
||||||
foreach($rowData as $key => $cellData) {
|
foreach($rowData as $key => $cellData) {
|
||||||
if ($this->getReadFilter() !== NULL) {
|
if ($this->getReadFilter() !== NULL) {
|
||||||
@ -574,6 +586,22 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
|
|||||||
$type = PHPExcel_Cell_DataType::TYPE_BOOL;
|
$type = PHPExcel_Cell_DataType::TYPE_BOOL;
|
||||||
$dataValue = ($allCellDataText == 'TRUE') ? True : False;
|
$dataValue = ($allCellDataText == 'TRUE') ? True : False;
|
||||||
break;
|
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' :
|
case 'float' :
|
||||||
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
||||||
$dataValue = (float) $cellDataOfficeAttributes['value'];
|
$dataValue = (float) $cellDataOfficeAttributes['value'];
|
||||||
@ -628,45 +656,53 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
|
|||||||
// echo 'Adjusted Formula: '.$cellDataFormula.'<br />';
|
// echo 'Adjusted Formula: '.$cellDataFormula.'<br />';
|
||||||
}
|
}
|
||||||
|
|
||||||
$repeats = (isset($cellDataTableAttributes['number-columns-repeated'])) ?
|
$colRepeats = (isset($cellDataTableAttributes['number-columns-repeated'])) ?
|
||||||
$cellDataTableAttributes['number-columns-repeated'] : 1;
|
$cellDataTableAttributes['number-columns-repeated'] : 1;
|
||||||
if ($type !== NULL) {
|
if ($type !== NULL) {
|
||||||
for ($i = 0; $i < $repeats; ++$i) {
|
for ($i = 0; $i < $colRepeats; ++$i) {
|
||||||
if ($i > 0) {
|
if ($i > 0) {
|
||||||
++$columnID;
|
++$columnID;
|
||||||
}
|
}
|
||||||
$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $dataValue),$type);
|
if ($type !== PHPExcel_Cell_DataType::TYPE_NULL) {
|
||||||
if ($hasCalculatedValue) {
|
for ($rowAdjust = 0; $rowAdjust < $rowRepeats; ++$rowAdjust) {
|
||||||
// echo 'Forumla result is '.$dataValue.'<br />';
|
$rID = $rowID + $rowAdjust;
|
||||||
$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setCalculatedValue($dataValue);
|
$objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $dataValue),$type);
|
||||||
}
|
if ($hasCalculatedValue) {
|
||||||
if (($cellDataOfficeAttributes['value-type'] == 'date') ||
|
// echo 'Forumla result is '.$dataValue.'<br />';
|
||||||
($cellDataOfficeAttributes['value-type'] == 'time')) {
|
$objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->setCalculatedValue($dataValue);
|
||||||
$objPHPExcel->getActiveSheet()->getStyle($columnID.$rowID)->getNumberFormat()->setFormatCode($formatting);
|
}
|
||||||
}
|
if ($formatting !== NULL) {
|
||||||
if ($hyperlink !== NULL) {
|
$objPHPExcel->getActiveSheet()->getStyle($columnID.$rID)->getNumberFormat()->setFormatCode($formatting);
|
||||||
$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->getHyperlink()->setUrl($hyperlink);
|
} 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
|
// Merged cells
|
||||||
if ((isset($cellDataTableAttributes['number-columns-spanned'])) || (isset($cellDataTableAttributes['number-rows-spanned']))) {
|
if ((isset($cellDataTableAttributes['number-columns-spanned'])) || (isset($cellDataTableAttributes['number-rows-spanned']))) {
|
||||||
$columnTo = $columnID;
|
if (($type !== PHPExcel_Cell_DataType::TYPE_NULL) || (!$this->_readDataOnly)) {
|
||||||
if (isset($cellDataTableAttributes['number-columns-spanned'])) {
|
$columnTo = $columnID;
|
||||||
$columnTo = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($columnID) + $cellDataTableAttributes['number-columns-spanned'] -2);
|
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;
|
++$columnID;
|
||||||
}
|
}
|
||||||
++$rowID;
|
$rowID += $rowRepeats;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,9 +88,9 @@ class PHPExcel_Shared_Date
|
|||||||
if (($baseDate == self::CALENDAR_WINDOWS_1900) ||
|
if (($baseDate == self::CALENDAR_WINDOWS_1900) ||
|
||||||
($baseDate == self::CALENDAR_MAC_1904)) {
|
($baseDate == self::CALENDAR_MAC_1904)) {
|
||||||
self::$ExcelBaseDate = $baseDate;
|
self::$ExcelBaseDate = $baseDate;
|
||||||
return True;
|
return TRUE;
|
||||||
}
|
}
|
||||||
return False;
|
return FALSE;
|
||||||
} // function setExcelCalendar()
|
} // function setExcelCalendar()
|
||||||
|
|
||||||
|
|
||||||
@ -166,12 +166,12 @@ class PHPExcel_Shared_Date
|
|||||||
*
|
*
|
||||||
* @param mixed $dateValue PHP serialized date/time or date object
|
* @param mixed $dateValue PHP serialized date/time or date object
|
||||||
* @return mixed Excel date/time value
|
* @return mixed Excel date/time value
|
||||||
* or boolean False on failure
|
* or boolean FALSE on failure
|
||||||
*/
|
*/
|
||||||
public static function PHPToExcel($dateValue = 0) {
|
public static function PHPToExcel($dateValue = 0) {
|
||||||
$saveTimeZone = date_default_timezone_get();
|
$saveTimeZone = date_default_timezone_get();
|
||||||
date_default_timezone_set('UTC');
|
date_default_timezone_set('UTC');
|
||||||
$retValue = False;
|
$retValue = FALSE;
|
||||||
if ((is_object($dateValue)) && ($dateValue instanceof self::$dateTimeObjectType)) {
|
if ((is_object($dateValue)) && ($dateValue instanceof self::$dateTimeObjectType)) {
|
||||||
$retValue = self::FormattedPHPToExcel( $dateValue->format('Y'), $dateValue->format('m'), $dateValue->format('d'),
|
$retValue = self::FormattedPHPToExcel( $dateValue->format('Y'), $dateValue->format('m'), $dateValue->format('d'),
|
||||||
$dateValue->format('H'), $dateValue->format('i'), $dateValue->format('s')
|
$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
|
// 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
|
// This affects every date following 28th February 1900
|
||||||
//
|
//
|
||||||
$excel1900isLeapYear = True;
|
$excel1900isLeapYear = TRUE;
|
||||||
if (($year == 1900) && ($month <= 2)) { $excel1900isLeapYear = False; }
|
if (($year == 1900) && ($month <= 2)) { $excel1900isLeapYear = FALSE; }
|
||||||
$myExcelBaseDate = 2415020;
|
$myExcelBaseDate = 2415020;
|
||||||
} else {
|
} else {
|
||||||
$myExcelBaseDate = 2416481;
|
$myExcelBaseDate = 2416481;
|
||||||
$excel1900isLeapYear = False;
|
$excel1900isLeapYear = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Julian base date Adjustment
|
// Julian base date Adjustment
|
||||||
@ -238,7 +238,11 @@ class PHPExcel_Shared_Date
|
|||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function isDateTime(PHPExcel_Cell $pCell) {
|
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()
|
} // function isDateTime()
|
||||||
|
|
||||||
|
|
||||||
@ -264,6 +268,10 @@ class PHPExcel_Shared_Date
|
|||||||
public static function isDateTimeFormatCode($pFormatCode = '') {
|
public static function isDateTimeFormatCode($pFormatCode = '') {
|
||||||
// Switch on formatcode
|
// Switch on formatcode
|
||||||
switch ($pFormatCode) {
|
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_YYYYMMDD:
|
||||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD2:
|
case PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD2:
|
||||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DDMMYYYY:
|
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_XLSX16:
|
||||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX17:
|
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX17:
|
||||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX22:
|
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX22:
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Typically number, currency or accounting (or occasionally fraction) formats
|
// Typically number, currency or accounting (or occasionally fraction) formats
|
||||||
if ((substr($pFormatCode,0,1) == '_') || (substr($pFormatCode,0,2) == '0 ')) {
|
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
|
// Try checking for any of the date formatting characters that don't appear within square braces
|
||||||
if (preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i',$pFormatCode)) {
|
if (preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i',$pFormatCode)) {
|
||||||
// We might also have a format mask containing quoted strings...
|
// 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
|
// we don't want to test for any of our characters within the quoted blocks
|
||||||
if (strpos($pFormatCode,'"') !== false) {
|
if (strpos($pFormatCode,'"') !== FALSE) {
|
||||||
$i = false;
|
$i = FALSE;
|
||||||
foreach(explode('"',$pFormatCode) as $subVal) {
|
foreach(explode('"',$pFormatCode) as $subVal) {
|
||||||
// Only test in alternate array entries (the non-quoted blocks)
|
// Only test in alternate array entries (the non-quoted blocks)
|
||||||
if (($i = !$i) && (preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i',$subVal))) {
|
if (($i = !$i) && (preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i',$subVal))) {
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// No date...
|
// No date...
|
||||||
return false;
|
return FALSE;
|
||||||
} // function isDateTimeFormatCode()
|
} // function isDateTimeFormatCode()
|
||||||
|
|
||||||
|
|
||||||
@ -319,23 +327,23 @@ class PHPExcel_Shared_Date
|
|||||||
* Convert a date/time string to Excel time
|
* 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'
|
* @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 = '') {
|
public static function stringToExcel($dateValue = '') {
|
||||||
if (strlen($dateValue) < 2)
|
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))
|
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);
|
$dateValueNew = PHPExcel_Calculation_DateTime::DATEVALUE($dateValue);
|
||||||
|
|
||||||
if ($dateValueNew === PHPExcel_Calculation_Functions::VALUE()) {
|
if ($dateValueNew === PHPExcel_Calculation_Functions::VALUE()) {
|
||||||
return false;
|
return FALSE;
|
||||||
} else {
|
} else {
|
||||||
if (strpos($dateValue, ':') !== false) {
|
if (strpos($dateValue, ':') !== FALSE) {
|
||||||
$timeValue = PHPExcel_Calculation_DateTime::TIMEVALUE($dateValue);
|
$timeValue = PHPExcel_Calculation_DateTime::TIMEVALUE($dateValue);
|
||||||
if ($timeValue === PHPExcel_Calculation_Functions::VALUE()) {
|
if ($timeValue === PHPExcel_Calculation_Functions::VALUE()) {
|
||||||
return false;
|
return FALSE;
|
||||||
}
|
}
|
||||||
$dateValueNew += $timeValue;
|
$dateValueNew += $timeValue;
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,11 @@ class PHPExcel_Shared_Font
|
|||||||
const AUTOSIZE_METHOD_APPROX = 'approx';
|
const AUTOSIZE_METHOD_APPROX = 'approx';
|
||||||
const AUTOSIZE_METHOD_EXACT = 'exact';
|
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 */
|
/** Character set codes used by BIFF5-8 in Font records */
|
||||||
const CHARSET_ANSI_LATIN = 0x00;
|
const CHARSET_ANSI_LATIN = 0x00;
|
||||||
const CHARSET_SYSTEM_DEFAULT = 0x01;
|
const CHARSET_SYSTEM_DEFAULT = 0x01;
|
||||||
@ -187,10 +192,17 @@ class PHPExcel_Shared_Font
|
|||||||
* Set autoSize method
|
* Set autoSize method
|
||||||
*
|
*
|
||||||
* @param string $pValue
|
* @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;
|
self::$autoSizeMethod = $pValue;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -612,7 +612,7 @@ class PHPExcel_Shared_String
|
|||||||
{
|
{
|
||||||
if (!isset(self::$_decimalSeparator)) {
|
if (!isset(self::$_decimalSeparator)) {
|
||||||
$localeconv = localeconv();
|
$localeconv = localeconv();
|
||||||
self::$_decimalSeparator = $localeconv['decimal_point'] != ''
|
self::$_decimalSeparator = ($localeconv['decimal_point'] != '')
|
||||||
? $localeconv['decimal_point'] : $localeconv['mon_decimal_point'];
|
? $localeconv['decimal_point'] : $localeconv['mon_decimal_point'];
|
||||||
|
|
||||||
if (self::$_decimalSeparator == '') {
|
if (self::$_decimalSeparator == '') {
|
||||||
@ -644,7 +644,7 @@ class PHPExcel_Shared_String
|
|||||||
{
|
{
|
||||||
if (!isset(self::$_thousandsSeparator)) {
|
if (!isset(self::$_thousandsSeparator)) {
|
||||||
$localeconv = localeconv();
|
$localeconv = localeconv();
|
||||||
self::$_thousandsSeparator = $localeconv['thousands_sep'] != ''
|
self::$_thousandsSeparator = ($localeconv['thousands_sep'] != '')
|
||||||
? $localeconv['thousands_sep'] : $localeconv['mon_thousands_sep'];
|
? $localeconv['thousands_sep'] : $localeconv['mon_thousands_sep'];
|
||||||
}
|
}
|
||||||
return self::$_thousandsSeparator;
|
return self::$_thousandsSeparator;
|
||||||
@ -671,7 +671,7 @@ class PHPExcel_Shared_String
|
|||||||
{
|
{
|
||||||
if (!isset(self::$_currencyCode)) {
|
if (!isset(self::$_currencyCode)) {
|
||||||
$localeconv = localeconv();
|
$localeconv = localeconv();
|
||||||
self::$_currencyCode = $localeconv['currency_symbol'] != ''
|
self::$_currencyCode = ($localeconv['currency_symbol'] != '')
|
||||||
? $localeconv['currency_symbol'] : $localeconv['int_curr_symbol'];
|
? $localeconv['currency_symbol'] : $localeconv['int_curr_symbol'];
|
||||||
|
|
||||||
if (self::$_currencyCode == '') {
|
if (self::$_currencyCode == '') {
|
||||||
|
@ -114,6 +114,10 @@ class PHPExcel_Shared_XMLWriter extends XMLWriter {
|
|||||||
*/
|
*/
|
||||||
public function writeRawData($text)
|
public function writeRawData($text)
|
||||||
{
|
{
|
||||||
|
if (is_array($text)) {
|
||||||
|
$text = implode("\n",$text);
|
||||||
|
}
|
||||||
|
|
||||||
if (method_exists($this, 'writeRaw')) {
|
if (method_exists($this, 'writeRaw')) {
|
||||||
return $this->writeRaw(htmlspecialchars($text));
|
return $this->writeRaw(htmlspecialchars($text));
|
||||||
}
|
}
|
||||||
|
@ -213,7 +213,7 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
* @return PHPExcel_Style_Color
|
* @return PHPExcel_Style_Color
|
||||||
*/
|
*/
|
||||||
public function applyFromArray($pStyles = null) {
|
public function applyFromArray($pStyles = NULL) {
|
||||||
if (is_array($pStyles)) {
|
if (is_array($pStyles)) {
|
||||||
if ($this->_isSupervisor) {
|
if ($this->_isSupervisor) {
|
||||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
|
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
|
||||||
@ -303,8 +303,8 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
|
|||||||
* decimal value
|
* decimal value
|
||||||
* @return string The extracted colour component
|
* @return string The extracted colour component
|
||||||
*/
|
*/
|
||||||
private static function _getColourComponent($RGB,$offset,$hex=true) {
|
private static function _getColourComponent($RGB,$offset,$hex=TRUE) {
|
||||||
$colour = substr($RGB,$offset,2);
|
$colour = substr($RGB, $offset, 2);
|
||||||
if (!$hex)
|
if (!$hex)
|
||||||
$colour = hexdec($colour);
|
$colour = hexdec($colour);
|
||||||
return $colour;
|
return $colour;
|
||||||
@ -318,11 +318,11 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
|
|||||||
* decimal value
|
* decimal value
|
||||||
* @return string The red colour component
|
* @return string The red colour component
|
||||||
*/
|
*/
|
||||||
public static function getRed($RGB,$hex=true) {
|
public static function getRed($RGB,$hex=TRUE) {
|
||||||
if (strlen($RGB) == 8) {
|
if (strlen($RGB) == 8) {
|
||||||
return self::_getColourComponent($RGB,2,$hex);
|
return self::_getColourComponent($RGB, 2, $hex);
|
||||||
} elseif (strlen($RGB) == 6) {
|
} 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
|
* decimal value
|
||||||
* @return string The green colour component
|
* @return string The green colour component
|
||||||
*/
|
*/
|
||||||
public static function getGreen($RGB,$hex=true) {
|
public static function getGreen($RGB,$hex=TRUE) {
|
||||||
if (strlen($RGB) == 8) {
|
if (strlen($RGB) == 8) {
|
||||||
return self::_getColourComponent($RGB,4,$hex);
|
return self::_getColourComponent($RGB, 4, $hex);
|
||||||
} elseif (strlen($RGB) == 6) {
|
} 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
|
* decimal value
|
||||||
* @return string The blue colour component
|
* @return string The blue colour component
|
||||||
*/
|
*/
|
||||||
public static function getBlue($RGB,$hex=true) {
|
public static function getBlue($RGB,$hex=TRUE) {
|
||||||
if (strlen($RGB) == 8) {
|
if (strlen($RGB) == 8) {
|
||||||
return self::_getColourComponent($RGB,6,$hex);
|
return self::_getColourComponent($RGB, 6, $hex);
|
||||||
} elseif (strlen($RGB) == 6) {
|
} elseif (strlen($RGB) == 6) {
|
||||||
return self::_getColourComponent($RGB,4,$hex);
|
return self::_getColourComponent($RGB, 4, $hex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adjust the brightness of a color
|
* 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
|
* @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) {
|
public static function changeBrightness($hex, $adjustPercentage) {
|
||||||
$red = self::getRed($hex,false);
|
$rgba = (strlen($hex) == 8);
|
||||||
$green = self::getGreen($hex,false);
|
|
||||||
$blue = self::getBlue($hex,false);
|
$red = self::getRed($hex, FALSE);
|
||||||
|
$green = self::getGreen($hex, FALSE);
|
||||||
|
$blue = self::getBlue($hex, FALSE);
|
||||||
if ($adjustPercentage > 0) {
|
if ($adjustPercentage > 0) {
|
||||||
$red += (255 - $red) * $adjustPercentage;
|
$red += (255 - $red) * $adjustPercentage;
|
||||||
$green += (255 - $green) * $adjustPercentage;
|
$green += (255 - $green) * $adjustPercentage;
|
||||||
@ -386,10 +388,11 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
|
|||||||
if ($blue < 0) $blue = 0;
|
if ($blue < 0) $blue = 0;
|
||||||
elseif ($blue > 255) $blue = 255;
|
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($green), 2, '0', 0) .
|
||||||
str_pad(dechex($blue), 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
|
* should be returned if the indexed colour doesn't exist
|
||||||
* @return PHPExcel_Style_Color
|
* @return PHPExcel_Style_Color
|
||||||
*/
|
*/
|
||||||
public static function indexedColor($pIndex, $background=false) {
|
public static function indexedColor($pIndex, $background=FALSE) {
|
||||||
// Clean parameter
|
// Clean parameter
|
||||||
$pIndex = intval($pIndex);
|
$pIndex = intval($pIndex);
|
||||||
|
|
||||||
|
@ -527,6 +527,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
*/
|
*/
|
||||||
public function addChart(PHPExcel_Chart $pChart = null, $iChartIndex = null)
|
public function addChart(PHPExcel_Chart $pChart = null, $iChartIndex = null)
|
||||||
{
|
{
|
||||||
|
$pChart->setWorksheet($this);
|
||||||
if (is_null($iChartIndex)) {
|
if (is_null($iChartIndex)) {
|
||||||
$this->_chartCollection[] = $pChart;
|
$this->_chartCollection[] = $pChart;
|
||||||
} else {
|
} else {
|
||||||
@ -1026,11 +1027,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
public function setCellValue($pCoordinate = 'A1', $pValue = null, $returnCell = false)
|
public function setCellValue($pCoordinate = 'A1', $pValue = null, $returnCell = false)
|
||||||
{
|
{
|
||||||
$cell = $this->getCell($pCoordinate)->setValue($pValue);
|
$cell = $this->getCell($pCoordinate)->setValue($pValue);
|
||||||
|
return ($returnCell) ? $cell : $this;
|
||||||
if ($returnCell) {
|
|
||||||
return $cell;
|
|
||||||
}
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1045,11 +1042,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
public function setCellValueByColumnAndRow($pColumn = 0, $pRow = 1, $pValue = null, $returnCell = false)
|
public function setCellValueByColumnAndRow($pColumn = 0, $pRow = 1, $pValue = null, $returnCell = false)
|
||||||
{
|
{
|
||||||
$cell = $this->getCell(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow)->setValue($pValue);
|
$cell = $this->getCell(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow)->setValue($pValue);
|
||||||
|
return ($returnCell) ? $cell : $this;
|
||||||
if ($returnCell) {
|
|
||||||
return $cell;
|
|
||||||
}
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1058,13 +1051,14 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
* @param string $pCoordinate Coordinate of the cell
|
* @param string $pCoordinate Coordinate of the cell
|
||||||
* @param mixed $pValue Value of the cell
|
* @param mixed $pValue Value of the cell
|
||||||
* @param string $pDataType Explicit data type
|
* @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
|
// Set value
|
||||||
$this->getCell($pCoordinate)->setValueExplicit($pValue, $pDataType);
|
$cell = $this->getCell($pCoordinate)->setValueExplicit($pValue, $pDataType);
|
||||||
return $this;
|
return ($returnCell) ? $cell : $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1074,11 +1068,13 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
* @param string $pRow Numeric row coordinate of the cell
|
* @param string $pRow Numeric row coordinate of the cell
|
||||||
* @param mixed $pValue Value of the cell
|
* @param mixed $pValue Value of the cell
|
||||||
* @param string $pDataType Explicit data type
|
* @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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -83,7 +83,12 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
|
|||||||
$objWriter->writeAttribute('val', 0);
|
$objWriter->writeAttribute('val', 0);
|
||||||
$objWriter->endElement();
|
$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);
|
$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,
|
private function _writePlotArea(PHPExcel_Chart_PlotArea $plotArea,
|
||||||
PHPExcel_Chart_Title $xAxisLabel = NULL,
|
PHPExcel_Chart_Title $xAxisLabel = NULL,
|
||||||
PHPExcel_Chart_Title $yAxisLabel = NULL,
|
PHPExcel_Chart_Title $yAxisLabel = NULL,
|
||||||
$objWriter)
|
$objWriter,
|
||||||
|
PHPExcel_Worksheet $pSheet)
|
||||||
{
|
{
|
||||||
if (is_null($plotArea)) {
|
if (is_null($plotArea)) {
|
||||||
return;
|
return;
|
||||||
@ -252,7 +258,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
|
|||||||
$objWriter->endElement();
|
$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))
|
if (is_array($caption))
|
||||||
$caption = $caption[0];
|
$caption = $caption[0];
|
||||||
$objWriter->startElement('a:t');
|
$objWriter->startElement('a:t');
|
||||||
$objWriter->writeAttribute('xml:space', 'preserve');
|
// $objWriter->writeAttribute('xml:space', 'preserve');
|
||||||
$objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML( $caption ));
|
$objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML( $caption ));
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
@ -564,7 +570,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
|
|||||||
if (is_array($caption))
|
if (is_array($caption))
|
||||||
$caption = $caption[0];
|
$caption = $caption[0];
|
||||||
$objWriter->startElement('a:t');
|
$objWriter->startElement('a:t');
|
||||||
$objWriter->writeAttribute('xml:space', 'preserve');
|
// $objWriter->writeAttribute('xml:space', 'preserve');
|
||||||
$objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML( $caption ));
|
$objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML( $caption ));
|
||||||
$objWriter->endElement();
|
$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 &$catIsMultiLevelSeries Is category a multi-series category
|
||||||
* @param boolean &$valIsMultiLevelSeries Is value set a multi-series set
|
* @param boolean &$valIsMultiLevelSeries Is value set a multi-series set
|
||||||
* @param string &$plotGroupingType Type of grouping for multi-series values
|
* @param string &$plotGroupingType Type of grouping for multi-series values
|
||||||
|
* @param PHPExcel_Worksheet $pSheet
|
||||||
* @throws Exception
|
* @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)) {
|
if (is_null($plotGroup)) {
|
||||||
return;
|
return;
|
||||||
@ -815,7 +829,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
|
|||||||
$objWriter->startElement('c:cat');
|
$objWriter->startElement('c:cat');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_writePlotSeriesValues($plotSeriesCategory, $objWriter, $groupType, 'str');
|
$this->_writePlotSeriesValues($plotSeriesCategory, $objWriter, $groupType, 'str', $pSheet);
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -830,12 +844,12 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
|
|||||||
$objWriter->startElement('c:val');
|
$objWriter->startElement('c:val');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_writePlotSeriesValues($plotSeriesValues, $objWriter, $groupType, 'num');
|
$this->_writePlotSeriesValues($plotSeriesValues, $objWriter, $groupType, 'num', $pSheet);
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($groupType === PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) {
|
if ($groupType === PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) {
|
||||||
$this->_writeBubbles($plotSeriesValues, $objWriter);
|
$this->_writeBubbles($plotSeriesValues, $objWriter, $pSheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
@ -885,9 +899,15 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
|
|||||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||||
* @param string $groupType Type of plot for dataseries
|
* @param string $groupType Type of plot for dataseries
|
||||||
* @param string $dataType Datatype of series values
|
* @param string $dataType Datatype of series values
|
||||||
|
* @param PHPExcel_Worksheet $pSheet
|
||||||
* @throws Exception
|
* @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)) {
|
if (is_null($plotSeriesValues)) {
|
||||||
return;
|
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_PIECHART_3D) &&
|
||||||
($groupType != PHPExcel_Chart_DataSeries::TYPE_DONUTCHART)) {
|
($groupType != PHPExcel_Chart_DataSeries::TYPE_DONUTCHART)) {
|
||||||
|
|
||||||
if ($plotSeriesValues->getFormatCode() !== NULL) {
|
if (($plotSeriesValues->getFormatCode() !== NULL) &&
|
||||||
|
($plotSeriesValues->getFormatCode() !== '')) {
|
||||||
$objWriter->startElement('c:formatCode');
|
$objWriter->startElement('c:formatCode');
|
||||||
$objWriter->writeRawData( $plotSeriesValues->getFormatCode() );
|
$objWriter->writeRawData( $plotSeriesValues->getFormatCode() );
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
@ -955,14 +976,16 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
|
|||||||
|
|
||||||
$dataValues = $plotSeriesValues->getDataValues();
|
$dataValues = $plotSeriesValues->getDataValues();
|
||||||
if (!empty($dataValues)) {
|
if (!empty($dataValues)) {
|
||||||
foreach($dataValues as $plotSeriesKey => $plotSeriesValue) {
|
if (is_array($dataValues)) {
|
||||||
$objWriter->startElement('c:pt');
|
foreach($dataValues as $plotSeriesKey => $plotSeriesValue) {
|
||||||
$objWriter->writeAttribute('idx', $plotSeriesKey );
|
$objWriter->startElement('c:pt');
|
||||||
|
$objWriter->writeAttribute('idx', $plotSeriesKey );
|
||||||
|
|
||||||
$objWriter->startElement('c:v');
|
$objWriter->startElement('c:v');
|
||||||
$objWriter->writeRawData( $plotSeriesValue );
|
$objWriter->writeRawData( $plotSeriesValue );
|
||||||
|
$objWriter->endElement();
|
||||||
$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
|
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private function _writeBubbles($plotSeriesValues, $objWriter)
|
private function _writeBubbles($plotSeriesValues, $objWriter, PHPExcel_Worksheet $pSheet)
|
||||||
{
|
{
|
||||||
if (is_null($plotSeriesValues)) {
|
if (is_null($plotSeriesValues)) {
|
||||||
return;
|
return;
|
||||||
@ -996,13 +1019,18 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
|
|||||||
$objWriter->writeAttribute('val', $plotSeriesValues->getPointCount() );
|
$objWriter->writeAttribute('val', $plotSeriesValues->getPointCount() );
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
foreach($plotSeriesValues->getDataValues() as $plotSeriesKey => $plotSeriesValue) {
|
$dataValues = $plotSeriesValues->getDataValues();
|
||||||
$objWriter->startElement('c:pt');
|
if (!empty($dataValues)) {
|
||||||
$objWriter->writeAttribute('idx', $plotSeriesKey );
|
if (is_array($dataValues)) {
|
||||||
$objWriter->startElement('c:v');
|
foreach($dataValues as $plotSeriesKey => $plotSeriesValue) {
|
||||||
$objWriter->writeRawData( 1 );
|
$objWriter->startElement('c:pt');
|
||||||
$objWriter->endElement();
|
$objWriter->writeAttribute('idx', $plotSeriesKey );
|
||||||
$objWriter->endElement();
|
$objWriter->startElement('c:v');
|
||||||
|
$objWriter->writeRawData( 1 );
|
||||||
|
$objWriter->endElement();
|
||||||
|
$objWriter->endElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
@ -286,7 +286,7 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
|
|||||||
|
|
||||||
// t
|
// t
|
||||||
$objWriter->startElement($prefix.'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->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML( $element->getText() ));
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
|
Binary file not shown.
Binary file not shown.
36
README.md
Normal file
36
README.md
Normal 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)
|
@ -27,9 +27,13 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL);
|
||||||
|
ini_set('display_errors', TRUE);
|
||||||
|
ini_set('display_startup_errors', TRUE);
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
|
if (PHP_SAPI == 'cli')
|
||||||
|
die('This example should only be run from a Web Browser');
|
||||||
|
|
||||||
/** Include PHPExcel */
|
/** Include PHPExcel */
|
||||||
require_once '../Classes/PHPExcel.php';
|
require_once '../Classes/PHPExcel.php';
|
||||||
|
|
||||||
@ -84,7 +88,7 @@ if (!PHPExcel_Settings::setPdfRenderer(
|
|||||||
)) {
|
)) {
|
||||||
die(
|
die(
|
||||||
'NOTICE: Please set the $rendererName and $rendererLibraryPath values' .
|
'NOTICE: Please set the $rendererName and $rendererLibraryPath values' .
|
||||||
PHP_EOL .
|
'<br />' .
|
||||||
'at the top of this script as appropriate for your directory structure'
|
'at the top of this script as appropriate for your directory structure'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -27,9 +27,13 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL);
|
||||||
|
ini_set('display_errors', TRUE);
|
||||||
|
ini_set('display_startup_errors', TRUE);
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
|
if (PHP_SAPI == 'cli')
|
||||||
|
die('This example should only be run from a Web Browser');
|
||||||
|
|
||||||
/** Include PHPExcel */
|
/** Include PHPExcel */
|
||||||
require_once '../Classes/PHPExcel.php';
|
require_once '../Classes/PHPExcel.php';
|
||||||
|
|
||||||
|
@ -27,9 +27,13 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL);
|
||||||
|
ini_set('display_errors', TRUE);
|
||||||
|
ini_set('display_startup_errors', TRUE);
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
|
if (PHP_SAPI == 'cli')
|
||||||
|
die('This example should only be run from a Web Browser');
|
||||||
|
|
||||||
/** Include PHPExcel */
|
/** Include PHPExcel */
|
||||||
require_once '../Classes/PHPExcel.php';
|
require_once '../Classes/PHPExcel.php';
|
||||||
|
|
||||||
|
@ -27,19 +27,22 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL);
|
||||||
|
ini_set('display_errors', TRUE);
|
||||||
|
ini_set('display_startup_errors', TRUE);
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
|
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||||
|
|
||||||
/** Include PHPExcel */
|
/** Include PHPExcel */
|
||||||
require_once '../Classes/PHPExcel.php';
|
require_once '../Classes/PHPExcel.php';
|
||||||
|
|
||||||
|
|
||||||
// Create new PHPExcel object
|
// 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();
|
$objPHPExcel = new PHPExcel();
|
||||||
|
|
||||||
// Set document properties
|
// 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")
|
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||||
->setLastModifiedBy("Maarten Balliauw")
|
->setLastModifiedBy("Maarten Balliauw")
|
||||||
->setTitle("PHPExcel Test Document")
|
->setTitle("PHPExcel Test Document")
|
||||||
@ -50,7 +53,7 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
|||||||
|
|
||||||
|
|
||||||
// Add some data
|
// 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->setActiveSheetIndex(0)
|
||||||
->setCellValue('A1', 'Hello')
|
->setCellValue('A1', 'Hello')
|
||||||
->setCellValue('B2', 'world!')
|
->setCellValue('B2', 'world!')
|
||||||
@ -63,7 +66,7 @@ $objPHPExcel->setActiveSheetIndex(0)
|
|||||||
->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');
|
->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');
|
||||||
|
|
||||||
// Rename worksheet
|
// Rename worksheet
|
||||||
echo date('H:i:s') , " Rename worksheet" , PHP_EOL;
|
echo date('H:i:s') , " Rename worksheet" , EOL;
|
||||||
$objPHPExcel->getActiveSheet()->setTitle('Simple');
|
$objPHPExcel->getActiveSheet()->setTitle('Simple');
|
||||||
|
|
||||||
|
|
||||||
@ -72,19 +75,20 @@ $objPHPExcel->setActiveSheetIndex(0);
|
|||||||
|
|
||||||
|
|
||||||
// Save Excel 2007 file
|
// 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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
$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
|
// 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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
$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 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 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;
|
||||||
|
@ -27,19 +27,22 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL);
|
||||||
|
ini_set('display_errors', TRUE);
|
||||||
|
ini_set('display_startup_errors', TRUE);
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
|
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||||
|
|
||||||
/** Include PHPExcel */
|
/** Include PHPExcel */
|
||||||
require_once '../Classes/PHPExcel.php';
|
require_once '../Classes/PHPExcel.php';
|
||||||
|
|
||||||
|
|
||||||
// Create new PHPExcel object
|
// 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();
|
$objPHPExcel = new PHPExcel();
|
||||||
|
|
||||||
// Set document properties
|
// 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")
|
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||||
->setLastModifiedBy("Maarten Balliauw")
|
->setLastModifiedBy("Maarten Balliauw")
|
||||||
->setTitle("Office 2007 XLSX Test Document")
|
->setTitle("Office 2007 XLSX Test Document")
|
||||||
@ -49,65 +52,65 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
|||||||
->setCategory("Test result file");
|
->setCategory("Test result file");
|
||||||
|
|
||||||
// Set default font
|
// Set default font
|
||||||
echo date('H:i:s') , " Set default font" , PHP_EOL;
|
echo date('H:i:s') , " Set default font" , EOL;
|
||||||
$objPHPExcel->getDefaultStyle()->getFont()->setName('Arial');
|
$objPHPExcel->getDefaultStyle()->getFont()->setName('Arial')
|
||||||
$objPHPExcel->getDefaultStyle()->getFont()->setSize(10);
|
->setSize(10);
|
||||||
|
|
||||||
// Add some data, resembling some different data types
|
// Add some data, 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->getActiveSheet()->setCellValue('A1', 'String');
|
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'String')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Simple');
|
->setCellValue('B1', 'Simple')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C1', 'PHPExcel');
|
->setCellValue('C1', 'PHPExcel');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A2', 'String');
|
$objPHPExcel->getActiveSheet()->setCellValue('A2', 'String')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B2', 'Symbols');
|
->setCellValue('B2', 'Symbols')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C2', '!+&=()~§±æþ');
|
->setCellValue('C2', '!+&=()~§±æþ');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A3', 'String');
|
$objPHPExcel->getActiveSheet()->setCellValue('A3', 'String')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B3', 'UTF-8');
|
->setCellValue('B3', 'UTF-8')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C3', 'Создать MS Excel Книги из PHP скриптов');
|
->setCellValue('C3', 'Создать MS Excel Книги из PHP скриптов');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A4', 'Number');
|
$objPHPExcel->getActiveSheet()->setCellValue('A4', 'Number')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B4', 'Integer');
|
->setCellValue('B4', 'Integer')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C4', 12);
|
->setCellValue('C4', 12);
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A5', 'Number');
|
$objPHPExcel->getActiveSheet()->setCellValue('A5', 'Number')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B5', 'Float');
|
->setCellValue('B5', 'Float')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C5', 34.56);
|
->setCellValue('C5', 34.56);
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A6', 'Number');
|
$objPHPExcel->getActiveSheet()->setCellValue('A6', 'Number')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B6', 'Negative');
|
->setCellValue('B6', 'Negative')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C6', -7.89);
|
->setCellValue('C6', -7.89);
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A7', 'Boolean');
|
$objPHPExcel->getActiveSheet()->setCellValue('A7', 'Boolean')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B7', 'True');
|
->setCellValue('B7', 'True')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C7', true);
|
->setCellValue('C7', true);
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A8', 'Boolean');
|
$objPHPExcel->getActiveSheet()->setCellValue('A8', 'Boolean')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B8', 'False');
|
->setCellValue('B8', 'False')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C8', false);
|
->setCellValue('C8', false);
|
||||||
|
|
||||||
$dateTimeNow = time();
|
$dateTimeNow = time();
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A9', 'Date/Time');
|
$objPHPExcel->getActiveSheet()->setCellValue('A9', 'Date/Time')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B9', 'Date');
|
->setCellValue('B9', 'Date')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C9', PHPExcel_Shared_Date::PHPToExcel( $dateTimeNow ));
|
->setCellValue('C9', PHPExcel_Shared_Date::PHPToExcel( $dateTimeNow ));
|
||||||
$objPHPExcel->getActiveSheet()->getStyle('C9')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD2);
|
$objPHPExcel->getActiveSheet()->getStyle('C9')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD2);
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A10', 'Date/Time');
|
$objPHPExcel->getActiveSheet()->setCellValue('A10', 'Date/Time')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B10', 'Time');
|
->setCellValue('B10', 'Time')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C10', PHPExcel_Shared_Date::PHPToExcel( $dateTimeNow ));
|
->setCellValue('C10', PHPExcel_Shared_Date::PHPToExcel( $dateTimeNow ));
|
||||||
$objPHPExcel->getActiveSheet()->getStyle('C10')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4);
|
$objPHPExcel->getActiveSheet()->getStyle('C10')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4);
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A11', 'Date/Time');
|
$objPHPExcel->getActiveSheet()->setCellValue('A11', 'Date/Time')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B11', 'Date and Time');
|
->setCellValue('B11', 'Date and Time')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C11', PHPExcel_Shared_Date::PHPToExcel( $dateTimeNow ));
|
->setCellValue('C11', PHPExcel_Shared_Date::PHPToExcel( $dateTimeNow ));
|
||||||
$objPHPExcel->getActiveSheet()->getStyle('C11')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_DATETIME);
|
$objPHPExcel->getActiveSheet()->getStyle('C11')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_DATETIME);
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);
|
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);
|
||||||
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setAutoSize(true);
|
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setAutoSize(true);
|
||||||
|
|
||||||
// Rename worksheet
|
// Rename worksheet
|
||||||
echo date('H:i:s') , " Rename worksheet" , PHP_EOL;
|
echo date('H:i:s') , " Rename worksheet" , EOL;
|
||||||
$objPHPExcel->getActiveSheet()->setTitle('Datatypes');
|
$objPHPExcel->getActiveSheet()->setTitle('Datatypes');
|
||||||
|
|
||||||
|
|
||||||
@ -116,20 +119,21 @@ $objPHPExcel->setActiveSheetIndex(0);
|
|||||||
|
|
||||||
|
|
||||||
// Save Excel 2007 file
|
// 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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
$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__));
|
$objPHPExcel = PHPExcel_IOFactory::load(str_replace('.php', '.xls', __FILE__));
|
||||||
|
|
||||||
var_dump($objPHPExcel->getActiveSheet()->toArray());
|
var_dump($objPHPExcel->getActiveSheet()->toArray());
|
||||||
|
|
||||||
|
|
||||||
// Echo memory peak usage
|
// 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 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;
|
||||||
|
@ -27,19 +27,22 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL);
|
||||||
|
ini_set('display_errors', TRUE);
|
||||||
|
ini_set('display_startup_errors', TRUE);
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
|
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||||
|
|
||||||
/** Include PHPExcel */
|
/** Include PHPExcel */
|
||||||
require_once '../Classes/PHPExcel.php';
|
require_once '../Classes/PHPExcel.php';
|
||||||
|
|
||||||
|
|
||||||
// Create new PHPExcel object
|
// 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();
|
$objPHPExcel = new PHPExcel();
|
||||||
|
|
||||||
// Set document properties
|
// 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")
|
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||||
->setLastModifiedBy("Maarten Balliauw")
|
->setLastModifiedBy("Maarten Balliauw")
|
||||||
->setTitle("Office 2007 XLSX Test Document")
|
->setTitle("Office 2007 XLSX Test Document")
|
||||||
@ -49,65 +52,65 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
|||||||
->setCategory("Test result file");
|
->setCategory("Test result file");
|
||||||
|
|
||||||
// Set default font
|
// Set default font
|
||||||
echo date('H:i:s') , " Set default font" , PHP_EOL;
|
echo date('H:i:s') , " Set default font" , EOL;
|
||||||
$objPHPExcel->getDefaultStyle()->getFont()->setName('Arial');
|
$objPHPExcel->getDefaultStyle()->getFont()->setName('Arial')
|
||||||
$objPHPExcel->getDefaultStyle()->getFont()->setSize(10);
|
->setSize(10);
|
||||||
|
|
||||||
// Add some data, resembling some different data types
|
// Add some data, 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->getActiveSheet()->setCellValue('A1', 'String');
|
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'String')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Simple');
|
->setCellValue('B1', 'Simple')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C1', 'PHPExcel');
|
->setCellValue('C1', 'PHPExcel');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A2', 'String');
|
$objPHPExcel->getActiveSheet()->setCellValue('A2', 'String')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B2', 'Symbols');
|
->setCellValue('B2', 'Symbols')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C2', '!+&=()~§±æþ');
|
->setCellValue('C2', '!+&=()~§±æþ');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A3', 'String');
|
$objPHPExcel->getActiveSheet()->setCellValue('A3', 'String')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B3', 'UTF-8');
|
->setCellValue('B3', 'UTF-8')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C3', 'Создать MS Excel Книги из PHP скриптов');
|
->setCellValue('C3', 'Создать MS Excel Книги из PHP скриптов');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A4', 'Number');
|
$objPHPExcel->getActiveSheet()->setCellValue('A4', 'Number')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B4', 'Integer');
|
->setCellValue('B4', 'Integer')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C4', 12);
|
->setCellValue('C4', 12);
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A5', 'Number');
|
$objPHPExcel->getActiveSheet()->setCellValue('A5', 'Number')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B5', 'Float');
|
->setCellValue('B5', 'Float')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C5', 34.56);
|
->setCellValue('C5', 34.56);
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A6', 'Number');
|
$objPHPExcel->getActiveSheet()->setCellValue('A6', 'Number')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B6', 'Negative');
|
->setCellValue('B6', 'Negative')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C6', -7.89);
|
->setCellValue('C6', -7.89);
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A7', 'Boolean');
|
$objPHPExcel->getActiveSheet()->setCellValue('A7', 'Boolean')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B7', 'True');
|
->setCellValue('B7', 'True')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C7', true);
|
->setCellValue('C7', true);
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A8', 'Boolean');
|
$objPHPExcel->getActiveSheet()->setCellValue('A8', 'Boolean')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B8', 'False');
|
->setCellValue('B8', 'False')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C8', false);
|
->setCellValue('C8', false);
|
||||||
|
|
||||||
$dateTimeNow = time();
|
$dateTimeNow = time();
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A9', 'Date/Time');
|
$objPHPExcel->getActiveSheet()->setCellValue('A9', 'Date/Time')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B9', 'Date');
|
->setCellValue('B9', 'Date')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C9', PHPExcel_Shared_Date::PHPToExcel( $dateTimeNow ));
|
->setCellValue('C9', PHPExcel_Shared_Date::PHPToExcel( $dateTimeNow ));
|
||||||
$objPHPExcel->getActiveSheet()->getStyle('C9')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD2);
|
$objPHPExcel->getActiveSheet()->getStyle('C9')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD2);
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A10', 'Date/Time');
|
$objPHPExcel->getActiveSheet()->setCellValue('A10', 'Date/Time')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B10', 'Time');
|
->setCellValue('B10', 'Time')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C10', PHPExcel_Shared_Date::PHPToExcel( $dateTimeNow ));
|
->setCellValue('C10', PHPExcel_Shared_Date::PHPToExcel( $dateTimeNow ));
|
||||||
$objPHPExcel->getActiveSheet()->getStyle('C10')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4);
|
$objPHPExcel->getActiveSheet()->getStyle('C10')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4);
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A11', 'Date/Time');
|
$objPHPExcel->getActiveSheet()->setCellValue('A11', 'Date/Time')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B11', 'Date and Time');
|
->setCellValue('B11', 'Date and Time')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C11', PHPExcel_Shared_Date::PHPToExcel( $dateTimeNow ));
|
->setCellValue('C11', PHPExcel_Shared_Date::PHPToExcel( $dateTimeNow ));
|
||||||
$objPHPExcel->getActiveSheet()->getStyle('C11')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_DATETIME);
|
$objPHPExcel->getActiveSheet()->getStyle('C11')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_DATETIME);
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);
|
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);
|
||||||
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setAutoSize(true);
|
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setAutoSize(true);
|
||||||
|
|
||||||
// Rename worksheet
|
// Rename worksheet
|
||||||
echo date('H:i:s') , " Rename worksheet" , PHP_EOL;
|
echo date('H:i:s') , " Rename worksheet" , EOL;
|
||||||
$objPHPExcel->getActiveSheet()->setTitle('Datatypes');
|
$objPHPExcel->getActiveSheet()->setTitle('Datatypes');
|
||||||
|
|
||||||
|
|
||||||
@ -116,20 +119,21 @@ $objPHPExcel->setActiveSheetIndex(0);
|
|||||||
|
|
||||||
|
|
||||||
// Save Excel 2007 file
|
// 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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
$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__));
|
$objPHPExcel = PHPExcel_IOFactory::load(str_replace('.php', '.xlsx', __FILE__));
|
||||||
|
|
||||||
var_dump($objPHPExcel->getActiveSheet()->toArray());
|
var_dump($objPHPExcel->getActiveSheet()->toArray());
|
||||||
|
|
||||||
|
|
||||||
// Echo memory peak usage
|
// 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 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;
|
||||||
|
@ -27,19 +27,22 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL);
|
||||||
|
ini_set('display_errors', TRUE);
|
||||||
|
ini_set('display_startup_errors', TRUE);
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
|
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||||
|
|
||||||
/** Include PHPExcel */
|
/** Include PHPExcel */
|
||||||
require_once '../Classes/PHPExcel.php';
|
require_once '../Classes/PHPExcel.php';
|
||||||
|
|
||||||
|
|
||||||
// Create new PHPExcel object
|
// 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();
|
$objPHPExcel = new PHPExcel();
|
||||||
|
|
||||||
// Set document properties
|
// 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")
|
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||||
->setLastModifiedBy("Maarten Balliauw")
|
->setLastModifiedBy("Maarten Balliauw")
|
||||||
->setTitle("Office 2007 XLSX Test Document")
|
->setTitle("Office 2007 XLSX Test Document")
|
||||||
@ -50,7 +53,7 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
|||||||
|
|
||||||
|
|
||||||
// Add some data, we will use some formulas here
|
// 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('A5', 'Sum:');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Range #1')
|
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Range #1')
|
||||||
@ -59,7 +62,7 @@ $objPHPExcel->getActiveSheet()->setCellValue('B1', 'Range #1')
|
|||||||
->setCellValue('B4', 13)
|
->setCellValue('B4', 13)
|
||||||
->setCellValue('B5', '=SUM(B2:B4)');
|
->setCellValue('B5', '=SUM(B2:B4)');
|
||||||
echo date('H:i:s') , " Sum of Range #1 is " ,
|
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')
|
$objPHPExcel->getActiveSheet()->setCellValue('C1', 'Range #2')
|
||||||
->setCellValue('C2', 5)
|
->setCellValue('C2', 5)
|
||||||
@ -67,31 +70,31 @@ $objPHPExcel->getActiveSheet()->setCellValue('C1', 'Range #2')
|
|||||||
->setCellValue('C4', 17)
|
->setCellValue('C4', 17)
|
||||||
->setCellValue('C5', '=SUM(C2:C4)');
|
->setCellValue('C5', '=SUM(C2:C4)');
|
||||||
echo date('H:i:s') , " Sum of Range #2 is " ,
|
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('A7', 'Total of both ranges:');
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B7', '=SUM(B5:C5)');
|
$objPHPExcel->getActiveSheet()->setCellValue('B7', '=SUM(B5:C5)');
|
||||||
echo date('H:i:s') , " Sum of both Ranges is " ,
|
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('A8', 'Minimum of both ranges:');
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B8', '=MIN(B2:C4)');
|
$objPHPExcel->getActiveSheet()->setCellValue('B8', '=MIN(B2:C4)');
|
||||||
echo date('H:i:s') , " Minimum value in either Range is " ,
|
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('A9', 'Maximum of both ranges:');
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B9', '=MAX(B2:C4)');
|
$objPHPExcel->getActiveSheet()->setCellValue('B9', '=MAX(B2:C4)');
|
||||||
echo date('H:i:s') , " Maximum value in either Range is " ,
|
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('A10', 'Average of both ranges:');
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B10', '=AVERAGE(B2:C4)');
|
$objPHPExcel->getActiveSheet()->setCellValue('B10', '=AVERAGE(B2:C4)');
|
||||||
echo date('H:i:s') , " Average value of both Ranges is " ,
|
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
|
// Rename worksheet
|
||||||
echo date('H:i:s') , " Rename worksheet" , PHP_EOL;
|
echo date('H:i:s') , " Rename worksheet" , EOL;
|
||||||
$objPHPExcel->getActiveSheet()->setTitle('Formulas');
|
$objPHPExcel->getActiveSheet()->setTitle('Formulas');
|
||||||
|
|
||||||
|
|
||||||
@ -100,14 +103,20 @@ $objPHPExcel->setActiveSheetIndex(0);
|
|||||||
|
|
||||||
|
|
||||||
// Save Excel 2007 file
|
// 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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
$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 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 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;
|
||||||
|
@ -27,6 +27,10 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
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');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
@ -35,11 +39,11 @@ require_once '../Classes/PHPExcel.php';
|
|||||||
|
|
||||||
|
|
||||||
// Create new PHPExcel object
|
// 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();
|
$objPHPExcel = new PHPExcel();
|
||||||
|
|
||||||
// Set document properties
|
// 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")
|
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||||
->setLastModifiedBy("Maarten Balliauw")
|
->setLastModifiedBy("Maarten Balliauw")
|
||||||
->setTitle("Office 2007 XLSX Test Document")
|
->setTitle("Office 2007 XLSX Test Document")
|
||||||
@ -50,19 +54,19 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
|||||||
|
|
||||||
|
|
||||||
// Add some data, we will use printing features
|
// 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++) {
|
for ($i = 1; $i < 200; $i++) {
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A' . $i, $i);
|
$objPHPExcel->getActiveSheet()->setCellValue('A' . $i, $i);
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B' . $i, 'Test value');
|
$objPHPExcel->getActiveSheet()->setCellValue('B' . $i, 'Test value');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set header and footer. When no different headers for odd/even are used, odd header is assumed.
|
// 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()->setOddHeader('&L&G&C&HPlease treat this document as confidential!');
|
||||||
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&L&B' . $objPHPExcel->getProperties()->getTitle() . '&RPage &P of &N');
|
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&L&B' . $objPHPExcel->getProperties()->getTitle() . '&RPage &P of &N');
|
||||||
|
|
||||||
// Add a drawing to the header
|
// 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 = new PHPExcel_Worksheet_HeaderFooterDrawing();
|
||||||
$objDrawing->setName('PHPExcel logo');
|
$objDrawing->setName('PHPExcel logo');
|
||||||
$objDrawing->setPath('./images/phpexcel_logo.gif');
|
$objDrawing->setPath('./images/phpexcel_logo.gif');
|
||||||
@ -70,12 +74,12 @@ $objDrawing->setHeight(36);
|
|||||||
$objPHPExcel->getActiveSheet()->getHeaderFooter()->addImage($objDrawing, PHPExcel_Worksheet_HeaderFooter::IMAGE_HEADER_LEFT);
|
$objPHPExcel->getActiveSheet()->getHeaderFooter()->addImage($objDrawing, PHPExcel_Worksheet_HeaderFooter::IMAGE_HEADER_LEFT);
|
||||||
|
|
||||||
// Set page orientation and size
|
// 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()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);
|
||||||
$objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
|
$objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
|
||||||
|
|
||||||
// Rename worksheet
|
// Rename worksheet
|
||||||
echo date('H:i:s') , " Rename worksheet" , PHP_EOL;
|
echo date('H:i:s') , " Rename worksheet" , EOL;
|
||||||
$objPHPExcel->getActiveSheet()->setTitle('Printing');
|
$objPHPExcel->getActiveSheet()->setTitle('Printing');
|
||||||
|
|
||||||
|
|
||||||
@ -84,14 +88,20 @@ $objPHPExcel->setActiveSheetIndex(0);
|
|||||||
|
|
||||||
|
|
||||||
// Save Excel 2007 file
|
// 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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
$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 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 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;
|
||||||
|
@ -27,6 +27,10 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
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');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
@ -37,13 +41,19 @@ require_once '../Classes/PHPExcel/IOFactory.php';
|
|||||||
|
|
||||||
|
|
||||||
// Save Excel 2007 file
|
// 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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
$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 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 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;
|
||||||
|
@ -27,6 +27,10 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
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');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
@ -49,11 +53,11 @@ for writing to Excel2007:
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Create new PHPExcel object
|
// 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();
|
$objPHPExcel = new PHPExcel();
|
||||||
|
|
||||||
// Set document properties
|
// 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")
|
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||||
->setLastModifiedBy("Maarten Balliauw")
|
->setLastModifiedBy("Maarten Balliauw")
|
||||||
->setTitle("Office 2007 XLSX Test Document")
|
->setTitle("Office 2007 XLSX Test Document")
|
||||||
@ -64,7 +68,7 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
|||||||
|
|
||||||
|
|
||||||
// Create a first sheet
|
// 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->setActiveSheetIndex(0);
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Firstname");
|
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Firstname");
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B1', "Lastname");
|
$objPHPExcel->getActiveSheet()->setCellValue('B1', "Lastname");
|
||||||
@ -74,24 +78,24 @@ $objPHPExcel->getActiveSheet()->setCellValue('E1', "Is Client ?");
|
|||||||
|
|
||||||
|
|
||||||
// Hide "Phone" and "fax" column
|
// 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('C')->setVisible(false);
|
||||||
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setVisible(false);
|
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setVisible(false);
|
||||||
|
|
||||||
|
|
||||||
// Set outline levels
|
// 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)
|
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setOutlineLevel(1)
|
||||||
->setVisible(false)
|
->setVisible(false)
|
||||||
->setCollapsed(true);
|
->setCollapsed(true);
|
||||||
|
|
||||||
// Freeze panes
|
// Freeze panes
|
||||||
echo date('H:i:s') , " Freeze panes" , PHP_EOL;
|
echo date('H:i:s') , " Freeze panes" , EOL;
|
||||||
$objPHPExcel->getActiveSheet()->freezePane('A2');
|
$objPHPExcel->getActiveSheet()->freezePane('A2');
|
||||||
|
|
||||||
|
|
||||||
// Rows to repeat at top
|
// 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);
|
$objPHPExcel->getActiveSheet()->getPageSetup()->setRowsToRepeatAtTopByStartAndEnd(1, 1);
|
||||||
|
|
||||||
|
|
||||||
@ -110,14 +114,15 @@ $objPHPExcel->setActiveSheetIndex(0);
|
|||||||
|
|
||||||
|
|
||||||
// Save Excel 5 file
|
// 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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
$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 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 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;
|
||||||
|
@ -27,6 +27,10 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
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');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
@ -49,11 +53,11 @@ for writing to Excel2007:
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Create new PHPExcel object
|
// 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();
|
$objPHPExcel = new PHPExcel();
|
||||||
|
|
||||||
// Set document properties
|
// 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")
|
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||||
->setLastModifiedBy("Maarten Balliauw")
|
->setLastModifiedBy("Maarten Balliauw")
|
||||||
->setTitle("Office 2007 XLSX Test Document")
|
->setTitle("Office 2007 XLSX Test Document")
|
||||||
@ -64,7 +68,7 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
|||||||
|
|
||||||
|
|
||||||
// Create a first sheet
|
// 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->setActiveSheetIndex(0);
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Firstname");
|
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Firstname");
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B1', "Lastname");
|
$objPHPExcel->getActiveSheet()->setCellValue('B1', "Lastname");
|
||||||
@ -74,24 +78,24 @@ $objPHPExcel->getActiveSheet()->setCellValue('E1', "Is Client ?");
|
|||||||
|
|
||||||
|
|
||||||
// Hide "Phone" and "fax" column
|
// 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('C')->setVisible(false);
|
||||||
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setVisible(false);
|
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setVisible(false);
|
||||||
|
|
||||||
|
|
||||||
// Set outline levels
|
// 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)
|
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setOutlineLevel(1)
|
||||||
->setVisible(false)
|
->setVisible(false)
|
||||||
->setCollapsed(true);
|
->setCollapsed(true);
|
||||||
|
|
||||||
// Freeze panes
|
// Freeze panes
|
||||||
echo date('H:i:s') , " Freeze panes" , PHP_EOL;
|
echo date('H:i:s') , " Freeze panes" , EOL;
|
||||||
$objPHPExcel->getActiveSheet()->freezePane('A2');
|
$objPHPExcel->getActiveSheet()->freezePane('A2');
|
||||||
|
|
||||||
|
|
||||||
// Rows to repeat at top
|
// 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);
|
$objPHPExcel->getActiveSheet()->getPageSetup()->setRowsToRepeatAtTopByStartAndEnd(1, 1);
|
||||||
|
|
||||||
|
|
||||||
@ -110,14 +114,15 @@ $objPHPExcel->setActiveSheetIndex(0);
|
|||||||
|
|
||||||
|
|
||||||
// Save Excel 2007 file
|
// 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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
$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 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 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;
|
||||||
|
@ -26,6 +26,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
error_reporting(E_ALL);
|
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');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
@ -34,20 +38,21 @@ require_once '../Classes/PHPExcel/IOFactory.php';
|
|||||||
|
|
||||||
|
|
||||||
if (!file_exists("05featuredemo.xlsx")) {
|
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");
|
$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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
$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 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 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;
|
||||||
|
@ -27,6 +27,10 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
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');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
@ -35,11 +39,11 @@ require_once '../Classes/PHPExcel.php';
|
|||||||
|
|
||||||
|
|
||||||
// Create new PHPExcel object
|
// 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();
|
$objPHPExcel = new PHPExcel();
|
||||||
|
|
||||||
// Set document properties
|
// 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")
|
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||||
->setLastModifiedBy("Maarten Balliauw")
|
->setLastModifiedBy("Maarten Balliauw")
|
||||||
->setTitle("Office 2007 XLSX Test Document")
|
->setTitle("Office 2007 XLSX Test Document")
|
||||||
@ -50,59 +54,59 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
|||||||
|
|
||||||
|
|
||||||
// Create a first sheet, representing sales data
|
// 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->setActiveSheetIndex(0);
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Description');
|
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Description')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Amount');
|
->setCellValue('B1', 'Amount');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A2', 'Paycheck received');
|
$objPHPExcel->getActiveSheet()->setCellValue('A2', 'Paycheck received')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B2', 100);
|
->setCellValue('B2', 100);
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A3', 'Cup of coffee bought');
|
$objPHPExcel->getActiveSheet()->setCellValue('A3', 'Cup of coffee bought')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B3', -1.5);
|
->setCellValue('B3', -1.5);
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A4', 'Cup of coffee bought');
|
$objPHPExcel->getActiveSheet()->setCellValue('A4', 'Cup of coffee bought')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B4', -1.5);
|
->setCellValue('B4', -1.5);
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A5', 'Cup of tea bought');
|
$objPHPExcel->getActiveSheet()->setCellValue('A5', 'Cup of tea bought')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B5', -1.2);
|
->setCellValue('B5', -1.2);
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A6', 'Found some money');
|
$objPHPExcel->getActiveSheet()->setCellValue('A6', 'Found some money')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B6', 8);
|
->setCellValue('B6', 8);
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A7', 'Total:');
|
$objPHPExcel->getActiveSheet()->setCellValue('A7', 'Total:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B7', '=SUM(B2:B6)');
|
->setCellValue('B7', '=SUM(B2:B6)');
|
||||||
|
|
||||||
|
|
||||||
// Set column widths
|
// 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('A')->setWidth(30);
|
||||||
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(12);
|
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(12);
|
||||||
|
|
||||||
|
|
||||||
// Add conditional formatting
|
// 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 = new PHPExcel_Style_Conditional();
|
||||||
$objConditional1->setConditionType(PHPExcel_Style_Conditional::CONDITION_CELLIS);
|
$objConditional1->setConditionType(PHPExcel_Style_Conditional::CONDITION_CELLIS)
|
||||||
$objConditional1->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_BETWEEN);
|
->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_BETWEEN)
|
||||||
$objConditional1->addCondition('200');
|
->addCondition('200')
|
||||||
$objConditional1->addCondition('400');
|
->addCondition('400');
|
||||||
$objConditional1->getStyle()->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_YELLOW);
|
$objConditional1->getStyle()->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_YELLOW);
|
||||||
$objConditional1->getStyle()->getFont()->setBold(true);
|
$objConditional1->getStyle()->getFont()->setBold(true);
|
||||||
$objConditional1->getStyle()->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE);
|
$objConditional1->getStyle()->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE);
|
||||||
|
|
||||||
$objConditional2 = new PHPExcel_Style_Conditional();
|
$objConditional2 = new PHPExcel_Style_Conditional();
|
||||||
$objConditional2->setConditionType(PHPExcel_Style_Conditional::CONDITION_CELLIS);
|
$objConditional2->setConditionType(PHPExcel_Style_Conditional::CONDITION_CELLIS)
|
||||||
$objConditional2->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_LESSTHAN);
|
->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_LESSTHAN)
|
||||||
$objConditional2->addCondition('0');
|
->addCondition('0');
|
||||||
$objConditional2->getStyle()->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_RED);
|
$objConditional2->getStyle()->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_RED);
|
||||||
$objConditional2->getStyle()->getFont()->setBold(true);
|
$objConditional2->getStyle()->getFont()->setBold(true);
|
||||||
$objConditional2->getStyle()->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE);
|
$objConditional2->getStyle()->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE);
|
||||||
|
|
||||||
$objConditional3 = new PHPExcel_Style_Conditional();
|
$objConditional3 = new PHPExcel_Style_Conditional();
|
||||||
$objConditional3->setConditionType(PHPExcel_Style_Conditional::CONDITION_CELLIS);
|
$objConditional3->setConditionType(PHPExcel_Style_Conditional::CONDITION_CELLIS)
|
||||||
$objConditional3->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_GREATERTHANOREQUAL);
|
->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_GREATERTHANOREQUAL)
|
||||||
$objConditional3->addCondition('0');
|
->addCondition('0');
|
||||||
$objConditional3->getStyle()->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_GREEN);
|
$objConditional3->getStyle()->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_GREEN);
|
||||||
$objConditional3->getStyle()->getFont()->setBold(true);
|
$objConditional3->getStyle()->getFont()->setBold(true);
|
||||||
$objConditional3->getStyle()->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE);
|
$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
|
// 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()->duplicateConditionalStyle(
|
||||||
$objPHPExcel->getActiveSheet()->getStyle('B2')->getConditionalStyles(),
|
$objPHPExcel->getActiveSheet()->getStyle('B2')->getConditionalStyles(),
|
||||||
'B3:B7'
|
'B3:B7'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// Set fonts
|
// 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('A1')->getFont()->setBold(true);
|
||||||
$objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setBold(true);
|
$objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setBold(true);
|
||||||
$objPHPExcel->getActiveSheet()->getStyle('A7')->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.
|
// 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()->setOddHeader('&L&BPersonal cash register&RPrinted on &D');
|
||||||
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&L&B' . $objPHPExcel->getProperties()->getTitle() . '&RPage &P of &N');
|
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&L&B' . $objPHPExcel->getProperties()->getTitle() . '&RPage &P of &N');
|
||||||
|
|
||||||
|
|
||||||
// Set page orientation and size
|
// 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()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT);
|
||||||
$objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
|
$objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
|
||||||
|
|
||||||
|
|
||||||
// Rename worksheet
|
// Rename worksheet
|
||||||
echo date('H:i:s') , " Rename worksheet" , PHP_EOL;
|
echo date('H:i:s') , " Rename worksheet" , EOL;
|
||||||
$objPHPExcel->getActiveSheet()->setTitle('Invoice');
|
$objPHPExcel->getActiveSheet()->setTitle('Invoice');
|
||||||
|
|
||||||
|
|
||||||
@ -152,14 +156,15 @@ $objPHPExcel->setActiveSheetIndex(0);
|
|||||||
|
|
||||||
|
|
||||||
// Save Excel 2007 file
|
// 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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
$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 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 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;
|
||||||
|
@ -27,6 +27,10 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
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');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
@ -35,11 +39,11 @@ require_once '../Classes/PHPExcel.php';
|
|||||||
|
|
||||||
|
|
||||||
// Create new PHPExcel object
|
// 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();
|
$objPHPExcel = new PHPExcel();
|
||||||
|
|
||||||
// Set document properties
|
// 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")
|
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||||
->setLastModifiedBy("Maarten Balliauw")
|
->setLastModifiedBy("Maarten Balliauw")
|
||||||
->setTitle("Office 2007 XLSX Test Document")
|
->setTitle("Office 2007 XLSX Test Document")
|
||||||
@ -50,7 +54,7 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
|||||||
|
|
||||||
|
|
||||||
// Create a first sheet
|
// 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->setActiveSheetIndex(0);
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Firstname")
|
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Firstname")
|
||||||
->setCellValue('B1', "Lastname")
|
->setCellValue('B1', "Lastname")
|
||||||
@ -80,14 +84,20 @@ $objPHPExcel->setActiveSheetIndex(0);
|
|||||||
|
|
||||||
|
|
||||||
// Save Excel 2007 file
|
// 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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
$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 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 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;
|
||||||
|
@ -27,19 +27,16 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
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');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
/** Include PHPExcel */
|
/** Include PHPExcel */
|
||||||
require_once '../Classes/PHPExcel.php';
|
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
|
// Create new PHPExcel object
|
||||||
echo date('H:i:s').' Create new PHPExcel object'.EOL;
|
echo date('H:i:s').' Create new PHPExcel object'.EOL;
|
||||||
$objPHPExcel = new PHPExcel();
|
$objPHPExcel = new PHPExcel();
|
||||||
@ -139,15 +136,16 @@ $objPHPExcel->setActiveSheetIndex(0);
|
|||||||
echo date('H:i:s').' Write to Excel2007 format'.EOL;
|
echo date('H:i:s').' Write to Excel2007 format'.EOL;
|
||||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
$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
|
// Save Excel5 file
|
||||||
echo date('H:i:s').' Write to Excel5 format'.EOL;
|
echo date('H:i:s').' Write to Excel5 format'.EOL;
|
||||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
$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 memory peak usage
|
||||||
echo date('H:i:s').' Peak memory usage: '.(memory_get_peak_usage(true) / 1024 / 1024).' MB'.EOL;
|
echo date('H:i:s').' Peak memory usage: '.(memory_get_peak_usage(true) / 1024 / 1024).' MB'.EOL;
|
||||||
|
|
||||||
// Echo done
|
// 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;
|
||||||
|
@ -27,6 +27,10 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
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');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
@ -35,11 +39,11 @@ require_once '../Classes/PHPExcel.php';
|
|||||||
|
|
||||||
|
|
||||||
// Create new PHPExcel object
|
// 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();
|
$objPHPExcel = new PHPExcel();
|
||||||
|
|
||||||
// Set document properties
|
// 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")
|
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||||
->setLastModifiedBy("Maarten Balliauw")
|
->setLastModifiedBy("Maarten Balliauw")
|
||||||
->setTitle("Office 2007 XLSX Test Document")
|
->setTitle("Office 2007 XLSX Test Document")
|
||||||
@ -50,7 +54,7 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
|||||||
|
|
||||||
|
|
||||||
// Add some data
|
// 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->setActiveSheetIndex(0);
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Hello');
|
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Hello');
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B2', 'world!');
|
$objPHPExcel->getActiveSheet()->setCellValue('B2', 'world!');
|
||||||
@ -58,19 +62,19 @@ $objPHPExcel->getActiveSheet()->setCellValue('C1', 'Hello');
|
|||||||
$objPHPExcel->getActiveSheet()->setCellValue('D2', 'world!');
|
$objPHPExcel->getActiveSheet()->setCellValue('D2', 'world!');
|
||||||
|
|
||||||
// Rename worksheet
|
// Rename worksheet
|
||||||
echo date('H:i:s') , " Rename worksheet" , PHP_EOL;
|
echo date('H:i:s') , " Rename worksheet" , EOL;
|
||||||
$objPHPExcel->getActiveSheet()->setTitle('Simple');
|
$objPHPExcel->getActiveSheet()->setTitle('Simple');
|
||||||
|
|
||||||
|
|
||||||
// Set document security
|
// 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()->setLockWindows(true);
|
||||||
$objPHPExcel->getSecurity()->setLockStructure(true);
|
$objPHPExcel->getSecurity()->setLockStructure(true);
|
||||||
$objPHPExcel->getSecurity()->setWorkbookPassword("PHPExcel");
|
$objPHPExcel->getSecurity()->setWorkbookPassword("PHPExcel");
|
||||||
|
|
||||||
|
|
||||||
// Set sheet security
|
// 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()->setPassword('PHPExcel');
|
||||||
$objPHPExcel->getActiveSheet()->getProtection()->setSheet(true); // This should be enabled in order to enable any of the following!
|
$objPHPExcel->getActiveSheet()->getProtection()->setSheet(true); // This should be enabled in order to enable any of the following!
|
||||||
$objPHPExcel->getActiveSheet()->getProtection()->setSort(true);
|
$objPHPExcel->getActiveSheet()->getProtection()->setSort(true);
|
||||||
@ -83,14 +87,15 @@ $objPHPExcel->setActiveSheetIndex(0);
|
|||||||
|
|
||||||
|
|
||||||
// Save Excel 2007 file
|
// 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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
$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 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 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;
|
||||||
|
@ -27,6 +27,10 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
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');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
@ -35,11 +39,11 @@ require_once '../Classes/PHPExcel.php';
|
|||||||
|
|
||||||
|
|
||||||
// Create new PHPExcel object
|
// 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();
|
$objPHPExcel = new PHPExcel();
|
||||||
|
|
||||||
// Set document properties
|
// 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")
|
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||||
->setLastModifiedBy("Maarten Balliauw")
|
->setLastModifiedBy("Maarten Balliauw")
|
||||||
->setTitle("Office 2007 XLSX Test Document")
|
->setTitle("Office 2007 XLSX Test Document")
|
||||||
@ -50,7 +54,7 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
|||||||
|
|
||||||
|
|
||||||
// Add some data
|
// 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->setActiveSheetIndex(0);
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Hello');
|
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Hello');
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B2', 'world!');
|
$objPHPExcel->getActiveSheet()->setCellValue('B2', 'world!');
|
||||||
@ -58,19 +62,19 @@ $objPHPExcel->getActiveSheet()->setCellValue('C1', 'Hello');
|
|||||||
$objPHPExcel->getActiveSheet()->setCellValue('D2', 'world!');
|
$objPHPExcel->getActiveSheet()->setCellValue('D2', 'world!');
|
||||||
|
|
||||||
// Rename worksheet
|
// Rename worksheet
|
||||||
echo date('H:i:s') , " Rename worksheet" , PHP_EOL;
|
echo date('H:i:s') , " Rename worksheet" , EOL;
|
||||||
$objPHPExcel->getActiveSheet()->setTitle('Simple');
|
$objPHPExcel->getActiveSheet()->setTitle('Simple');
|
||||||
|
|
||||||
|
|
||||||
// Set document security
|
// 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()->setLockWindows(true);
|
||||||
$objPHPExcel->getSecurity()->setLockStructure(true);
|
$objPHPExcel->getSecurity()->setLockStructure(true);
|
||||||
$objPHPExcel->getSecurity()->setWorkbookPassword("PHPExcel");
|
$objPHPExcel->getSecurity()->setWorkbookPassword("PHPExcel");
|
||||||
|
|
||||||
|
|
||||||
// Set sheet security
|
// 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()->setPassword('PHPExcel');
|
||||||
$objPHPExcel->getActiveSheet()->getProtection()->setSheet(true); // This should be enabled in order to enable any of the following!
|
$objPHPExcel->getActiveSheet()->getProtection()->setSheet(true); // This should be enabled in order to enable any of the following!
|
||||||
$objPHPExcel->getActiveSheet()->getProtection()->setSort(true);
|
$objPHPExcel->getActiveSheet()->getProtection()->setSort(true);
|
||||||
@ -83,14 +87,15 @@ $objPHPExcel->setActiveSheetIndex(0);
|
|||||||
|
|
||||||
|
|
||||||
// Save Excel 2007 file
|
// 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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
$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 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 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;
|
||||||
|
@ -27,6 +27,11 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
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');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
@ -35,177 +40,178 @@ require_once '../Classes/PHPExcel.php';
|
|||||||
|
|
||||||
|
|
||||||
// List functions
|
// 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();
|
$objCalc = PHPExcel_Calculation::getInstance();
|
||||||
print_r($objCalc->listFunctionNames());
|
print_r($objCalc->listFunctionNames());
|
||||||
|
|
||||||
// Create new PHPExcel object
|
// 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();
|
$objPHPExcel = new PHPExcel();
|
||||||
|
|
||||||
// Add some data, we will use some formulas here
|
// Add some data, we will use some formulas here
|
||||||
echo date('H:i:s') , " Add some data and formulas" , PHP_EOL;
|
echo date('H:i:s') , " Add some data and formulas" , EOL;
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A14', 'Count:');
|
$objPHPExcel->getActiveSheet()->setCellValue('A14', 'Count:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A15', 'Sum:');
|
->setCellValue('A15', 'Sum:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A16', 'Max:');
|
->setCellValue('A16', 'Max:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A17', 'Min:');
|
->setCellValue('A17', 'Min:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A18', 'Average:');
|
->setCellValue('A18', 'Average:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A19', 'Median:');
|
->setCellValue('A19', 'Median:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A20', 'Mode:');
|
->setCellValue('A20', 'Mode:');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A22', 'CountA:');
|
$objPHPExcel->getActiveSheet()->setCellValue('A22', 'CountA:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A23', 'MaxA:');
|
->setCellValue('A23', 'MaxA:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A24', 'MinA:');
|
->setCellValue('A24', 'MinA:');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A26', 'StDev:');
|
$objPHPExcel->getActiveSheet()->setCellValue('A26', 'StDev:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A27', 'StDevA:');
|
->setCellValue('A27', 'StDevA:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A28', 'StDevP:');
|
->setCellValue('A28', 'StDevP:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A29', 'StDevPA:');
|
->setCellValue('A29', 'StDevPA:');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A31', 'DevSq:');
|
$objPHPExcel->getActiveSheet()->setCellValue('A31', 'DevSq:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A32', 'Var:');
|
->setCellValue('A32', 'Var:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A33', 'VarA:');
|
->setCellValue('A33', 'VarA:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A34', 'VarP:');
|
->setCellValue('A34', 'VarP:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A35', 'VarPA:');
|
->setCellValue('A35', 'VarPA:');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A37', 'Date:');
|
$objPHPExcel->getActiveSheet()->setCellValue('A37', 'Date:');
|
||||||
|
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Range 1');
|
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Range 1')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B2', 2);
|
->setCellValue('B2', 2)
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B3', 8);
|
->setCellValue('B3', 8)
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B4', 10);
|
->setCellValue('B4', 10)
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B5', True);
|
->setCellValue('B5', True)
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B6', False);
|
->setCellValue('B6', False)
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B7', 'Text String');
|
->setCellValue('B7', 'Text String')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B9', '22');
|
->setCellValue('B9', '22')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B10', 4);
|
->setCellValue('B10', 4)
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B11', 6);
|
->setCellValue('B11', 6)
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B12', 12);
|
->setCellValue('B12', 12);
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B14', '=COUNT(B2:B12)');
|
$objPHPExcel->getActiveSheet()->setCellValue('B14', '=COUNT(B2:B12)')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B15', '=SUM(B2:B12)');
|
->setCellValue('B15', '=SUM(B2:B12)')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B16', '=MAX(B2:B12)');
|
->setCellValue('B16', '=MAX(B2:B12)')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B17', '=MIN(B2:B12)');
|
->setCellValue('B17', '=MIN(B2:B12)')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B18', '=AVERAGE(B2:B12)');
|
->setCellValue('B18', '=AVERAGE(B2:B12)')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B19', '=MEDIAN(B2:B12)');
|
->setCellValue('B19', '=MEDIAN(B2:B12)')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B20', '=MODE(B2:B12)');
|
->setCellValue('B20', '=MODE(B2:B12)');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B22', '=COUNTA(B2:B12)');
|
$objPHPExcel->getActiveSheet()->setCellValue('B22', '=COUNTA(B2:B12)')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B23', '=MAXA(B2:B12)');
|
->setCellValue('B23', '=MAXA(B2:B12)')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B24', '=MINA(B2:B12)');
|
->setCellValue('B24', '=MINA(B2:B12)');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B26', '=STDEV(B2:B12)');
|
$objPHPExcel->getActiveSheet()->setCellValue('B26', '=STDEV(B2:B12)')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B27', '=STDEVA(B2:B12)');
|
->setCellValue('B27', '=STDEVA(B2:B12)')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B28', '=STDEVP(B2:B12)');
|
->setCellValue('B28', '=STDEVP(B2:B12)')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B29', '=STDEVPA(B2:B12)');
|
->setCellValue('B29', '=STDEVPA(B2:B12)');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B31', '=DEVSQ(B2:B12)');
|
$objPHPExcel->getActiveSheet()->setCellValue('B31', '=DEVSQ(B2:B12)')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B32', '=VAR(B2:B12)');
|
->setCellValue('B32', '=VAR(B2:B12)')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B33', '=VARA(B2:B12)');
|
->setCellValue('B33', '=VARA(B2:B12)')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B34', '=VARP(B2:B12)');
|
->setCellValue('B34', '=VARP(B2:B12)')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B35', '=VARPA(B2:B12)');
|
->setCellValue('B35', '=VARPA(B2:B12)');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B37', '=DATE(2007, 12, 21)');
|
$objPHPExcel->getActiveSheet()->setCellValue('B37', '=DATE(2007, 12, 21)')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B38', '=DATEDIF( DATE(2007, 12, 21), DATE(2007, 12, 22), "D" )');
|
->setCellValue('B38', '=DATEDIF( DATE(2007, 12, 21), DATE(2007, 12, 22), "D" )')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B39', '=DATEVALUE("01-Feb-2006 10:06 AM")');
|
->setCellValue('B39', '=DATEVALUE("01-Feb-2006 10:06 AM")')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B40', '=DAY( DATE(2006, 1, 2) )');
|
->setCellValue('B40', '=DAY( DATE(2006, 1, 2) )')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B41', '=DAYS360( DATE(2002, 2, 3), DATE(2005, 5, 31) )');
|
->setCellValue('B41', '=DAYS360( DATE(2002, 2, 3), DATE(2005, 5, 31) )');
|
||||||
|
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C1', 'Range 2');
|
$objPHPExcel->getActiveSheet()->setCellValue('C1', 'Range 2')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C2', 1);
|
->setCellValue('C2', 1)
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C3', 2);
|
->setCellValue('C3', 2)
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C4', 2);
|
->setCellValue('C4', 2)
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C5', 3);
|
->setCellValue('C5', 3)
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C6', 3);
|
->setCellValue('C6', 3)
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C7', 3);
|
->setCellValue('C7', 3)
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C8', '0');
|
->setCellValue('C8', '0')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C9', 4);
|
->setCellValue('C9', 4)
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C10', 4);
|
->setCellValue('C10', 4)
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C11', 4);
|
->setCellValue('C11', 4)
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C12', 4);
|
->setCellValue('C12', 4);
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C14', '=COUNT(C2:C12)');
|
$objPHPExcel->getActiveSheet()->setCellValue('C14', '=COUNT(C2:C12)')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C15', '=SUM(C2:C12)');
|
->setCellValue('C15', '=SUM(C2:C12)')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C16', '=MAX(C2:C12)');
|
->setCellValue('C16', '=MAX(C2:C12)')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C17', '=MIN(C2:C12)');
|
->setCellValue('C17', '=MIN(C2:C12)')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C18', '=AVERAGE(C2:C12)');
|
->setCellValue('C18', '=AVERAGE(C2:C12)')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C19', '=MEDIAN(C2:C12)');
|
->setCellValue('C19', '=MEDIAN(C2:C12)')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C20', '=MODE(C2:C12)');
|
->setCellValue('C20', '=MODE(C2:C12)');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C22', '=COUNTA(C2:C12)');
|
$objPHPExcel->getActiveSheet()->setCellValue('C22', '=COUNTA(C2:C12)')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C23', '=MAXA(C2:C12)');
|
->setCellValue('C23', '=MAXA(C2:C12)')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C24', '=MINA(C2:C12)');
|
->setCellValue('C24', '=MINA(C2:C12)');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C26', '=STDEV(C2:C12)');
|
$objPHPExcel->getActiveSheet()->setCellValue('C26', '=STDEV(C2:C12)')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C27', '=STDEVA(C2:C12)');
|
->setCellValue('C27', '=STDEVA(C2:C12)')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C28', '=STDEVP(C2:C12)');
|
->setCellValue('C28', '=STDEVP(C2:C12)')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C29', '=STDEVPA(C2:C12)');
|
->setCellValue('C29', '=STDEVPA(C2:C12)');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C31', '=DEVSQ(C2:C12)');
|
$objPHPExcel->getActiveSheet()->setCellValue('C31', '=DEVSQ(C2:C12)')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C32', '=VAR(C2:C12)');
|
->setCellValue('C32', '=VAR(C2:C12)')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C33', '=VARA(C2:C12)');
|
->setCellValue('C33', '=VARA(C2:C12)')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C34', '=VARP(C2:C12)');
|
->setCellValue('C34', '=VARP(C2:C12)')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C35', '=VARPA(C2:C12)');
|
->setCellValue('C35', '=VARPA(C2:C12)');
|
||||||
|
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('D1', 'Range 3');
|
$objPHPExcel->getActiveSheet()->setCellValue('D1', 'Range 3')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('D2', 2);
|
->setCellValue('D2', 2)
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('D3', 3);
|
->setCellValue('D3', 3)
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('D4', 4);
|
->setCellValue('D4', 4);
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('D14', '=((D2 * D3) + D4) & " should be 10"');
|
$objPHPExcel->getActiveSheet()->setCellValue('D14', '=((D2 * D3) + D4) & " should be 10"');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('E12', 'Other functions');
|
$objPHPExcel->getActiveSheet()->setCellValue('E12', 'Other functions')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('E14', '=PI()');
|
->setCellValue('E14', '=PI()')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('E15', '=RAND()');
|
->setCellValue('E15', '=RAND()')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('E16', '=RANDBETWEEN(5, 10)');
|
->setCellValue('E16', '=RANDBETWEEN(5, 10)');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('E17', 'Count of both ranges:');
|
$objPHPExcel->getActiveSheet()->setCellValue('E17', 'Count of both ranges:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('F17', '=COUNT(B2:C12)');
|
->setCellValue('F17', '=COUNT(B2:C12)');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('E18', 'Total of both ranges:');
|
$objPHPExcel->getActiveSheet()->setCellValue('E18', 'Total of both ranges:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('F18', '=SUM(B2:C12)');
|
->setCellValue('F18', '=SUM(B2:C12)');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('E19', 'Maximum of both ranges:');
|
$objPHPExcel->getActiveSheet()->setCellValue('E19', 'Maximum of both ranges:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('F19', '=MAX(B2:C12)');
|
->setCellValue('F19', '=MAX(B2:C12)');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('E20', 'Minimum of both ranges:');
|
$objPHPExcel->getActiveSheet()->setCellValue('E20', 'Minimum of both ranges:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('F20', '=MIN(B2:C12)');
|
->setCellValue('F20', '=MIN(B2:C12)');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('E21', 'Average of both ranges:');
|
$objPHPExcel->getActiveSheet()->setCellValue('E21', 'Average of both ranges:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('F21', '=AVERAGE(B2:C12)');
|
->setCellValue('F21', '=AVERAGE(B2:C12)');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('E22', 'Median of both ranges:');
|
$objPHPExcel->getActiveSheet()->setCellValue('E22', 'Median of both ranges:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('F22', '=MEDIAN(B2:C12)');
|
->setCellValue('F22', '=MEDIAN(B2:C12)');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('E23', 'Mode of both ranges:');
|
$objPHPExcel->getActiveSheet()->setCellValue('E23', 'Mode of both ranges:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('F23', '=MODE(B2:C12)');
|
->setCellValue('F23', '=MODE(B2:C12)');
|
||||||
|
|
||||||
|
|
||||||
// Calculated data
|
// 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 ($col = 'B'; $col != 'G'; ++$col) {
|
||||||
for($row = 14; $row <= 41; ++$row) {
|
for($row = 14; $row <= 41; ++$row) {
|
||||||
if ((!is_null($formula = $objPHPExcel->getActiveSheet()->getCell($col.$row)->getValue())) &&
|
if ((!is_null($formula = $objPHPExcel->getActiveSheet()->getCell($col.$row)->getValue())) &&
|
||||||
($formula[0] == '=')) {
|
($formula[0] == '=')) {
|
||||||
echo 'Value of ' , $col , $row , ' [' , $formula , ']: ' ,
|
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
|
// 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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
$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 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 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;
|
||||||
|
@ -27,6 +27,10 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
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');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
@ -36,14 +40,15 @@ include "05featuredemo.inc.php";
|
|||||||
require_once '../Classes/PHPExcel/IOFactory.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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
$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 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 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;
|
||||||
|
@ -27,6 +27,11 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
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');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
@ -35,12 +40,12 @@ require_once '../Classes/PHPExcel.php';
|
|||||||
|
|
||||||
|
|
||||||
// Create new PHPExcel object
|
// 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();
|
$objPHPExcel = new PHPExcel();
|
||||||
|
|
||||||
|
|
||||||
// Set document properties
|
// 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")
|
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||||
->setLastModifiedBy("Maarten Balliauw")
|
->setLastModifiedBy("Maarten Balliauw")
|
||||||
->setTitle("Office 2007 XLSX Test Document")
|
->setTitle("Office 2007 XLSX Test Document")
|
||||||
@ -51,17 +56,17 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
|||||||
|
|
||||||
|
|
||||||
// Create a first sheet
|
// 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->setActiveSheetIndex(0);
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Cell B3 and B5 contain data validation...");
|
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Cell B3 and B5 contain data validation...")
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A3', "Number:");
|
->setCellValue('A3', "Number:")
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B3', "10");
|
->setCellValue('B3', "10")
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A5', "List:");
|
->setCellValue('A5', "List:")
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B5', "Item A");
|
->setCellValue('B5', "Item A");
|
||||||
|
|
||||||
|
|
||||||
// Set data validation
|
// 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 = $objPHPExcel->getActiveSheet()->getCell('B3')->getDataValidation();
|
||||||
$objValidation->setType( PHPExcel_Cell_DataValidation::TYPE_WHOLE );
|
$objValidation->setType( PHPExcel_Cell_DataValidation::TYPE_WHOLE );
|
||||||
$objValidation->setErrorStyle( PHPExcel_Cell_DataValidation::STYLE_STOP );
|
$objValidation->setErrorStyle( PHPExcel_Cell_DataValidation::STYLE_STOP );
|
||||||
@ -94,14 +99,15 @@ $objPHPExcel->setActiveSheetIndex(0);
|
|||||||
|
|
||||||
|
|
||||||
// Save Excel 2007 file
|
// 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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
$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 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 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;
|
||||||
|
@ -27,6 +27,11 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
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');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
@ -35,12 +40,12 @@ require_once '../Classes/PHPExcel.php';
|
|||||||
|
|
||||||
|
|
||||||
// Create new PHPExcel object
|
// 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();
|
$objPHPExcel = new PHPExcel();
|
||||||
|
|
||||||
|
|
||||||
// Set document properties
|
// 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")
|
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||||
->setLastModifiedBy("Maarten Balliauw")
|
->setLastModifiedBy("Maarten Balliauw")
|
||||||
->setTitle("Office 2007 XLSX Test Document")
|
->setTitle("Office 2007 XLSX Test Document")
|
||||||
@ -51,17 +56,17 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
|||||||
|
|
||||||
|
|
||||||
// Create a first sheet
|
// 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->setActiveSheetIndex(0);
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Cell B3 and B5 contain data validation...");
|
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Cell B3 and B5 contain data validation...")
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A3', "Number:");
|
->setCellValue('A3', "Number:")
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B3', "10");
|
->setCellValue('B3', "10")
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A5', "List:");
|
->setCellValue('A5', "List:")
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B5', "Item A");
|
->setCellValue('B5', "Item A");
|
||||||
|
|
||||||
|
|
||||||
// Set data validation
|
// 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 = $objPHPExcel->getActiveSheet()->getCell('B3')->getDataValidation();
|
||||||
$objValidation->setType( PHPExcel_Cell_DataValidation::TYPE_WHOLE );
|
$objValidation->setType( PHPExcel_Cell_DataValidation::TYPE_WHOLE );
|
||||||
$objValidation->setErrorStyle( PHPExcel_Cell_DataValidation::STYLE_STOP );
|
$objValidation->setErrorStyle( PHPExcel_Cell_DataValidation::STYLE_STOP );
|
||||||
@ -94,14 +99,15 @@ $objPHPExcel->setActiveSheetIndex(0);
|
|||||||
|
|
||||||
|
|
||||||
// Save Excel 2007 file
|
// 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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
$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 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 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;
|
||||||
|
@ -27,6 +27,11 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
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');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
@ -36,31 +41,32 @@ include "05featuredemo.inc.php";
|
|||||||
require_once '../Classes/PHPExcel/IOFactory.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(',')
|
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'CSV')->setDelimiter(',')
|
||||||
->setEnclosure('"')
|
->setEnclosure('"')
|
||||||
->setLineEnding("\r\n")
|
->setLineEnding("\r\n")
|
||||||
->setSheetIndex(0)
|
->setSheetIndex(0)
|
||||||
->save(str_replace('.php', '.csv', __FILE__));
|
->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(',')
|
$objReader = PHPExcel_IOFactory::createReader('CSV')->setDelimiter(',')
|
||||||
->setEnclosure('"')
|
->setEnclosure('"')
|
||||||
->setLineEnding("\r\n")
|
->setLineEnding("\r\n")
|
||||||
->setSheetIndex(0);
|
->setSheetIndex(0);
|
||||||
$objPHPExcelFromCSV = $objReader->load(str_replace('.php', '.csv', __FILE__));
|
$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 = PHPExcel_IOFactory::createWriter($objPHPExcelFromCSV, 'Excel2007');
|
||||||
$objWriter2007->save(str_replace('.php', '.xlsx', __FILE__));
|
$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 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 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;
|
||||||
|
@ -27,6 +27,11 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
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');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
@ -36,16 +41,17 @@ include "05featuredemo.inc.php";
|
|||||||
require_once '../Classes/PHPExcel/IOFactory.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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'HTML');
|
||||||
$objWriter->setSheetIndex(0);
|
$objWriter->setSheetIndex(0);
|
||||||
//$objWriter->setImagesRoot('http://www.example.com');
|
//$objWriter->setImagesRoot('http://www.example.com');
|
||||||
$objWriter->save(str_replace('.php', '.htm', __FILE__));
|
$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 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 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;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006 - 2011 PHPExcel
|
* Copyright (C) 2006 - 2012 PHPExcel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -20,13 +20,18 @@
|
|||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package 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
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
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');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
@ -46,28 +51,6 @@ $objPHPExcel = new PHPExcel();
|
|||||||
// Add some data, we will use some formulas here
|
// Add some data, we will use some formulas here
|
||||||
echo date('H:i:s') . " Add some data\n";
|
echo date('H:i:s') . " Add some data\n";
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A14', 'Count:');
|
$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('B1', 'Range 1');
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B2', 2);
|
$objPHPExcel->getActiveSheet()->setCellValue('B2', 2);
|
||||||
@ -82,27 +65,6 @@ $objPHPExcel->getActiveSheet()->setCellValue('B11', 6);
|
|||||||
$objPHPExcel->getActiveSheet()->setCellValue('B12', 12);
|
$objPHPExcel->getActiveSheet()->setCellValue('B12', 12);
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B14', '=COUNT(B2:B12)');
|
$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('C1', 'Range 2');
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C2', 1);
|
$objPHPExcel->getActiveSheet()->setCellValue('C2', 1);
|
||||||
@ -118,28 +80,6 @@ $objPHPExcel->getActiveSheet()->setCellValue('C11', 4);
|
|||||||
$objPHPExcel->getActiveSheet()->setCellValue('C12', 4);
|
$objPHPExcel->getActiveSheet()->setCellValue('C12', 4);
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C14', '=COUNT(C2:C12)');
|
$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('D1', 'Range 3');
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('D2', 2);
|
$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('E14', 'Count of both ranges:');
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('F14', '=COUNT(B2:C12)');
|
$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
|
// Calculated data
|
||||||
echo date('H:i:s') . " Calculated data\n";
|
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 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 memory peak usage
|
||||||
echo date('H:i:s') . " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB\r\n";
|
echo date('H:i:s') . " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB\r\n";
|
||||||
|
|
||||||
// Echo done
|
// Echo done
|
||||||
echo date('H:i:s') . " Done.\r\n";
|
echo date('H:i:s') . " Done" , EOL;
|
||||||
|
@ -27,6 +27,11 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
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');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
@ -35,11 +40,11 @@ require_once '../Classes/PHPExcel.php';
|
|||||||
|
|
||||||
|
|
||||||
// Create new PHPExcel object
|
// 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();
|
$objPHPExcel = new PHPExcel();
|
||||||
|
|
||||||
// Set document properties
|
// 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")
|
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||||
->setLastModifiedBy("Maarten Balliauw")
|
->setLastModifiedBy("Maarten Balliauw")
|
||||||
->setTitle("Office 2007 XLSX Test Document")
|
->setTitle("Office 2007 XLSX Test Document")
|
||||||
@ -50,7 +55,7 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
|||||||
|
|
||||||
|
|
||||||
// Add some data
|
// 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->setActiveSheetIndex(0);
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Firstname:')
|
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Firstname:')
|
||||||
->setCellValue('A2', 'Lastname:')
|
->setCellValue('A2', 'Lastname:')
|
||||||
@ -60,25 +65,25 @@ $objPHPExcel->getActiveSheet()->setCellValue('A1', 'Firstname:')
|
|||||||
->setCellValue('B3', '=B1 & " " & B2');
|
->setCellValue('B3', '=B1 & " " & B2');
|
||||||
|
|
||||||
// Define named ranges
|
// 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('PersonName', $objPHPExcel->getActiveSheet(), 'B1') );
|
||||||
$objPHPExcel->addNamedRange( new PHPExcel_NamedRange('PersonLN', $objPHPExcel->getActiveSheet(), 'B2') );
|
$objPHPExcel->addNamedRange( new PHPExcel_NamedRange('PersonLN', $objPHPExcel->getActiveSheet(), 'B2') );
|
||||||
|
|
||||||
// Rename named ranges
|
// 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');
|
$objPHPExcel->getNamedRange('PersonName')->setName('PersonFN');
|
||||||
|
|
||||||
// Rename worksheet
|
// Rename worksheet
|
||||||
echo date('H:i:s') , " Rename worksheet" , PHP_EOL;
|
echo date('H:i:s') , " Rename worksheet" , EOL;
|
||||||
$objPHPExcel->getActiveSheet()->setTitle('Person');
|
$objPHPExcel->getActiveSheet()->setTitle('Person');
|
||||||
|
|
||||||
|
|
||||||
// Create a new worksheet, after the default sheet
|
// 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();
|
$objPHPExcel->createSheet();
|
||||||
|
|
||||||
// Add some data to the second sheet, resembling some different data types
|
// 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->setActiveSheetIndex(1);
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Firstname:')
|
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Firstname:')
|
||||||
->setCellValue('A2', 'Lastname:')
|
->setCellValue('A2', 'Lastname:')
|
||||||
@ -88,13 +93,13 @@ $objPHPExcel->getActiveSheet()->setCellValue('A1', 'Firstname:')
|
|||||||
->setCellValue('B3', '=PersonFN & " " & PersonLN');
|
->setCellValue('B3', '=PersonFN & " " & PersonLN');
|
||||||
|
|
||||||
// Resolve range
|
// Resolve range
|
||||||
echo date('H:i:s') , " Resolve range" , PHP_EOL;
|
echo date('H:i:s') , " Resolve range" , EOL;
|
||||||
echo 'Cell B1 {=PersonFN}: ' , $objPHPExcel->getActiveSheet()->getCell('B1')->getCalculatedValue() , PHP_EOL;
|
echo 'Cell B1 {=PersonFN}: ' , $objPHPExcel->getActiveSheet()->getCell('B1')->getCalculatedValue() , EOL;
|
||||||
echo 'Cell B3 {=PersonFN & " " & PersonLN}: ' , $objPHPExcel->getActiveSheet()->getCell('B3')->getCalculatedValue() , PHP_EOL;
|
echo 'Cell B3 {=PersonFN & " " & PersonLN}: ' , $objPHPExcel->getActiveSheet()->getCell('B3')->getCalculatedValue() , EOL;
|
||||||
echo 'Cell Person!B1: ' , $objPHPExcel->getActiveSheet()->getCell('Person!B1')->getCalculatedValue() , PHP_EOL;
|
echo 'Cell Person!B1: ' , $objPHPExcel->getActiveSheet()->getCell('Person!B1')->getCalculatedValue() , EOL;
|
||||||
|
|
||||||
// Rename worksheet
|
// Rename worksheet
|
||||||
echo date('H:i:s') , " Rename worksheet" , PHP_EOL;
|
echo date('H:i:s') , " Rename worksheet" , EOL;
|
||||||
$objPHPExcel->getActiveSheet()->setTitle('Person (cloned)');
|
$objPHPExcel->getActiveSheet()->setTitle('Person (cloned)');
|
||||||
|
|
||||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
// 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
|
// 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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
$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 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 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;
|
||||||
|
@ -27,6 +27,11 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
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');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
@ -38,17 +43,18 @@ if (!file_exists("14excel5.xls")) {
|
|||||||
exit("Please run 14excel5.php first.\n");
|
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");
|
$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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
$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 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 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;
|
||||||
|
@ -27,6 +27,11 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
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');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
@ -46,14 +51,14 @@ $rendererLibrary = 'domPDF0.6.0beta3';
|
|||||||
$rendererLibraryPath = dirname(__FILE__).'/../../../libraries/PDF/' . $rendererLibrary;
|
$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);
|
$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);
|
$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(
|
if (!PHPExcel_Settings::setPdfRenderer(
|
||||||
$rendererName,
|
$rendererName,
|
||||||
@ -61,7 +66,7 @@ if (!PHPExcel_Settings::setPdfRenderer(
|
|||||||
)) {
|
)) {
|
||||||
die(
|
die(
|
||||||
'NOTICE: Please set the $rendererName and $rendererLibraryPath values' .
|
'NOTICE: Please set the $rendererName and $rendererLibraryPath values' .
|
||||||
PHP_EOL .
|
EOL .
|
||||||
'at the top of this script as appropriate for your directory structure'
|
'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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF');
|
||||||
$objWriter->setSheetIndex(0);
|
$objWriter->setSheetIndex(0);
|
||||||
$objWriter->save(str_replace('.php', '_'.$rendererName.'.pdf', __FILE__));
|
$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 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 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;
|
||||||
|
@ -27,6 +27,11 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
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');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
@ -35,11 +40,11 @@ require_once '../Classes/PHPExcel.php';
|
|||||||
|
|
||||||
|
|
||||||
// Create new PHPExcel object
|
// 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();
|
$objPHPExcel = new PHPExcel();
|
||||||
|
|
||||||
// Set document properties
|
// 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")
|
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||||
->setLastModifiedBy("Maarten Balliauw")
|
->setLastModifiedBy("Maarten Balliauw")
|
||||||
->setTitle("Office 2007 XLSX Test Document")
|
->setTitle("Office 2007 XLSX Test Document")
|
||||||
@ -50,7 +55,7 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
|||||||
|
|
||||||
|
|
||||||
// Add some data
|
// 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->setActiveSheetIndex(0);
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->getStyle('A1:T100')->applyFromArray(
|
$objPHPExcel->getActiveSheet()->getStyle('A1:T100')->applyFromArray(
|
||||||
@ -74,14 +79,15 @@ $objPHPExcel->getActiveSheet()->getStyle('C5:R95')->applyFromArray(
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Save Excel 2007 file
|
// 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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
$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 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 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;
|
||||||
|
@ -27,6 +27,11 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
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');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
@ -35,11 +40,11 @@ require_once '../Classes/PHPExcel.php';
|
|||||||
|
|
||||||
|
|
||||||
// Create new PHPExcel object
|
// 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();
|
$objPHPExcel = new PHPExcel();
|
||||||
|
|
||||||
// Set document properties
|
// 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")
|
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||||
->setLastModifiedBy("Maarten Balliauw")
|
->setLastModifiedBy("Maarten Balliauw")
|
||||||
->setTitle("Office 2007 XLSX Test Document")
|
->setTitle("Office 2007 XLSX Test Document")
|
||||||
@ -50,7 +55,7 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
|||||||
|
|
||||||
|
|
||||||
// Add some data
|
// 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->setActiveSheetIndex(0);
|
||||||
|
|
||||||
$sharedStyle1 = new PHPExcel_Style();
|
$sharedStyle1 = new PHPExcel_Style();
|
||||||
@ -82,14 +87,15 @@ $objPHPExcel->getActiveSheet()->setSharedStyle($sharedStyle1, "A1:T100");
|
|||||||
$objPHPExcel->getActiveSheet()->setSharedStyle($sharedStyle2, "C5:R95");
|
$objPHPExcel->getActiveSheet()->setSharedStyle($sharedStyle2, "C5:R95");
|
||||||
|
|
||||||
// Save Excel 2007 file
|
// 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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
$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 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 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;
|
||||||
|
@ -26,6 +26,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
error_reporting(E_ALL);
|
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');
|
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 = PHPExcel_IOFactory::createReader('Excel2007');
|
||||||
$objReader->setReadFilter( new MyReadFilter() );
|
$objReader->setReadFilter( new MyReadFilter() );
|
||||||
$objPHPExcel = $objReader->load("06largescale.xlsx");
|
$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);
|
$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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
$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 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 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;
|
||||||
|
@ -27,6 +27,10 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
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');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
@ -35,11 +39,11 @@ require_once '../Classes/PHPExcel.php';
|
|||||||
|
|
||||||
|
|
||||||
// Create new PHPExcel object
|
// 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();
|
$objPHPExcel = new PHPExcel();
|
||||||
|
|
||||||
// Set document properties
|
// 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")
|
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||||
->setLastModifiedBy("Maarten Balliauw")
|
->setLastModifiedBy("Maarten Balliauw")
|
||||||
->setTitle("Office 2007 XLSX Test Document")
|
->setTitle("Office 2007 XLSX Test Document")
|
||||||
@ -49,13 +53,13 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
|||||||
->setCategory("Test result file");
|
->setCategory("Test result file");
|
||||||
|
|
||||||
// Generate an image
|
// 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');
|
$gdImage = @imagecreatetruecolor(120, 20) or die('Cannot Initialize new GD image stream');
|
||||||
$textColor = imagecolorallocate($gdImage, 255, 255, 255);
|
$textColor = imagecolorallocate($gdImage, 255, 255, 255);
|
||||||
imagestring($gdImage, 1, 5, 5, 'Created with PHPExcel', $textColor);
|
imagestring($gdImage, 1, 5, 5, 'Created with PHPExcel', $textColor);
|
||||||
|
|
||||||
// Add a drawing to the worksheet
|
// 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 = new PHPExcel_Worksheet_MemoryDrawing();
|
||||||
$objDrawing->setName('Sample image');
|
$objDrawing->setName('Sample image');
|
||||||
$objDrawing->setDescription('Sample image');
|
$objDrawing->setDescription('Sample image');
|
||||||
@ -65,14 +69,15 @@ $objDrawing->setMimeType(PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_DEFAULT);
|
|||||||
$objDrawing->setHeight(36);
|
$objDrawing->setHeight(36);
|
||||||
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
|
$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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
$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 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 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;
|
||||||
|
@ -27,6 +27,10 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
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');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
@ -46,32 +50,32 @@ $rendererLibraryPath = dirname(__FILE__).'/../../../libraries/PDF/' . $rendererL
|
|||||||
|
|
||||||
|
|
||||||
// Read from Excel2007 (.xlsx) template
|
// 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');
|
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
|
||||||
$objPHPExcel = $objReader->load("templates/26template.xlsx");
|
$objPHPExcel = $objReader->load("templates/26template.xlsx");
|
||||||
|
|
||||||
/** at this point, we could do some manipulations with the template, but we skip this step */
|
/** at this point, we could do some manipulations with the template, but we skip this step */
|
||||||
|
|
||||||
// Export to Excel2007 (.xlsx)
|
// 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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
$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)
|
// 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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
$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)
|
// 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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'HTML');
|
||||||
$objWriter->save(str_replace('.php', '.htm', __FILE__));
|
$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)
|
// 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 {
|
try {
|
||||||
if (!PHPExcel_Settings::setPdfRenderer(
|
if (!PHPExcel_Settings::setPdfRenderer(
|
||||||
$rendererName,
|
$rendererName,
|
||||||
@ -79,38 +83,40 @@ try {
|
|||||||
)) {
|
)) {
|
||||||
echo (
|
echo (
|
||||||
'NOTICE: Please set the $rendererName and $rendererLibraryPath values' .
|
'NOTICE: Please set the $rendererName and $rendererLibraryPath values' .
|
||||||
PHP_EOL .
|
EOL .
|
||||||
'at the top of this script as appropriate for your directory structure'
|
'at the top of this script as appropriate for your directory structure' .
|
||||||
|
EOL
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF');
|
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF');
|
||||||
$objWriter->save(str_replace('.php', '.pdf', __FILE__));
|
$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) {
|
} 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
|
// 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 = $objPHPExcel->getActiveSheet();
|
||||||
$objWorksheet->removeRow(1, 2);
|
$objWorksheet->removeRow(1, 2);
|
||||||
|
|
||||||
// Export to CSV (.csv)
|
// 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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'CSV');
|
||||||
$objWriter->save(str_replace('.php', '.csv', __FILE__));
|
$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)
|
// 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->setUseBOM(true);
|
||||||
$objWriter->save(str_replace('.php', '-bom.csv', __FILE__));
|
$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 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 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;
|
||||||
|
@ -27,6 +27,10 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
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');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
@ -35,25 +39,26 @@ require_once '../Classes/PHPExcel.php';
|
|||||||
|
|
||||||
|
|
||||||
// Read from Excel5 (.xls) template
|
// 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');
|
$objReader = PHPExcel_IOFactory::createReader('Excel5');
|
||||||
$objPHPExcel = $objReader->load("templates/27template.xls");
|
$objPHPExcel = $objReader->load("templates/27template.xls");
|
||||||
|
|
||||||
// Export to Excel2007 (.xlsx)
|
// 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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
$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)
|
// 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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
$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 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 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;
|
||||||
|
@ -27,6 +27,10 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
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');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
@ -35,25 +39,25 @@ require_once '../Classes/PHPExcel/IOFactory.php';
|
|||||||
|
|
||||||
|
|
||||||
if (!file_exists("05featuredemo.xlsx")) {
|
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');
|
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
|
||||||
$objPHPExcel = $objReader->load("05featuredemo.xlsx");
|
$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) {
|
foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
|
||||||
echo 'Worksheet - ' , $worksheet->getTitle() , PHP_EOL;
|
echo 'Worksheet - ' , $worksheet->getTitle() , EOL;
|
||||||
|
|
||||||
foreach ($worksheet->getRowIterator() as $row) {
|
foreach ($worksheet->getRowIterator() as $row) {
|
||||||
echo ' Row number - ' , $row->getRowIndex() , PHP_EOL;
|
echo ' Row number - ' , $row->getRowIndex() , EOL;
|
||||||
|
|
||||||
$cellIterator = $row->getCellIterator();
|
$cellIterator = $row->getCellIterator();
|
||||||
$cellIterator->setIterateOnlyExistingCells(false); // Loop all cells, even if it is not set
|
$cellIterator->setIterateOnlyExistingCells(false); // Loop all cells, even if it is not set
|
||||||
foreach ($cellIterator as $cell) {
|
foreach ($cellIterator as $cell) {
|
||||||
if (!is_null($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 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;
|
||||||
|
@ -27,27 +27,29 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
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 */
|
/** PHPExcel */
|
||||||
require_once '../Classes/PHPExcel.php';
|
require_once '../Classes/PHPExcel.php';
|
||||||
|
|
||||||
|
|
||||||
// Set timezone
|
// Set timezone
|
||||||
echo date('H:i:s') , " Set timezone" , PHP_EOL;
|
echo date('H:i:s') , " Set timezone" , EOL;
|
||||||
date_default_timezone_set('UTC');
|
date_default_timezone_set('UTC');
|
||||||
|
|
||||||
// Set value binder
|
// 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() );
|
PHPExcel_Cell::setValueBinder( new PHPExcel_Cell_AdvancedValueBinder() );
|
||||||
|
|
||||||
// Create new PHPExcel object
|
// 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();
|
$objPHPExcel = new PHPExcel();
|
||||||
|
|
||||||
// Set document properties
|
// 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")
|
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||||
->setLastModifiedBy("Maarten Balliauw")
|
->setLastModifiedBy("Maarten Balliauw")
|
||||||
->setTitle("Office 2007 XLSX Test Document")
|
->setTitle("Office 2007 XLSX Test Document")
|
||||||
@ -57,82 +59,85 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
|||||||
->setCategory("Test result file");
|
->setCategory("Test result file");
|
||||||
|
|
||||||
// Set default font
|
// 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()->setName('Arial');
|
||||||
$objPHPExcel->getActiveSheet()->getDefaultStyle()->getFont()->setSize(10);
|
$objPHPExcel->getActiveSheet()->getDefaultStyle()->getFont()->setSize(10);
|
||||||
|
|
||||||
// Set column widths
|
// 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('A')->setAutoSize(true);
|
||||||
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(14);
|
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(14);
|
||||||
|
|
||||||
// Add some data, resembling some different data types
|
// Add some data, 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->getActiveSheet()->setCellValue('A1', 'String value:');
|
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'String value:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Mark Baker');
|
->setCellValue('B1', 'Mark Baker');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A2', 'Numeric value #1:');
|
$objPHPExcel->getActiveSheet()->setCellValue('A2', 'Numeric value #1:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B2', 12345);
|
->setCellValue('B2', 12345);
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A3', 'Numeric value #2:');
|
$objPHPExcel->getActiveSheet()->setCellValue('A3', 'Numeric value #2:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B3', -12.345);
|
->setCellValue('B3', -12.345);
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A4', 'Numeric value #3:');
|
$objPHPExcel->getActiveSheet()->setCellValue('A4', 'Numeric value #3:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B4', .12345);
|
->setCellValue('B4', .12345);
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A5', 'Numeric value #4:');
|
$objPHPExcel->getActiveSheet()->setCellValue('A5', 'Numeric value #4:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B5', '12345');
|
->setCellValue('B5', '12345');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A6', 'Numeric value #5:');
|
$objPHPExcel->getActiveSheet()->setCellValue('A6', 'Numeric value #5:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B6', '1.2345');
|
->setCellValue('B6', '1.2345');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A7', 'Numeric value #6:');
|
$objPHPExcel->getActiveSheet()->setCellValue('A7', 'Numeric value #6:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B7', '.12345');
|
->setCellValue('B7', '.12345');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A8', 'Numeric value #7:');
|
$objPHPExcel->getActiveSheet()->setCellValue('A8', 'Numeric value #7:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B8', '1.234e-5');
|
->setCellValue('B8', '1.234e-5');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A9', 'Numeric value #8:');
|
$objPHPExcel->getActiveSheet()->setCellValue('A9', 'Numeric value #8:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B9', '-1.234e+5');
|
->setCellValue('B9', '-1.234e+5');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A10', 'Boolean value:');
|
$objPHPExcel->getActiveSheet()->setCellValue('A10', 'Boolean value:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B10', true);
|
->setCellValue('B10', true);
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A11', 'Percentage value #1:');
|
$objPHPExcel->getActiveSheet()->setCellValue('A11', 'Percentage value #1:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B11', '10%');
|
->setCellValue('B11', '10%');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A12', 'Percentage value #2:');
|
$objPHPExcel->getActiveSheet()->setCellValue('A12', 'Percentage value #2:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B12', '12.5%');
|
->setCellValue('B12', '12.5%');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A13', 'Date value #1:');
|
$objPHPExcel->getActiveSheet()->setCellValue('A13', 'Currency value:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B13', '21 December 1983');
|
->setCellValue('B13', '$12345');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A14', 'Date value #2:');
|
$objPHPExcel->getActiveSheet()->setCellValue('A14', 'Date value #1:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B14', '19-Dec-1960');
|
->setCellValue('B14', '21 December 1983');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A15', 'Date value #3:');
|
$objPHPExcel->getActiveSheet()->setCellValue('A15', 'Date value #2:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B15', '19/12/1960');
|
->setCellValue('B15', '19-Dec-1960');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A16', 'Date value #4:');
|
$objPHPExcel->getActiveSheet()->setCellValue('A16', 'Date value #3:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B16', '19-12-1960');
|
->setCellValue('B16', '19/12/1960');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A17', 'Date value #5:');
|
$objPHPExcel->getActiveSheet()->setCellValue('A17', 'Date value #4:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B17', '1-Jan');
|
->setCellValue('B17', '19-12-1960');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A18', 'Time value #1:');
|
$objPHPExcel->getActiveSheet()->setCellValue('A18', 'Date value #5:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B18', '01:30');
|
->setCellValue('B18', '1-Jan');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A19', 'Time value #2:');
|
$objPHPExcel->getActiveSheet()->setCellValue('A19', 'Time value #1:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B19', '01:30:15');
|
->setCellValue('B19', '01:30');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A20', 'Date/Time value:');
|
$objPHPExcel->getActiveSheet()->setCellValue('A20', 'Time value #2:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B20', '19-Dec-1960 01:30');
|
->setCellValue('B20', '01:30:15');
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A21', 'Formula:');
|
$objPHPExcel->getActiveSheet()->setCellValue('A21', 'Date/Time value:')
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B21', '=SUM(B2:B9)');
|
->setCellValue('B21', '19-Dec-1960 01:30');
|
||||||
|
|
||||||
|
$objPHPExcel->getActiveSheet()->setCellValue('A22', 'Formula:')
|
||||||
|
->setCellValue('B22', '=SUM(B2:B9)');
|
||||||
|
|
||||||
// Rename worksheet
|
// 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');
|
$objPHPExcel->getActiveSheet()->setTitle('Advanced value binder');
|
||||||
|
|
||||||
|
|
||||||
@ -141,14 +146,15 @@ $objPHPExcel->setActiveSheetIndex(0);
|
|||||||
|
|
||||||
|
|
||||||
// Save Excel 2007 file
|
// 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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
$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 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 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;
|
||||||
|
@ -27,6 +27,10 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
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');
|
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');
|
$objReader = PHPExcel_IOFactory::createReader('Excel5');
|
||||||
$objPHPExcel = $objReader->load("templates/30template.xls");
|
$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',
|
$data = array(array('title' => 'Excel for dummies',
|
||||||
'price' => 17.99,
|
'price' => 17.99,
|
||||||
'quantity' => 2
|
'quantity' => 2
|
||||||
@ -64,23 +68,24 @@ foreach($data as $r => $dataRow) {
|
|||||||
$row = $baseRow + $r;
|
$row = $baseRow + $r;
|
||||||
$objPHPExcel->getActiveSheet()->insertNewRowBefore($row,1);
|
$objPHPExcel->getActiveSheet()->insertNewRowBefore($row,1);
|
||||||
|
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('A'.$row, $r+1);
|
$objPHPExcel->getActiveSheet()->setCellValue('A'.$row, $r+1)
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('B'.$row, $dataRow['title']);
|
->setCellValue('B'.$row, $dataRow['title'])
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('C'.$row, $dataRow['price']);
|
->setCellValue('C'.$row, $dataRow['price'])
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('D'.$row, $dataRow['quantity']);
|
->setCellValue('D'.$row, $dataRow['quantity'])
|
||||||
$objPHPExcel->getActiveSheet()->setCellValue('E'.$row, '=C'.$row.'*D'.$row);
|
->setCellValue('E'.$row, '=C'.$row.'*D'.$row);
|
||||||
}
|
}
|
||||||
$objPHPExcel->getActiveSheet()->removeRow($baseRow-1,1);
|
$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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
$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 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 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;
|
||||||
|
@ -27,6 +27,10 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
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');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
@ -38,7 +42,7 @@ $inputFileType = 'Excel5';
|
|||||||
$inputFileName = 'templates/31docproperties.xls';
|
$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);
|
$callStartTime = microtime(true);
|
||||||
|
|
||||||
$objPHPExcelReader = PHPExcel_IOFactory::createReader($inputFileType);
|
$objPHPExcelReader = PHPExcel_IOFactory::createReader($inputFileType);
|
||||||
@ -46,12 +50,12 @@ $objPHPExcel = $objPHPExcelReader->load($inputFileName);
|
|||||||
|
|
||||||
$callEndTime = microtime(true);
|
$callEndTime = microtime(true);
|
||||||
$callTime = $callEndTime - $callStartTime;
|
$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 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")
|
$objPHPExcel->getProperties()->setTitle("Office 95 XLS Test Document")
|
||||||
->setSubject("Office 95 XLS Test Document")
|
->setSubject("Office 95 XLS Test Document")
|
||||||
->setDescription("Test XLS document, generated using PHPExcel")
|
->setDescription("Test XLS document, generated using PHPExcel")
|
||||||
@ -59,57 +63,57 @@ $objPHPExcel->getProperties()->setTitle("Office 95 XLS Test Document")
|
|||||||
|
|
||||||
|
|
||||||
// Save Excel 95 file
|
// 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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
$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 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
|
// 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__));
|
$objPHPExcelRead = PHPExcel_IOFactory::load(str_replace('.php', '.xls', __FILE__));
|
||||||
|
|
||||||
// Set properties
|
// 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 'Core Properties:' , EOL;
|
||||||
echo ' Created by - ' , $objPHPExcel->getProperties()->getCreator() , PHP_EOL;
|
echo ' Created by - ' , $objPHPExcel->getProperties()->getCreator() , EOL;
|
||||||
echo ' Created on - ' , date('d-M-Y',$objPHPExcel->getProperties()->getCreated()) , ' at ' ,
|
echo ' Created on - ' , date('d-M-Y',$objPHPExcel->getProperties()->getCreated()) , ' at ' ,
|
||||||
date('H:i:s',$objPHPExcel->getProperties()->getCreated()) , PHP_EOL;
|
date('H:i:s',$objPHPExcel->getProperties()->getCreated()) , EOL;
|
||||||
echo ' Last Modified by - ' , $objPHPExcel->getProperties()->getLastModifiedBy() , PHP_EOL;
|
echo ' Last Modified by - ' , $objPHPExcel->getProperties()->getLastModifiedBy() , EOL;
|
||||||
echo ' Last Modified on - ' , date('d-M-Y',$objPHPExcel->getProperties()->getModified()) , ' at ' ,
|
echo ' Last Modified on - ' , date('d-M-Y',$objPHPExcel->getProperties()->getModified()) , ' at ' ,
|
||||||
date('H:i:s',$objPHPExcel->getProperties()->getModified()) , PHP_EOL;
|
date('H:i:s',$objPHPExcel->getProperties()->getModified()) , EOL;
|
||||||
echo ' Title - ' , $objPHPExcel->getProperties()->getTitle() , PHP_EOL;
|
echo ' Title - ' , $objPHPExcel->getProperties()->getTitle() , EOL;
|
||||||
echo ' Subject - ' , $objPHPExcel->getProperties()->getSubject() , PHP_EOL;
|
echo ' Subject - ' , $objPHPExcel->getProperties()->getSubject() , EOL;
|
||||||
echo ' Description - ' , $objPHPExcel->getProperties()->getDescription() , PHP_EOL;
|
echo ' Description - ' , $objPHPExcel->getProperties()->getDescription() , EOL;
|
||||||
echo ' Keywords: - ' , $objPHPExcel->getProperties()->getKeywords() , PHP_EOL;
|
echo ' Keywords: - ' , $objPHPExcel->getProperties()->getKeywords() , EOL;
|
||||||
|
|
||||||
|
|
||||||
echo 'Extended (Application) Properties:' , PHP_EOL;
|
echo 'Extended (Application) Properties:' , EOL;
|
||||||
echo ' Category - ' , $objPHPExcel->getProperties()->getCategory() , PHP_EOL;
|
echo ' Category - ' , $objPHPExcel->getProperties()->getCategory() , EOL;
|
||||||
echo ' Company - ' , $objPHPExcel->getProperties()->getCompany() , PHP_EOL;
|
echo ' Company - ' , $objPHPExcel->getProperties()->getCompany() , EOL;
|
||||||
echo ' Manager - ' , $objPHPExcel->getProperties()->getManager() , PHP_EOL;
|
echo ' Manager - ' , $objPHPExcel->getProperties()->getManager() , EOL;
|
||||||
|
|
||||||
|
|
||||||
echo 'Custom Properties:' , PHP_EOL;
|
echo 'Custom Properties:' , EOL;
|
||||||
$customProperties = $objPHPExcel->getProperties()->getCustomProperties();
|
$customProperties = $objPHPExcel->getProperties()->getCustomProperties();
|
||||||
foreach($customProperties as $customProperty) {
|
foreach($customProperties as $customProperty) {
|
||||||
$propertyValue = $objPHPExcel->getProperties()->getCustomPropertyValue($customProperty);
|
$propertyValue = $objPHPExcel->getProperties()->getCustomPropertyValue($customProperty);
|
||||||
$propertyType = $objPHPExcel->getProperties()->getCustomPropertyType($customProperty);
|
$propertyType = $objPHPExcel->getProperties()->getCustomPropertyType($customProperty);
|
||||||
echo ' ' , $customProperty , ' - (' , $propertyType , ') - ';
|
echo ' ' , $customProperty , ' - (' , $propertyType , ') - ';
|
||||||
if ($propertyType == PHPExcel_DocumentProperties::PROPERTY_TYPE_DATE) {
|
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) {
|
} elseif ($propertyType == PHPExcel_DocumentProperties::PROPERTY_TYPE_BOOLEAN) {
|
||||||
echo (($propertyValue) ? 'TRUE' : 'FALSE') , PHP_EOL;
|
echo (($propertyValue) ? 'TRUE' : 'FALSE') , EOL;
|
||||||
} else {
|
} else {
|
||||||
echo $propertyValue , PHP_EOL;
|
echo $propertyValue , EOL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Echo memory peak usage
|
// 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;
|
||||||
|
@ -27,6 +27,10 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
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');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
@ -38,7 +42,7 @@ $inputFileType = 'Excel2007';
|
|||||||
$inputFileName = 'templates/31docproperties.xlsx';
|
$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);
|
$callStartTime = microtime(true);
|
||||||
|
|
||||||
$objPHPExcelReader = PHPExcel_IOFactory::createReader($inputFileType);
|
$objPHPExcelReader = PHPExcel_IOFactory::createReader($inputFileType);
|
||||||
@ -46,12 +50,12 @@ $objPHPExcel = $objPHPExcelReader->load($inputFileName);
|
|||||||
|
|
||||||
$callEndTime = microtime(true);
|
$callEndTime = microtime(true);
|
||||||
$callTime = $callEndTime - $callStartTime;
|
$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 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")
|
$objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document")
|
||||||
->setSubject("Office 2007 XLSX Test Document")
|
->setSubject("Office 2007 XLSX Test Document")
|
||||||
->setDescription("Test XLSX document, generated using PHPExcel")
|
->setDescription("Test XLSX document, generated using PHPExcel")
|
||||||
@ -59,57 +63,57 @@ $objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document")
|
|||||||
|
|
||||||
|
|
||||||
// Save Excel 2007 file
|
// 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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
$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 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
|
// 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__));
|
$objPHPExcelRead = PHPExcel_IOFactory::load(str_replace('.php', '.xlsx', __FILE__));
|
||||||
|
|
||||||
// Set properties
|
// 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 'Core Properties:' , EOL;
|
||||||
echo ' Created by - ' , $objPHPExcel->getProperties()->getCreator() , PHP_EOL;
|
echo ' Created by - ' , $objPHPExcel->getProperties()->getCreator() , EOL;
|
||||||
echo ' Created on - ' , date('d-M-Y',$objPHPExcel->getProperties()->getCreated()) , ' at ' ,
|
echo ' Created on - ' , date('d-M-Y',$objPHPExcel->getProperties()->getCreated()) , ' at ' ,
|
||||||
date('H:i:s',$objPHPExcel->getProperties()->getCreated()) , PHP_EOL;
|
date('H:i:s',$objPHPExcel->getProperties()->getCreated()) , EOL;
|
||||||
echo ' Last Modified by - ' , $objPHPExcel->getProperties()->getLastModifiedBy() , PHP_EOL;
|
echo ' Last Modified by - ' , $objPHPExcel->getProperties()->getLastModifiedBy() , EOL;
|
||||||
echo ' Last Modified on - ' , date('d-M-Y',$objPHPExcel->getProperties()->getModified()) , ' at ' ,
|
echo ' Last Modified on - ' , date('d-M-Y',$objPHPExcel->getProperties()->getModified()) , ' at ' ,
|
||||||
date('H:i:s',$objPHPExcel->getProperties()->getModified()) , PHP_EOL;
|
date('H:i:s',$objPHPExcel->getProperties()->getModified()) , EOL;
|
||||||
echo ' Title - ' , $objPHPExcel->getProperties()->getTitle() , PHP_EOL;
|
echo ' Title - ' , $objPHPExcel->getProperties()->getTitle() , EOL;
|
||||||
echo ' Subject - ' , $objPHPExcel->getProperties()->getSubject() , PHP_EOL;
|
echo ' Subject - ' , $objPHPExcel->getProperties()->getSubject() , EOL;
|
||||||
echo ' Description - ' , $objPHPExcel->getProperties()->getDescription() , PHP_EOL;
|
echo ' Description - ' , $objPHPExcel->getProperties()->getDescription() , EOL;
|
||||||
echo ' Keywords: - ' , $objPHPExcel->getProperties()->getKeywords() , PHP_EOL;
|
echo ' Keywords: - ' , $objPHPExcel->getProperties()->getKeywords() , EOL;
|
||||||
|
|
||||||
|
|
||||||
echo 'Extended (Application) Properties:' , PHP_EOL;
|
echo 'Extended (Application) Properties:' , EOL;
|
||||||
echo ' Category - ' , $objPHPExcel->getProperties()->getCategory() , PHP_EOL;
|
echo ' Category - ' , $objPHPExcel->getProperties()->getCategory() , EOL;
|
||||||
echo ' Company - ' , $objPHPExcel->getProperties()->getCompany() , PHP_EOL;
|
echo ' Company - ' , $objPHPExcel->getProperties()->getCompany() , EOL;
|
||||||
echo ' Manager - ' , $objPHPExcel->getProperties()->getManager() , PHP_EOL;
|
echo ' Manager - ' , $objPHPExcel->getProperties()->getManager() , EOL;
|
||||||
|
|
||||||
|
|
||||||
echo 'Custom Properties:' , PHP_EOL;
|
echo 'Custom Properties:' , EOL;
|
||||||
$customProperties = $objPHPExcel->getProperties()->getCustomProperties();
|
$customProperties = $objPHPExcel->getProperties()->getCustomProperties();
|
||||||
foreach($customProperties as $customProperty) {
|
foreach($customProperties as $customProperty) {
|
||||||
$propertyValue = $objPHPExcel->getProperties()->getCustomPropertyValue($customProperty);
|
$propertyValue = $objPHPExcel->getProperties()->getCustomPropertyValue($customProperty);
|
||||||
$propertyType = $objPHPExcel->getProperties()->getCustomPropertyType($customProperty);
|
$propertyType = $objPHPExcel->getProperties()->getCustomPropertyType($customProperty);
|
||||||
echo ' ' , $customProperty , ' - (' , $propertyType , ') - ';
|
echo ' ' , $customProperty , ' - (' , $propertyType , ') - ';
|
||||||
if ($propertyType == PHPExcel_DocumentProperties::PROPERTY_TYPE_DATE) {
|
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) {
|
} elseif ($propertyType == PHPExcel_DocumentProperties::PROPERTY_TYPE_BOOLEAN) {
|
||||||
echo (($propertyValue) ? 'TRUE' : 'FALSE') , PHP_EOL;
|
echo (($propertyValue) ? 'TRUE' : 'FALSE') , EOL;
|
||||||
} else {
|
} else {
|
||||||
echo $propertyValue , PHP_EOL;
|
echo $propertyValue , EOL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Echo memory peak usage
|
// 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;
|
||||||
|
@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
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');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
@ -52,25 +57,25 @@ foreach($inputFileNames as $inputFileName) {
|
|||||||
$inputFileNameShort = basename($inputFileName);
|
$inputFileNameShort = basename($inputFileName);
|
||||||
|
|
||||||
if (!file_exists($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;
|
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 = PHPExcel_IOFactory::createReader($inputFileType);
|
||||||
$objReader->setIncludeCharts(TRUE);
|
$objReader->setIncludeCharts(TRUE);
|
||||||
$objPHPExcel = $objReader->load($inputFileName);
|
$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) {
|
foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
|
||||||
$sheetName = $worksheet->getTitle();
|
$sheetName = $worksheet->getTitle();
|
||||||
echo 'Worksheet: ' , $sheetName , PHP_EOL;
|
echo 'Worksheet: ' , $sheetName , EOL;
|
||||||
|
|
||||||
$chartNames = $worksheet->getChartNames();
|
$chartNames = $worksheet->getChartNames();
|
||||||
if(empty($chartNames)) {
|
if(empty($chartNames)) {
|
||||||
echo ' There are no charts in this worksheet' , PHP_EOL;
|
echo ' There are no charts in this worksheet' , EOL;
|
||||||
} else {
|
} else {
|
||||||
natsort($chartNames);
|
natsort($chartNames);
|
||||||
foreach($chartNames as $i => $chartName) {
|
foreach($chartNames as $i => $chartName) {
|
||||||
@ -80,12 +85,12 @@ foreach($inputFileNames as $inputFileName) {
|
|||||||
} else {
|
} else {
|
||||||
$caption = 'Untitled';
|
$caption = 'Untitled';
|
||||||
}
|
}
|
||||||
echo ' ' , $chartName , ' - ' , $caption , PHP_EOL;
|
echo ' ' , $chartName , ' - ' , $caption , EOL;
|
||||||
echo str_repeat(' ',strlen($chartName)+3);
|
echo str_repeat(' ',strlen($chartName)+3);
|
||||||
$groupCount = $chart->getPlotArea()->getPlotGroupCount();
|
$groupCount = $chart->getPlotArea()->getPlotGroupCount();
|
||||||
if ($groupCount == 1) {
|
if ($groupCount == 1) {
|
||||||
$chartType = $chart->getPlotArea()->getPlotGroupByIndex(0)->getPlotType();
|
$chartType = $chart->getPlotArea()->getPlotGroupByIndex(0)->getPlotType();
|
||||||
echo ' ' , $chartType , PHP_EOL;
|
echo ' ' , $chartType , EOL;
|
||||||
} else {
|
} else {
|
||||||
$chartTypes = array();
|
$chartTypes = array();
|
||||||
for($i = 0; $i < $groupCount; ++$i) {
|
for($i = 0; $i < $groupCount; ++$i) {
|
||||||
@ -94,11 +99,11 @@ foreach($inputFileNames as $inputFileName) {
|
|||||||
$chartTypes = array_unique($chartTypes);
|
$chartTypes = array_unique($chartTypes);
|
||||||
if (count($chartTypes) == 1) {
|
if (count($chartTypes) == 1) {
|
||||||
$chartType = 'Multiple Plot ' . array_pop($chartTypes);
|
$chartType = 'Multiple Plot ' . array_pop($chartTypes);
|
||||||
echo ' ' , $chartType , PHP_EOL;
|
echo ' ' , $chartType , EOL;
|
||||||
} elseif (count($chartTypes) == 0) {
|
} elseif (count($chartTypes) == 0) {
|
||||||
echo ' *** Type not yet implemented' , PHP_EOL;
|
echo ' *** Type not yet implemented' , EOL;
|
||||||
} else {
|
} else {
|
||||||
echo ' Combination Chart' , PHP_EOL;
|
echo ' Combination Chart' , EOL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -108,18 +113,19 @@ foreach($inputFileNames as $inputFileName) {
|
|||||||
|
|
||||||
$outputFileName = basename($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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||||
$objWriter->setIncludeCharts(TRUE);
|
$objWriter->setIncludeCharts(TRUE);
|
||||||
$objWriter->save($outputFileName);
|
$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();
|
$objPHPExcel->disconnectWorksheets();
|
||||||
unset($objPHPExcel);
|
unset($objPHPExcel);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Echo memory peak usage
|
// 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 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;
|
||||||
|
@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
/** Error reporting */
|
/** Error reporting */
|
||||||
error_reporting(E_ALL);
|
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');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
@ -28,7 +33,7 @@ date_default_timezone_set('Europe/London');
|
|||||||
* @package PHPExcel
|
* @package PHPExcel
|
||||||
* @copyright Copyright (c) 2006 - 2012 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
|
* @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 **/
|
/** Include path **/
|
||||||
@ -50,16 +55,34 @@ $objWorksheet->fromArray(
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Set the Labels for each data series we want to plot
|
// 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(
|
$dataseriesLabels = array(
|
||||||
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$B$1', null, 1), // 2010
|
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!$C$1', null, 1), // 2011
|
||||||
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$D$1', null, 1), // 2012
|
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$D$1', null, 1), // 2012
|
||||||
);
|
);
|
||||||
// Set the X-Axis Labels
|
// Set the X-Axis Labels
|
||||||
|
// Datatype
|
||||||
|
// Cell reference for data
|
||||||
|
// Format Code
|
||||||
|
// Number of datapoints in series
|
||||||
|
// Data values
|
||||||
|
// Data Marker
|
||||||
$xAxisTickValues = array(
|
$xAxisTickValues = array(
|
||||||
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4
|
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
|
// 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(
|
$dataSeriesValues = array(
|
||||||
new PHPExcel_Chart_DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', null, 4),
|
new PHPExcel_Chart_DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', null, 4),
|
||||||
new PHPExcel_Chart_DataSeriesValues('Number', 'Worksheet!$C$2:$C$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
|
$dataSeriesValues // plotValues
|
||||||
);
|
);
|
||||||
// Set additional dataseries parameters
|
// Set additional dataseries parameters
|
||||||
|
// Make it a vertical column rather than a horizontal bar graph
|
||||||
$series->setPlotDirection(PHPExcel_Chart_DataSeries::DIRECTION_COL);
|
$series->setPlotDirection(PHPExcel_Chart_DataSeries::DIRECTION_COL);
|
||||||
|
|
||||||
// Set the series in the plot area
|
// Set the series in the plot area
|
||||||
@ -108,15 +132,16 @@ $objWorksheet->addChart($chart);
|
|||||||
|
|
||||||
|
|
||||||
// Save Excel 2007 file
|
// 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 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||||
$objWriter->setIncludeCharts(TRUE);
|
$objWriter->setIncludeCharts(TRUE);
|
||||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
$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 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 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
81
Tests/34chartupdate.php
Normal 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;
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -79,6 +79,10 @@ Fixed in develop branch:
|
|||||||
- Feature: (MBaker) Initial version of HTML Reader
|
- Feature: (MBaker) Initial version of HTML Reader
|
||||||
- Feature: (Progi1984) & (blazzy) Work items 9605 - Implement support for AutoFilter in PHPExcel_Writer_Excel5
|
- 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
|
- 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: (cyberconte) Patch 12318 - OOCalc cells containing <text:span> inside the <text:p> tag
|
||||||
- Bugfix: (schir1964) Fix to listWorksheetInfo() method for OOCalc Reader
|
- Bugfix: (schir1964) Fix to listWorksheetInfo() method for OOCalc Reader
|
||||||
- Bugfix: (MBaker) Support for "e" (epoch) date format mask
|
- 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: (MBaker) Work items 15905 and 18183 - Allow "no impact" to formats on Conditional Formatting
|
||||||
- Bugfix: (wackonline) OOCalc Reader fix for NULL cells
|
- Bugfix: (wackonline) OOCalc Reader fix for NULL cells
|
||||||
- Bugfix: (seltzlab) Fix to excel2007 Chart Writer when a $plotSeriesValues is empty
|
- 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) 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):
|
2012-05-19 (v1.7.7):
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* 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
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
**************************************************************************************
|
**************************************************************************************
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// Custom assertion class for handling precision of Complex numbers
|
// Custom assertion class for handling precision of Complex numbers
|
||||||
require_once __DIR__.'/../../custom/complexAssert.php';
|
require_once 'custom/complexAssert.php';
|
||||||
|
|
||||||
// Data Provider handler
|
// Data Provider handler
|
||||||
require_once 'testDataFileIterator.php';
|
require_once 'testDataFileIterator.php';
|
24
unitTests/Classes/PHPExcel/Cell/DataTypeTest.php
Normal file
24
unitTests/Classes/PHPExcel/Cell/DataTypeTest.php
Normal 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
88
unitTests/Classes/PHPExcel/Cell/HyperlinkTest.php
Normal file
88
unitTests/Classes/PHPExcel/Cell/HyperlinkTest.php
Normal 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
295
unitTests/Classes/PHPExcel/CellTest.php
Normal file
295
unitTests/Classes/PHPExcel/CellTest.php
Normal 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');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -46,6 +46,9 @@ class DateTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
$expectedResult = array_pop($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);
|
$result = call_user_func_array(array('PHPExcel_Shared_Date','ExcelToPHP'),$args);
|
||||||
$this->assertEquals($expectedResult, $result);
|
$this->assertEquals($expectedResult, $result);
|
||||||
}
|
}
|
||||||
@ -55,6 +58,48 @@ class DateTest extends PHPUnit_Framework_TestCase
|
|||||||
return new testDataFileIterator('rawTestData/Shared/DateTimeExcelToPHP1900.data');
|
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
|
* @dataProvider providerDateTimeExcelToPHP1904
|
||||||
*/
|
*/
|
||||||
@ -67,6 +112,9 @@ class DateTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
$expectedResult = array_pop($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);
|
$result = call_user_func_array(array('PHPExcel_Shared_Date','ExcelToPHP'),$args);
|
||||||
$this->assertEquals($expectedResult, $result);
|
$this->assertEquals($expectedResult, $result);
|
||||||
}
|
}
|
||||||
@ -76,6 +124,27 @@ class DateTest extends PHPUnit_Framework_TestCase
|
|||||||
return new testDataFileIterator('rawTestData/Shared/DateTimeExcelToPHP1904.data');
|
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
|
* @dataProvider providerIsDateTimeFormatCode
|
||||||
*/
|
*/
|
94
unitTests/Classes/PHPExcel/Shared/FontTest.php
Normal file
94
unitTests/Classes/PHPExcel/Shared/FontTest.php
Normal 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');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
33
unitTests/Classes/PHPExcel/Shared/PasswordHasherTest.php
Normal file
33
unitTests/Classes/PHPExcel/Shared/PasswordHasherTest.php
Normal 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');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
81
unitTests/Classes/PHPExcel/Style/ColorTest.php
Normal file
81
unitTests/Classes/PHPExcel/Style/ColorTest.php
Normal 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');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* $Id: bootstrap.php 2892 2011-08-14 15:11:50Z markbaker@phpexcel.net $
|
* $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
|
* @package PHPExcel
|
||||||
* @subpackage PHPExcel Unit Tests
|
* @subpackage PHPExcel Unit Tests
|
||||||
* @author Mark Baker
|
* @author Mark Baker
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
<ini name="memory_limit" value="2048M"/>
|
<ini name="memory_limit" value="2048M"/>
|
||||||
</php>
|
</php>
|
||||||
<testsuite name="PHPExcel Unit Test Suite">
|
<testsuite name="PHPExcel Unit Test Suite">
|
||||||
<directory suffix="Test.php">./PHPExcel</directory>
|
<directory suffix="Test.php">./Classes</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
<filter>
|
<filter>
|
||||||
<whitelist>
|
<whitelist>
|
||||||
|
@ -9,3 +9,5 @@
|
|||||||
"k", "Mark Baker", 5, 8
|
"k", "Mark Baker", 5, 8
|
||||||
"a", "Mark Baker", 3, 7
|
"a", "Mark Baker", 3, 7
|
||||||
"BITE", "BIT", "#VALUE!"
|
"BITE", "BIT", "#VALUE!"
|
||||||
|
"", "Mark Baker", 1
|
||||||
|
"", "Mark Baker", 8, 8
|
||||||
|
12
unitTests/rawTestData/CellAbsoluteCoordinate.data
Normal file
12
unitTests/rawTestData/CellAbsoluteCoordinate.data
Normal 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"
|
16
unitTests/rawTestData/CellAbsoluteReference.data
Normal file
16
unitTests/rawTestData/CellAbsoluteReference.data
Normal 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"
|
2
unitTests/rawTestData/CellBuildRange.data
Normal file
2
unitTests/rawTestData/CellBuildRange.data
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
{"B4"|"E9"}, "B4:E9"
|
||||||
|
{"B4"|"E9";"H2"|"O11"}, '"B4:E9,H2:O11"'
|
6
unitTests/rawTestData/CellCoordinates.data
Normal file
6
unitTests/rawTestData/CellCoordinates.data
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
"A1", {"A";1}
|
||||||
|
"A12", {"A";12}
|
||||||
|
"J1", {"J";1}
|
||||||
|
"J20", {"J";20}
|
||||||
|
"AI1", {"AI";1}
|
||||||
|
"AI2012", {"AI";2012}
|
@ -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"}
|
2
unitTests/rawTestData/CellGetRangeBoundaries.data
Normal file
2
unitTests/rawTestData/CellGetRangeBoundaries.data
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
"B4:E9", {"B"|4;"E"|9}
|
||||||
|
"B4", {"B"|4;"B"|4}
|
2
unitTests/rawTestData/CellRangeBoundaries.data
Normal file
2
unitTests/rawTestData/CellRangeBoundaries.data
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
"B4:E9", {2|4;5|9}
|
||||||
|
"B4", {2|4;2|4}
|
2
unitTests/rawTestData/CellRangeDimension.data
Normal file
2
unitTests/rawTestData/CellRangeDimension.data
Normal 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
Loading…
Reference in New Issue
Block a user