PSR-2 : Fixes

This commit is contained in:
Progi1984 2015-05-15 12:55:10 +02:00
parent e18ba38f16
commit 96f3d0e6ee
18 changed files with 6048 additions and 6172 deletions

View File

@ -98,10 +98,10 @@ class PHPExcel_Comment implements PHPExcel_IComparable
public function __construct() public function __construct()
{ {
// Initialise variables // Initialise variables
$this->_author = 'Author'; $this->_author = 'Author';
$this->_text = new PHPExcel_RichText(); $this->_text = new PHPExcel_RichText();
$this->_fillColor = new PHPExcel_Style_Color('FFFFFFE1'); $this->_fillColor = new PHPExcel_Style_Color('FFFFFFE1');
$this->_alignment = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL; $this->_alignment = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
} }
/** /**
@ -109,7 +109,8 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* *
* @return string * @return string
*/ */
public function getAuthor() { public function getAuthor()
{
return $this->_author; return $this->_author;
} }
@ -119,7 +120,8 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* @param string $pValue * @param string $pValue
* @return PHPExcel_Comment * @return PHPExcel_Comment
*/ */
public function setAuthor($pValue = '') { public function setAuthor($pValue = '')
{
$this->_author = $pValue; $this->_author = $pValue;
return $this; return $this;
} }
@ -129,7 +131,8 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* *
* @return PHPExcel_RichText * @return PHPExcel_RichText
*/ */
public function getText() { public function getText()
{
return $this->_text; return $this->_text;
} }
@ -139,7 +142,8 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* @param PHPExcel_RichText $pValue * @param PHPExcel_RichText $pValue
* @return PHPExcel_Comment * @return PHPExcel_Comment
*/ */
public function setText(PHPExcel_RichText $pValue) { public function setText(PHPExcel_RichText $pValue)
{
$this->_text = $pValue; $this->_text = $pValue;
return $this; return $this;
} }
@ -149,7 +153,8 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* *
* @return string * @return string
*/ */
public function getWidth() { public function getWidth()
{
return $this->_width; return $this->_width;
} }
@ -159,7 +164,8 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* @param string $value * @param string $value
* @return PHPExcel_Comment * @return PHPExcel_Comment
*/ */
public function setWidth($value = '96pt') { public function setWidth($value = '96pt')
{
$this->_width = $value; $this->_width = $value;
return $this; return $this;
} }
@ -169,7 +175,8 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* *
* @return string * @return string
*/ */
public function getHeight() { public function getHeight()
{
return $this->_height; return $this->_height;
} }
@ -179,7 +186,8 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* @param string $value * @param string $value
* @return PHPExcel_Comment * @return PHPExcel_Comment
*/ */
public function setHeight($value = '55.5pt') { public function setHeight($value = '55.5pt')
{
$this->_height = $value; $this->_height = $value;
return $this; return $this;
} }
@ -189,7 +197,8 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* *
* @return string * @return string
*/ */
public function getMarginLeft() { public function getMarginLeft()
{
return $this->_marginLeft; return $this->_marginLeft;
} }
@ -199,7 +208,8 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* @param string $value * @param string $value
* @return PHPExcel_Comment * @return PHPExcel_Comment
*/ */
public function setMarginLeft($value = '59.25pt') { public function setMarginLeft($value = '59.25pt')
{
$this->_marginLeft = $value; $this->_marginLeft = $value;
return $this; return $this;
} }
@ -209,7 +219,8 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* *
* @return string * @return string
*/ */
public function getMarginTop() { public function getMarginTop()
{
return $this->_marginTop; return $this->_marginTop;
} }
@ -219,7 +230,8 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* @param string $value * @param string $value
* @return PHPExcel_Comment * @return PHPExcel_Comment
*/ */
public function setMarginTop($value = '1.5pt') { public function setMarginTop($value = '1.5pt')
{
$this->_marginTop = $value; $this->_marginTop = $value;
return $this; return $this;
} }
@ -229,7 +241,8 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* *
* @return boolean * @return boolean
*/ */
public function getVisible() { public function getVisible()
{
return $this->_visible; return $this->_visible;
} }
@ -239,7 +252,8 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* @param boolean $value * @param boolean $value
* @return PHPExcel_Comment * @return PHPExcel_Comment
*/ */
public function setVisible($value = false) { public function setVisible($value = false)
{
$this->_visible = $value; $this->_visible = $value;
return $this; return $this;
} }
@ -249,7 +263,8 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* *
* @return PHPExcel_Style_Color * @return PHPExcel_Style_Color
*/ */
public function getFillColor() { public function getFillColor()
{
return $this->_fillColor; return $this->_fillColor;
} }
@ -259,7 +274,8 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* @param string $pValue * @param string $pValue
* @return PHPExcel_Comment * @return PHPExcel_Comment
*/ */
public function setAlignment($pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL) { public function setAlignment($pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL)
{
$this->_alignment = $pValue; $this->_alignment = $pValue;
return $this; return $this;
} }
@ -269,7 +285,8 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* *
* @return string * @return string
*/ */
public function getAlignment() { public function getAlignment()
{
return $this->_alignment; return $this->_alignment;
} }
@ -278,9 +295,10 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* *
* @return string Hash code * @return string Hash code
*/ */
public function getHashCode() { public function getHashCode()
{
return md5( return md5(
$this->_author $this->_author
. $this->_text->getHashCode() . $this->_text->getHashCode()
. $this->_width . $this->_width
. $this->_height . $this->_height
@ -296,7 +314,8 @@ class PHPExcel_Comment implements PHPExcel_IComparable
/** /**
* Implement PHP __clone to create a deep clone, not just a shallow copy. * Implement PHP __clone to create a deep clone, not just a shallow copy.
*/ */
public function __clone() { public function __clone()
{
$vars = get_object_vars($this); $vars = get_object_vars($this);
foreach ($vars as $key => $value) { foreach ($vars as $key => $value) {
if (is_object($value)) { if (is_object($value)) {
@ -312,8 +331,8 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* *
* @return string * @return string
*/ */
public function __toString() { public function __toString()
{
return $this->_text->getPlainText(); return $this->_text->getPlainText();
} }
} }

View File

@ -33,7 +33,8 @@
* @package PHPExcel * @package PHPExcel
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Exception extends Exception { class PHPExcel_Exception extends Exception
{
/** /**
* Error handler callback * Error handler callback
* *
@ -43,7 +44,8 @@ class PHPExcel_Exception extends Exception {
* @param mixed $line * @param mixed $line
* @param mixed $context * @param mixed $context
*/ */
public static function errorHandlerCallback($code, $string, $file, $line, $context) { public static function errorHandlerCallback($code, $string, $file, $line, $context)
{
$e = new self($string, $code); $e = new self($string, $code);
$e->line = $line; $e->line = $line;
$e->file = $file; $e->file = $file;

View File

@ -157,7 +157,7 @@ class PHPExcel_HashTable
public function getByIndex($pIndex = 0) public function getByIndex($pIndex = 0)
{ {
if (isset($this->_keyMap[$pIndex])) { if (isset($this->_keyMap[$pIndex])) {
return $this->getByHashCode( $this->_keyMap[$pIndex] ); return $this->getByHashCode($this->_keyMap[$pIndex]);
} }
return null; return null;

View File

@ -69,7 +69,9 @@ class PHPExcel_IOFactory
/** /**
* Private constructor for PHPExcel_IOFactory * Private constructor for PHPExcel_IOFactory
*/ */
private function __construct() { } private function __construct()
{
}
/** /**
* Get search locations * Get search locations
@ -135,7 +137,7 @@ class PHPExcel_IOFactory
$className = str_replace('{0}', $writerType, $searchLocation['class']); $className = str_replace('{0}', $writerType, $searchLocation['class']);
$instance = new $className($phpExcel); $instance = new $className($phpExcel);
if ($instance !== NULL) { if ($instance !== null) {
return $instance; return $instance;
} }
} }
@ -165,7 +167,7 @@ class PHPExcel_IOFactory
$className = str_replace('{0}', $readerType, $searchLocation['class']); $className = str_replace('{0}', $readerType, $searchLocation['class']);
$instance = new $className(); $instance = new $className();
if ($instance !== NULL) { if ($instance !== null) {
return $instance; return $instance;
} }
} }
@ -222,7 +224,7 @@ class PHPExcel_IOFactory
// First, lucky guess by inspecting file extension // First, lucky guess by inspecting file extension
$pathinfo = pathinfo($pFilename); $pathinfo = pathinfo($pFilename);
$extensionType = NULL; $extensionType = null;
if (isset($pathinfo['extension'])) { if (isset($pathinfo['extension'])) {
switch (strtolower($pathinfo['extension'])) { switch (strtolower($pathinfo['extension'])) {
case 'xlsx': // Excel (OfficeOpenXML) Spreadsheet case 'xlsx': // Excel (OfficeOpenXML) Spreadsheet

View File

@ -75,7 +75,7 @@ class PHPExcel_NamedRange
public function __construct($pName = null, PHPExcel_Worksheet $pWorksheet, $pRange = 'A1', $pLocalOnly = false, $pScope = null) public function __construct($pName = null, PHPExcel_Worksheet $pWorksheet, $pRange = 'A1', $pLocalOnly = false, $pScope = null)
{ {
// Validate data // Validate data
if (($pName === NULL) || ($pWorksheet === NULL) || ($pRange === NULL)) { if (($pName === null) || ($pWorksheet === null) || ($pRange === null)) {
throw new PHPExcel_Exception('Parameters can not be null.'); throw new PHPExcel_Exception('Parameters can not be null.');
} }
@ -93,7 +93,8 @@ class PHPExcel_NamedRange
* *
* @return string * @return string
*/ */
public function getName() { public function getName()
{
return $this->_name; return $this->_name;
} }
@ -103,18 +104,19 @@ class PHPExcel_NamedRange
* @param string $value * @param string $value
* @return PHPExcel_NamedRange * @return PHPExcel_NamedRange
*/ */
public function setName($value = null) { public function setName($value = null)
if ($value !== NULL) { {
if ($value !== null) {
// Old title // Old title
$oldTitle = $this->_name; $oldTitle = $this->_name;
// Re-attach // Re-attach
if ($this->_worksheet !== NULL) { if ($this->_worksheet !== null) {
$this->_worksheet->getParent()->removeNamedRange($this->_name, $this->_worksheet); $this->_worksheet->getParent()->removeNamedRange($this->_name, $this->_worksheet);
} }
$this->_name = $value; $this->_name = $value;
if ($this->_worksheet !== NULL) { if ($this->_worksheet !== null) {
$this->_worksheet->getParent()->addNamedRange($this); $this->_worksheet->getParent()->addNamedRange($this);
} }
@ -130,7 +132,8 @@ class PHPExcel_NamedRange
* *
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function getWorksheet() { public function getWorksheet()
{
return $this->_worksheet; return $this->_worksheet;
} }
@ -140,8 +143,9 @@ class PHPExcel_NamedRange
* @param PHPExcel_Worksheet $value * @param PHPExcel_Worksheet $value
* @return PHPExcel_NamedRange * @return PHPExcel_NamedRange
*/ */
public function setWorksheet(PHPExcel_Worksheet $value = null) { public function setWorksheet(PHPExcel_Worksheet $value = null)
if ($value !== NULL) { {
if ($value !== null) {
$this->_worksheet = $value; $this->_worksheet = $value;
} }
return $this; return $this;
@ -152,7 +156,8 @@ class PHPExcel_NamedRange
* *
* @return string * @return string
*/ */
public function getRange() { public function getRange()
{
return $this->_range; return $this->_range;
} }
@ -162,8 +167,9 @@ class PHPExcel_NamedRange
* @param string $value * @param string $value
* @return PHPExcel_NamedRange * @return PHPExcel_NamedRange
*/ */
public function setRange($value = null) { public function setRange($value = null)
if ($value !== NULL) { {
if ($value !== null) {
$this->_range = $value; $this->_range = $value;
} }
return $this; return $this;
@ -174,7 +180,8 @@ class PHPExcel_NamedRange
* *
* @return bool * @return bool
*/ */
public function getLocalOnly() { public function getLocalOnly()
{
return $this->_localOnly; return $this->_localOnly;
} }
@ -184,7 +191,8 @@ class PHPExcel_NamedRange
* @param bool $value * @param bool $value
* @return PHPExcel_NamedRange * @return PHPExcel_NamedRange
*/ */
public function setLocalOnly($value = false) { public function setLocalOnly($value = false)
{
$this->_localOnly = $value; $this->_localOnly = $value;
$this->_scope = $value ? $this->_worksheet : null; $this->_scope = $value ? $this->_worksheet : null;
return $this; return $this;
@ -195,7 +203,8 @@ class PHPExcel_NamedRange
* *
* @return PHPExcel_Worksheet|null * @return PHPExcel_Worksheet|null
*/ */
public function getScope() { public function getScope()
{
return $this->_scope; return $this->_scope;
} }
@ -205,7 +214,8 @@ class PHPExcel_NamedRange
* @param PHPExcel_Worksheet|null $value * @param PHPExcel_Worksheet|null $value
* @return PHPExcel_NamedRange * @return PHPExcel_NamedRange
*/ */
public function setScope(PHPExcel_Worksheet $value = null) { public function setScope(PHPExcel_Worksheet $value = null)
{
$this->_scope = $value; $this->_scope = $value;
$this->_localOnly = ($value == null) ? false : true; $this->_localOnly = ($value == null) ? false : true;
return $this; return $this;
@ -218,14 +228,16 @@ class PHPExcel_NamedRange
* @param PHPExcel_Worksheet|null $pSheet Scope. Use null for global scope * @param PHPExcel_Worksheet|null $pSheet Scope. Use null for global scope
* @return PHPExcel_NamedRange * @return PHPExcel_NamedRange
*/ */
public static function resolveRange($pNamedRange = '', PHPExcel_Worksheet $pSheet) { public static function resolveRange($pNamedRange = '', PHPExcel_Worksheet $pSheet)
{
return $pSheet->getParent()->getNamedRange($pNamedRange, $pSheet); return $pSheet->getParent()->getNamedRange($pNamedRange, $pSheet);
} }
/** /**
* Implement PHP __clone to create a deep clone, not just a shallow copy. * Implement PHP __clone to create a deep clone, not just a shallow copy.
*/ */
public function __clone() { public function __clone()
{
$vars = get_object_vars($this); $vars = get_object_vars($this);
foreach ($vars as $key => $value) { foreach ($vars as $key => $value) {
if (is_object($value)) { if (is_object($value)) {

View File

@ -46,8 +46,9 @@ class PHPExcel_ReferenceHelper
* *
* @return PHPExcel_ReferenceHelper * @return PHPExcel_ReferenceHelper
*/ */
public static function getInstance() { public static function getInstance()
if (!isset(self::$_instance) || (self::$_instance === NULL)) { {
if (!isset(self::$_instance) || (self::$_instance === null)) {
self::$_instance = new PHPExcel_ReferenceHelper(); self::$_instance = new PHPExcel_ReferenceHelper();
} }
@ -57,7 +58,8 @@ class PHPExcel_ReferenceHelper
/** /**
* Create a new PHPExcel_ReferenceHelper * Create a new PHPExcel_ReferenceHelper
*/ */
protected function __construct() { protected function __construct()
{
} }
/** /**
@ -68,7 +70,8 @@ class PHPExcel_ReferenceHelper
* @param string $b Second column to test (e.g. 'Z') * @param string $b Second column to test (e.g. 'Z')
* @return integer * @return integer
*/ */
public static function columnSort($a, $b) { public static function columnSort($a, $b)
{
return strcasecmp(strlen($a) . $a, strlen($b) . $b); return strcasecmp(strlen($a) . $a, strlen($b) . $b);
} }
@ -80,7 +83,8 @@ class PHPExcel_ReferenceHelper
* @param string $b Second column to test (e.g. 'Z') * @param string $b Second column to test (e.g. 'Z')
* @return integer * @return integer
*/ */
public static function columnReverseSort($a, $b) { public static function columnReverseSort($a, $b)
{
return 1 - strcasecmp(strlen($a) . $a, strlen($b) . $b); return 1 - strcasecmp(strlen($a) . $a, strlen($b) . $b);
} }
@ -92,9 +96,10 @@ class PHPExcel_ReferenceHelper
* @param string $b Second cell to test (e.g. 'Z1') * @param string $b Second cell to test (e.g. 'Z1')
* @return integer * @return integer
*/ */
public static function cellSort($a, $b) { public static function cellSort($a, $b)
sscanf($a,'%[A-Z]%d', $ac, $ar); {
sscanf($b,'%[A-Z]%d', $bc, $br); sscanf($a, '%[A-Z]%d', $ac, $ar);
sscanf($b, '%[A-Z]%d', $bc, $br);
if ($ar == $br) { if ($ar == $br) {
return strcasecmp(strlen($ac) . $ac, strlen($bc) . $bc); return strcasecmp(strlen($ac) . $ac, strlen($bc) . $bc);
@ -110,9 +115,10 @@ class PHPExcel_ReferenceHelper
* @param string $b Second cell to test (e.g. 'Z1') * @param string $b Second cell to test (e.g. 'Z1')
* @return integer * @return integer
*/ */
public static function cellReverseSort($a, $b) { public static function cellReverseSort($a, $b)
sscanf($a,'%[A-Z]%d', $ac, $ar); {
sscanf($b,'%[A-Z]%d', $bc, $br); sscanf($a, '%[A-Z]%d', $ac, $ar);
sscanf($b, '%[A-Z]%d', $bc, $br);
if ($ar == $br) { if ($ar == $br) {
return 1 - strcasecmp(strlen($ac) . $ac, strlen($bc) . $bc); return 1 - strcasecmp(strlen($ac) . $ac, strlen($bc) . $bc);
@ -130,20 +136,21 @@ class PHPExcel_ReferenceHelper
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion) * @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
* @return boolean * @return boolean
*/ */
private static function cellAddressInDeleteRange($cellAddress, $beforeRow, $pNumRows, $beforeColumnIndex, $pNumCols) { private static function cellAddressInDeleteRange($cellAddress, $beforeRow, $pNumRows, $beforeColumnIndex, $pNumCols)
{
list($cellColumn, $cellRow) = PHPExcel_Cell::coordinateFromString($cellAddress); list($cellColumn, $cellRow) = PHPExcel_Cell::coordinateFromString($cellAddress);
$cellColumnIndex = PHPExcel_Cell::columnIndexFromString($cellColumn); $cellColumnIndex = PHPExcel_Cell::columnIndexFromString($cellColumn);
// Is cell within the range of rows/columns if we're deleting // Is cell within the range of rows/columns if we're deleting
if ($pNumRows < 0 && if ($pNumRows < 0 &&
($cellRow >= ($beforeRow + $pNumRows)) && ($cellRow >= ($beforeRow + $pNumRows)) &&
($cellRow < $beforeRow)) { ($cellRow < $beforeRow)) {
return TRUE; return true;
} elseif ($pNumCols < 0 && } elseif ($pNumCols < 0 &&
($cellColumnIndex >= ($beforeColumnIndex + $pNumCols)) && ($cellColumnIndex >= ($beforeColumnIndex + $pNumCols)) &&
($cellColumnIndex < $beforeColumnIndex)) { ($cellColumnIndex < $beforeColumnIndex)) {
return TRUE; return true;
} }
return FALSE; return false;
} }
/** /**
@ -198,7 +205,7 @@ class PHPExcel_ReferenceHelper
foreach ($aComments as $key => &$value) { foreach ($aComments as $key => &$value) {
// Any comments inside a deleted range will be ignored // Any comments inside a deleted range will be ignored
if (!self::cellAddressInDeleteRange($key, $beforeRow, $pNumRows, $beforeColumnIndex, $pNumCols)) { if (!self::cellAddressInDeleteRange($key, $beforeRow, $pNumRows, $beforeColumnIndex, $pNumCols)) {
// Otherwise build a new array of comments indexed by the adjusted cell reference // Otherwise build a new array of comments indexed by the adjusted cell reference
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows); $newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
$aNewComments[$newReference] = $value; $aNewComments[$newReference] = $value;
} }
@ -220,15 +227,13 @@ class PHPExcel_ReferenceHelper
protected function _adjustHyperlinks($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) protected function _adjustHyperlinks($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
{ {
$aHyperlinkCollection = $pSheet->getHyperlinkCollection(); $aHyperlinkCollection = $pSheet->getHyperlinkCollection();
($pNumCols > 0 || $pNumRows > 0) ? ($pNumCols > 0 || $pNumRows > 0) ? uksort($aHyperlinkCollection, array('PHPExcel_ReferenceHelper','cellReverseSort')) : uksort($aHyperlinkCollection, array('PHPExcel_ReferenceHelper','cellSort'));
uksort($aHyperlinkCollection, array('PHPExcel_ReferenceHelper','cellReverseSort')) :
uksort($aHyperlinkCollection, array('PHPExcel_ReferenceHelper','cellSort'));
foreach ($aHyperlinkCollection as $key => $value) { foreach ($aHyperlinkCollection as $key => $value) {
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows); $newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
if ($key != $newReference) { if ($key != $newReference) {
$pSheet->setHyperlink( $newReference, $value ); $pSheet->setHyperlink($newReference, $value);
$pSheet->setHyperlink( $key, null ); $pSheet->setHyperlink($key, null);
} }
} }
} }
@ -246,14 +251,13 @@ class PHPExcel_ReferenceHelper
protected function _adjustDataValidations($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) protected function _adjustDataValidations($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
{ {
$aDataValidationCollection = $pSheet->getDataValidationCollection(); $aDataValidationCollection = $pSheet->getDataValidationCollection();
($pNumCols > 0 || $pNumRows > 0) ? ($pNumCols > 0 || $pNumRows > 0) ? uksort($aDataValidationCollection, array('PHPExcel_ReferenceHelper','cellReverseSort')) : uksort($aDataValidationCollection, array('PHPExcel_ReferenceHelper','cellSort'));
uksort($aDataValidationCollection, array('PHPExcel_ReferenceHelper','cellReverseSort')) :
uksort($aDataValidationCollection, array('PHPExcel_ReferenceHelper','cellSort'));
foreach ($aDataValidationCollection as $key => $value) { foreach ($aDataValidationCollection as $key => $value) {
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows); $newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
if ($key != $newReference) { if ($key != $newReference) {
$pSheet->setDataValidation( $newReference, $value ); $pSheet->setDataValidation($newReference, $value);
$pSheet->setDataValidation( $key, null ); $pSheet->setDataValidation($key, null);
} }
} }
} }
@ -298,8 +302,8 @@ class PHPExcel_ReferenceHelper
foreach ($aProtectedCells as $key => $value) { foreach ($aProtectedCells as $key => $value) {
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows); $newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
if ($key != $newReference) { if ($key != $newReference) {
$pSheet->protectCells( $newReference, $value, true ); $pSheet->protectCells($newReference, $value, true);
$pSheet->unprotectCells( $key ); $pSheet->unprotectCells($key);
} }
} }
} }
@ -372,7 +376,7 @@ class PHPExcel_ReferenceHelper
* @param PHPExcel_Worksheet $pSheet The worksheet that we're editing * @param PHPExcel_Worksheet $pSheet The worksheet that we're editing
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
*/ */
public function insertNewBefore($pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, PHPExcel_Worksheet $pSheet = NULL) public function insertNewBefore($pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, PHPExcel_Worksheet $pSheet = null)
{ {
$remove = ($pNumCols < 0 || $pNumRows < 0); $remove = ($pNumCols < 0 || $pNumRows < 0);
$aCellCollection = $pSheet->getCellCollection(); $aCellCollection = $pSheet->getCellCollection();
@ -442,8 +446,7 @@ class PHPExcel_ReferenceHelper
if ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA) { if ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA) {
// Formula should be adjusted // Formula should be adjusted
$pSheet->getCell($newCoordinates) $pSheet->getCell($newCoordinates)
->setValue($this->updateFormulaReferences($cell->getValue(), ->setValue($this->updateFormulaReferences($cell->getValue(), $pBefore, $pNumCols, $pNumRows, $pSheet->getTitle()));
$pBefore, $pNumCols, $pNumRows, $pSheet->getTitle()));
} else { } else {
// Formula should not be adjusted // Formula should not be adjusted
$pSheet->getCell($newCoordinates)->setValue($cell->getValue()); $pSheet->getCell($newCoordinates)->setValue($cell->getValue());
@ -451,14 +454,12 @@ class PHPExcel_ReferenceHelper
// Clear the original cell // Clear the original cell
$pSheet->getCellCacheController()->deleteCacheData($cellID); $pSheet->getCellCacheController()->deleteCacheData($cellID);
} else { } else {
/* We don't need to update styles for rows/columns before our insertion position, /* We don't need to update styles for rows/columns before our insertion position,
but we do still need to adjust any formulae in those cells */ but we do still need to adjust any formulae in those cells */
if ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA) { if ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA) {
// Formula should be adjusted // Formula should be adjusted
$cell->setValue($this->updateFormulaReferences($cell->getValue(), $cell->setValue($this->updateFormulaReferences($cell->getValue(), $pBefore, $pNumCols, $pNumRows, $pSheet->getTitle()));
$pBefore, $pNumCols, $pNumRows, $pSheet->getTitle()));
} }
} }
@ -472,7 +473,7 @@ class PHPExcel_ReferenceHelper
for ($i = $beforeRow; $i <= $highestRow - 1; ++$i) { for ($i = $beforeRow; $i <= $highestRow - 1; ++$i) {
// Style // Style
$coordinate = PHPExcel_Cell::stringFromColumnIndex( $beforeColumnIndex - 2 ) . $i; $coordinate = PHPExcel_Cell::stringFromColumnIndex($beforeColumnIndex - 2) . $i;
if ($pSheet->cellExists($coordinate)) { if ($pSheet->cellExists($coordinate)) {
$xfIndex = $pSheet->getCell($coordinate)->getXfIndex(); $xfIndex = $pSheet->getCell($coordinate)->getXfIndex();
$conditionalStyles = $pSheet->conditionalStylesExists($coordinate) ? $conditionalStyles = $pSheet->conditionalStylesExists($coordinate) ?
@ -594,17 +595,17 @@ class PHPExcel_ReferenceHelper
} }
} }
} }
$pSheet->setAutoFilter( $this->updateCellReference($autoFilterRange, $pBefore, $pNumCols, $pNumRows) ); $pSheet->setAutoFilter($this->updateCellReference($autoFilterRange, $pBefore, $pNumCols, $pNumRows));
} }
// Update worksheet: freeze pane // Update worksheet: freeze pane
if ($pSheet->getFreezePane() != '') { if ($pSheet->getFreezePane() != '') {
$pSheet->freezePane( $this->updateCellReference($pSheet->getFreezePane(), $pBefore, $pNumCols, $pNumRows) ); $pSheet->freezePane($this->updateCellReference($pSheet->getFreezePane(), $pBefore, $pNumCols, $pNumRows));
} }
// Page setup // Page setup
if ($pSheet->getPageSetup()->isPrintAreaSet()) { if ($pSheet->getPageSetup()->isPrintAreaSet()) {
$pSheet->getPageSetup()->setPrintArea( $this->updateCellReference($pSheet->getPageSetup()->getPrintArea(), $pBefore, $pNumCols, $pNumRows) ); $pSheet->getPageSetup()->setPrintArea($this->updateCellReference($pSheet->getPageSetup()->getPrintArea(), $pBefore, $pNumCols, $pNumRows));
} }
// Update worksheet: drawings // Update worksheet: drawings
@ -620,9 +621,7 @@ class PHPExcel_ReferenceHelper
if (count($pSheet->getParent()->getNamedRanges()) > 0) { if (count($pSheet->getParent()->getNamedRanges()) > 0) {
foreach ($pSheet->getParent()->getNamedRanges() as $namedRange) { foreach ($pSheet->getParent()->getNamedRanges() as $namedRange) {
if ($namedRange->getWorksheet()->getHashCode() == $pSheet->getHashCode()) { if ($namedRange->getWorksheet()->getHashCode() == $pSheet->getHashCode()) {
$namedRange->setRange( $namedRange->setRange($this->updateCellReference($namedRange->getRange(), $pBefore, $pNumCols, $pNumRows));
$this->updateCellReference($namedRange->getRange(), $pBefore, $pNumCols, $pNumRows)
);
} }
} }
} }
@ -642,7 +641,8 @@ class PHPExcel_ReferenceHelper
* @return string Updated formula * @return string Updated formula
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
*/ */
public function updateFormulaReferences($pFormula = '', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, $sheetName = '') { public function updateFormulaReferences($pFormula = '', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, $sheetName = '')
{
// Update cell references in the formula // Update cell references in the formula
$formulaBlocks = explode('"', $pFormula); $formulaBlocks = explode('"', $pFormula);
$i = false; $i = false;
@ -657,8 +657,8 @@ class PHPExcel_ReferenceHelper
foreach ($matches as $match) { foreach ($matches as $match) {
$fromString = ($match[2] > '') ? $match[2].'!' : ''; $fromString = ($match[2] > '') ? $match[2].'!' : '';
$fromString .= $match[3].':'.$match[4]; $fromString .= $match[3].':'.$match[4];
$modified3 = substr($this->updateCellReference('$A'.$match[3], $pBefore, $pNumCols, $pNumRows),2); $modified3 = substr($this->updateCellReference('$A'.$match[3], $pBefore, $pNumCols, $pNumRows), 2);
$modified4 = substr($this->updateCellReference('$A'.$match[4], $pBefore, $pNumCols, $pNumRows),2); $modified4 = substr($this->updateCellReference('$A'.$match[4], $pBefore, $pNumCols, $pNumRows), 2);
if ($match[3].':'.$match[4] !== $modified3.':'.$modified4) { if ($match[3].':'.$match[4] !== $modified3.':'.$modified4) {
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) { if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) {
@ -682,8 +682,8 @@ class PHPExcel_ReferenceHelper
foreach ($matches as $match) { foreach ($matches as $match) {
$fromString = ($match[2] > '') ? $match[2].'!' : ''; $fromString = ($match[2] > '') ? $match[2].'!' : '';
$fromString .= $match[3].':'.$match[4]; $fromString .= $match[3].':'.$match[4];
$modified3 = substr($this->updateCellReference($match[3].'$1', $pBefore, $pNumCols, $pNumRows),0,-2); $modified3 = substr($this->updateCellReference($match[3].'$1', $pBefore, $pNumCols, $pNumRows), 0, -2);
$modified4 = substr($this->updateCellReference($match[4].'$1', $pBefore, $pNumCols, $pNumRows),0,-2); $modified4 = substr($this->updateCellReference($match[4].'$1', $pBefore, $pNumCols, $pNumRows), 0, -2);
if ($match[3].':'.$match[4] !== $modified3.':'.$modified4) { if ($match[3].':'.$match[4] !== $modified3.':'.$modified4) {
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) { if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) {
@ -781,7 +781,8 @@ class PHPExcel_ReferenceHelper
* @return string Updated cell range * @return string Updated cell range
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
*/ */
public function updateCellReference($pCellRange = 'A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) { public function updateCellReference($pCellRange = 'A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0)
{
// Is it in another worksheet? Will not have to update anything. // Is it in another worksheet? Will not have to update anything.
if (strpos($pCellRange, "!") !== false) { if (strpos($pCellRange, "!") !== false) {
return $pCellRange; return $pCellRange;
@ -805,7 +806,8 @@ class PHPExcel_ReferenceHelper
* @param string $oldName Old name (name to replace) * @param string $oldName Old name (name to replace)
* @param string $newName New name * @param string $newName New name
*/ */
public function updateNamedFormulas(PHPExcel $pPhpExcel, $oldName = '', $newName = '') { public function updateNamedFormulas(PHPExcel $pPhpExcel, $oldName = '', $newName = '')
{
if ($oldName == '') { if ($oldName == '') {
return; return;
} }
@ -813,7 +815,7 @@ class PHPExcel_ReferenceHelper
foreach ($pPhpExcel->getWorksheetIterator() as $sheet) { foreach ($pPhpExcel->getWorksheetIterator() as $sheet) {
foreach ($sheet->getCellCollection(false) as $cellID) { foreach ($sheet->getCellCollection(false) as $cellID) {
$cell = $sheet->getCell($cellID); $cell = $sheet->getCell($cellID);
if (($cell !== NULL) && ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA)) { if (($cell !== null) && ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA)) {
$formula = $cell->getValue(); $formula = $cell->getValue();
if (strpos($formula, $oldName) !== false) { if (strpos($formula, $oldName) !== false) {
$formula = str_replace("'" . $oldName . "'!", "'" . $newName . "'!", $formula); $formula = str_replace("'" . $oldName . "'!", "'" . $newName . "'!", $formula);
@ -835,7 +837,8 @@ class PHPExcel_ReferenceHelper
* @return string Updated cell range * @return string Updated cell range
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
*/ */
private function _updateCellRange($pCellRange = 'A1:A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) { private function _updateCellRange($pCellRange = 'A1:A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0)
{
if (strpos($pCellRange,':') !== false || strpos($pCellRange, ',') !== false) { if (strpos($pCellRange,':') !== false || strpos($pCellRange, ',') !== false) {
// Update range // Update range
$range = PHPExcel_Cell::splitRange($pCellRange); $range = PHPExcel_Cell::splitRange($pCellRange);
@ -872,23 +875,22 @@ class PHPExcel_ReferenceHelper
* @return string Updated cell reference * @return string Updated cell reference
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
*/ */
private function _updateSingleCellReference($pCellReference = 'A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) { private function _updateSingleCellReference($pCellReference = 'A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0)
{
if (strpos($pCellReference, ':') === false && strpos($pCellReference, ',') === false) { if (strpos($pCellReference, ':') === false && strpos($pCellReference, ',') === false) {
// Get coordinates of $pBefore // Get coordinates of $pBefore
list($beforeColumn, $beforeRow) = PHPExcel_Cell::coordinateFromString( $pBefore ); list($beforeColumn, $beforeRow) = PHPExcel_Cell::coordinateFromString($pBefore);
// Get coordinates of $pCellReference // Get coordinates of $pCellReference
list($newColumn, $newRow) = PHPExcel_Cell::coordinateFromString( $pCellReference ); list($newColumn, $newRow) = PHPExcel_Cell::coordinateFromString($pCellReference);
// Verify which parts should be updated // Verify which parts should be updated
$updateColumn = (($newColumn{0} != '$') && ($beforeColumn{0} != '$') && $updateColumn = (($newColumn{0} != '$') && ($beforeColumn{0} != '$') && (PHPExcel_Cell::columnIndexFromString($newColumn) >= PHPExcel_Cell::columnIndexFromString($beforeColumn)));
PHPExcel_Cell::columnIndexFromString($newColumn) >= PHPExcel_Cell::columnIndexFromString($beforeColumn)); $updateRow = (($newRow{0} != '$') && ($beforeRow{0} != '$') && $newRow >= $beforeRow);
$updateRow = (($newRow{0} != '$') && ($beforeRow{0} != '$') &&
$newRow >= $beforeRow);
// Create new column reference // Create new column reference
if ($updateColumn) { if ($updateColumn) {
$newColumn = PHPExcel_Cell::stringFromColumnIndex( PHPExcel_Cell::columnIndexFromString($newColumn) - 1 + $pNumCols ); $newColumn = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($newColumn) - 1 + $pNumCols);
} }
// Create new row reference // Create new row reference
@ -908,7 +910,8 @@ class PHPExcel_ReferenceHelper
* *
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
*/ */
public final function __clone() { final public function __clone()
{
throw new PHPExcel_Exception("Cloning a Singleton is not allowed!"); throw new PHPExcel_Exception("Cloning a Singleton is not allowed!");
} }
} }

View File

@ -41,7 +41,8 @@ class PHPExcel_Shared_Drawing
* @param int $pValue Value in pixels * @param int $pValue Value in pixels
* @return int Value in EMU * @return int Value in EMU
*/ */
public static function pixelsToEMU($pValue = 0) { public static function pixelsToEMU($pValue = 0)
{
return round($pValue * 9525); return round($pValue * 9525);
} }
@ -51,7 +52,8 @@ class PHPExcel_Shared_Drawing
* @param int $pValue Value in EMU * @param int $pValue Value in EMU
* @return int Value in pixels * @return int Value in pixels
*/ */
public static function EMUToPixels($pValue = 0) { public static function EMUToPixels($pValue = 0)
{
if ($pValue != 0) { if ($pValue != 0) {
return round($pValue / 9525); return round($pValue / 9525);
} else { } else {
@ -68,22 +70,19 @@ class PHPExcel_Shared_Drawing
* @param PHPExcel_Style_Font $pDefaultFont Default font of the workbook * @param PHPExcel_Style_Font $pDefaultFont Default font of the workbook
* @return int Value in cell dimension * @return int Value in cell dimension
*/ */
public static function pixelsToCellDimension($pValue = 0, PHPExcel_Style_Font $pDefaultFont) { public static function pixelsToCellDimension($pValue = 0, PHPExcel_Style_Font $pDefaultFont)
{
// Font name and size // Font name and size
$name = $pDefaultFont->getName(); $name = $pDefaultFont->getName();
$size = $pDefaultFont->getSize(); $size = $pDefaultFont->getSize();
if (isset(PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size])) { if (isset(PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size])) {
// Exact width can be determined // Exact width can be determined
$colWidth = $pValue $colWidth = $pValue * PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['width'] / PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['px'];
* PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['width']
/ PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['px'];
} else { } else {
// We don't have data for this particular font and size, use approximation by // We don't have data for this particular font and size, use approximation by
// extrapolating from Calibri 11 // extrapolating from Calibri 11
$colWidth = $pValue * 11 $colWidth = $pValue * 11 * PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['width'] / PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['px'] / $size;
* PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['width']
/ PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['px'] / $size;
} }
return $colWidth; return $colWidth;
@ -96,23 +95,19 @@ class PHPExcel_Shared_Drawing
* @param PHPExcel_Style_Font $pDefaultFont Default font of the workbook * @param PHPExcel_Style_Font $pDefaultFont Default font of the workbook
* @return int Value in pixels * @return int Value in pixels
*/ */
public static function cellDimensionToPixels($pValue = 0, PHPExcel_Style_Font $pDefaultFont) { public static function cellDimensionToPixels($pValue = 0, PHPExcel_Style_Font $pDefaultFont)
{
// Font name and size // Font name and size
$name = $pDefaultFont->getName(); $name = $pDefaultFont->getName();
$size = $pDefaultFont->getSize(); $size = $pDefaultFont->getSize();
if (isset(PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size])) { if (isset(PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size])) {
// Exact width can be determined // Exact width can be determined
$colWidth = $pValue $colWidth = $pValue * PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['px'] / PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['width'];
* PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['px']
/ PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['width'];
} else { } else {
// We don't have data for this particular font and size, use approximation by // We don't have data for this particular font and size, use approximation by
// extrapolating from Calibri 11 // extrapolating from Calibri 11
$colWidth = $pValue * $size $colWidth = $pValue * $size * PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['px'] / PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['width'] / 11;
* PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['px']
/ PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['width'] / 11;
} }
// Round pixels to closest integer // Round pixels to closest integer
@ -127,7 +122,8 @@ class PHPExcel_Shared_Drawing
* @param int $pValue Value in pixels * @param int $pValue Value in pixels
* @return int Value in points * @return int Value in points
*/ */
public static function pixelsToPoints($pValue = 0) { public static function pixelsToPoints($pValue = 0)
{
return $pValue * 0.67777777; return $pValue * 0.67777777;
} }
@ -137,7 +133,8 @@ class PHPExcel_Shared_Drawing
* @param int $pValue Value in points * @param int $pValue Value in points
* @return int Value in pixels * @return int Value in pixels
*/ */
public static function pointsToPixels($pValue = 0) { public static function pointsToPixels($pValue = 0)
{
if ($pValue != 0) { if ($pValue != 0) {
return (int) ceil($pValue * 1.333333333); return (int) ceil($pValue * 1.333333333);
} else { } else {
@ -151,7 +148,8 @@ class PHPExcel_Shared_Drawing
* @param int $pValue Degrees * @param int $pValue Degrees
* @return int Angle * @return int Angle
*/ */
public static function degreesToAngle($pValue = 0) { public static function degreesToAngle($pValue = 0)
{
return (int)round($pValue * 60000); return (int)round($pValue * 60000);
} }
@ -161,7 +159,8 @@ class PHPExcel_Shared_Drawing
* @param int $pValue Angle * @param int $pValue Angle
* @return int Degrees * @return int Degrees
*/ */
public static function angleToDegrees($pValue = 0) { public static function angleToDegrees($pValue = 0)
{
if ($pValue != 0) { if ($pValue != 0) {
return round($pValue / 60000); return round($pValue / 60000);
} else { } else {
@ -179,94 +178,93 @@ class PHPExcel_Shared_Drawing
public static function imagecreatefrombmp($p_sFile) public static function imagecreatefrombmp($p_sFile)
{ {
// Load the image into a string // Load the image into a string
$file = fopen($p_sFile,"rb"); $file = fopen($p_sFile, "rb");
$read = fread($file,10); $read = fread($file, 10);
while (!feof($file)&&($read<>"")) while (!feof($file) && ($read<>"")) {
$read .= fread($file,1024); $read .= fread($file, 1024);
}
$temp = unpack("H*", $read); $temp = unpack("H*", $read);
$hex = $temp[1]; $hex = $temp[1];
$header = substr($hex,0,108); $header = substr($hex, 0, 108);
// Process the header // Process the header
// Structure: http://www.fastgraph.com/help/bmp_header_format.html // Structure: http://www.fastgraph.com/help/bmp_header_format.html
if (substr($header,0,4)=="424d") if (substr($header, 0, 4)=="424d") {
{
// Cut it in parts of 2 bytes // Cut it in parts of 2 bytes
$header_parts = str_split($header,2); $header_parts = str_split($header, 2);
// Get the width 4 bytes // Get the width 4 bytes
$width = hexdec($header_parts[19].$header_parts[18]); $width = hexdec($header_parts[19].$header_parts[18]);
// Get the height 4 bytes // Get the height 4 bytes
$height = hexdec($header_parts[23].$header_parts[22]); $height = hexdec($header_parts[23].$header_parts[22]);
// Unset the header params // Unset the header params
unset($header_parts); unset($header_parts);
} }
// Define starting X and Y // Define starting X and Y
$x = 0; $x = 0;
$y = 1; $y = 1;
// Create newimage // Create newimage
$image = imagecreatetruecolor($width, $height); $image = imagecreatetruecolor($width, $height);
// Grab the body from the image // Grab the body from the image
$body = substr($hex,108); $body = substr($hex, 108);
// Calculate if padding at the end-line is needed // Calculate if padding at the end-line is needed
// Divided by two to keep overview. // Divided by two to keep overview.
// 1 byte = 2 HEX-chars // 1 byte = 2 HEX-chars
$body_size = (strlen($body)/2); $body_size = (strlen($body)/2);
$header_size = ($width*$height); $header_size = ($width*$height);
// Use end-line padding? Only when needed // Use end-line padding? Only when needed
$usePadding = ($body_size>($header_size*3)+4); $usePadding = ($body_size>($header_size*3)+4);
// Using a for-loop with index-calculation instaid of str_split to avoid large memory consumption // Using a for-loop with index-calculation instaid of str_split to avoid large memory consumption
// Calculate the next DWORD-position in the body // Calculate the next DWORD-position in the body
for ($i=0;$i<$body_size;$i+=3) for ($i = 0 ; $i < $body_size ; $i += 3) {
{
// Calculate line-ending and padding // Calculate line-ending and padding
if ($x>=$width) if ($x >= $width) {
{ // If padding needed, ignore image-padding
// If padding needed, ignore image-padding // Shift i to the ending of the current 32-bit-block
// Shift i to the ending of the current 32-bit-block if ($usePadding) {
if ($usePadding) $i += $width%4;
$i += $width%4; }
// Reset horizontal position // Reset horizontal position
$x = 0; $x = 0;
// Raise the height-position (bottom-up) // Raise the height-position (bottom-up)
$y++; $y++;
// Reached the image-height? Break the for-loop // Reached the image-height? Break the for-loop
if ($y>$height) if ($y > $height) {
break; break;
}
} }
// Calculation of the RGB-pixel (defined as BGR in image-data) // Calculation of the RGB-pixel (defined as BGR in image-data)
// Define $i_pos as absolute position in the body // Define $i_pos as absolute position in the body
$i_pos = $i*2; $i_pos = $i * 2;
$r = hexdec($body[$i_pos+4].$body[$i_pos+5]); $r = hexdec($body[$i_pos+4].$body[$i_pos+5]);
$g = hexdec($body[$i_pos+2].$body[$i_pos+3]); $g = hexdec($body[$i_pos+2].$body[$i_pos+3]);
$b = hexdec($body[$i_pos].$body[$i_pos+1]); $b = hexdec($body[$i_pos].$body[$i_pos+1]);
// Calculate and draw the pixel // Calculate and draw the pixel
$color = imagecolorallocate($image, $r, $g, $b); $color = imagecolorallocate($image, $r, $g, $b);
imagesetpixel($image, $x, $height-$y, $color); imagesetpixel($image, $x, $height-$y, $color);
// Raise the horizontal position // Raise the horizontal position
$x++; $x++;
} }
// Unset the body / free the memory // Unset the body / free the memory
unset($body); unset($body);
// Return image-object // Return image-object
return $image; return $image;
} }
} }

View File

@ -87,5 +87,4 @@ class PHPExcel_Shared_Escher
{ {
return $this->_dgContainer = $dgContainer; return $this->_dgContainer = $dgContainer;
} }
} }

View File

@ -41,7 +41,7 @@ class PHPExcel_Shared_File
* @protected * @protected
* @var boolean * @var boolean
*/ */
protected static $_useUploadTempDirectory = FALSE; protected static $_useUploadTempDirectory = false;
/** /**
@ -49,9 +49,10 @@ class PHPExcel_Shared_File
* *
* @param boolean $useUploadTempDir Use File Upload Temporary directory (true or false) * @param boolean $useUploadTempDir Use File Upload Temporary directory (true or false)
*/ */
public static function setUseUploadTempDirectory($useUploadTempDir = FALSE) { public static function setUseUploadTempDirectory($useUploadTempDir = false)
{
self::$_useUploadTempDirectory = (boolean) $useUploadTempDir; self::$_useUploadTempDirectory = (boolean) $useUploadTempDir;
} // function setUseUploadTempDirectory() }
/** /**
@ -59,9 +60,10 @@ class PHPExcel_Shared_File
* *
* @return boolean Use File Upload Temporary directory (true or false) * @return boolean Use File Upload Temporary directory (true or false)
*/ */
public static function getUseUploadTempDirectory() { public static function getUseUploadTempDirectory()
{
return self::$_useUploadTempDirectory; return self::$_useUploadTempDirectory;
} // function getUseUploadTempDirectory() }
/** /**
@ -70,11 +72,12 @@ class PHPExcel_Shared_File
* @param string $pFilename Filename * @param string $pFilename Filename
* @return bool * @return bool
*/ */
public static function file_exists($pFilename) { public static function file_exists($pFilename)
{
// Sick construction, but it seems that // Sick construction, but it seems that
// file_exists returns strange values when // file_exists returns strange values when
// doing the original file_exists on ZIP archives... // doing the original file_exists on ZIP archives...
if ( strtolower(substr($pFilename, 0, 3)) == 'zip' ) { if (strtolower(substr($pFilename, 0, 3)) == 'zip') {
// Open ZIP file and verify if the file exists // Open ZIP file and verify if the file exists
$zipFile = substr($pFilename, 6, strpos($pFilename, '#') - 6); $zipFile = substr($pFilename, 6, strpos($pFilename, '#') - 6);
$archiveFile = substr($pFilename, strpos($pFilename, '#') + 1); $archiveFile = substr($pFilename, strpos($pFilename, '#') + 1);
@ -99,7 +102,8 @@ class PHPExcel_Shared_File
* @param string $pFilename * @param string $pFilename
* @return string * @return string
*/ */
public static function realpath($pFilename) { public static function realpath($pFilename)
{
// Returnvalue // Returnvalue
$returnValue = ''; $returnValue = '';
@ -109,8 +113,8 @@ class PHPExcel_Shared_File
} }
// Found something? // Found something?
if ($returnValue == '' || ($returnValue === NULL)) { if ($returnValue == '' || ($returnValue === null)) {
$pathArray = explode('/' , $pFilename); $pathArray = explode('/', $pFilename);
while (in_array('..', $pathArray) && $pathArray[0] != '..') { while (in_array('..', $pathArray) && $pathArray[0] != '..') {
for ($i = 0; $i < count($pathArray); ++$i) { for ($i = 0; $i < count($pathArray); ++$i) {
if ($pathArray[$i] == '..' && $i > 0) { if ($pathArray[$i] == '..' && $i > 0) {
@ -137,10 +141,11 @@ class PHPExcel_Shared_File
if (self::$_useUploadTempDirectory) { if (self::$_useUploadTempDirectory) {
// use upload-directory when defined to allow running on environments having very restricted // use upload-directory when defined to allow running on environments having very restricted
// open_basedir configs // open_basedir configs
if (ini_get('upload_tmp_dir') !== FALSE) { if (ini_get('upload_tmp_dir') !== false) {
if ($temp = ini_get('upload_tmp_dir')) { if ($temp = ini_get('upload_tmp_dir')) {
if (file_exists($temp)) if (file_exists($temp)) {
return realpath($temp); return realpath($temp);
}
} }
} }
} }
@ -149,13 +154,19 @@ class PHPExcel_Shared_File
// http://php.net/manual/en/function.sys-get-temp-dir.php#94119 // http://php.net/manual/en/function.sys-get-temp-dir.php#94119
if ( !function_exists('sys_get_temp_dir')) { if ( !function_exists('sys_get_temp_dir')) {
if ($temp = getenv('TMP') ) { if ($temp = getenv('TMP') ) {
if ((!empty($temp)) && (file_exists($temp))) { return realpath($temp); } if ((!empty($temp)) && (file_exists($temp))) {
return realpath($temp);
}
} }
if ($temp = getenv('TEMP') ) { if ($temp = getenv('TEMP') ) {
if ((!empty($temp)) && (file_exists($temp))) { return realpath($temp); } if ((!empty($temp)) && (file_exists($temp))) {
return realpath($temp);
}
} }
if ($temp = getenv('TMPDIR') ) { if ($temp = getenv('TMPDIR') ) {
if ((!empty($temp)) && (file_exists($temp))) { return realpath($temp); } if ((!empty($temp)) && (file_exists($temp))) {
return realpath($temp);
}
} }
// trick for creating a file in system's temporary dir // trick for creating a file in system's temporary dir
@ -174,5 +185,4 @@ class PHPExcel_Shared_File
// be called if we're running 5.2.1 or earlier // be called if we're running 5.2.1 or earlier
return realpath(sys_get_temp_dir()); return realpath(sys_get_temp_dir());
} }
} }

View File

@ -159,7 +159,7 @@ class PHPExcel_Shared_OLE
for ($i = 0; $i < $bbatBlockCount; ++$i) { for ($i = 0; $i < $bbatBlockCount; ++$i) {
$pos = $this->_getBlockOffset($mbatBlocks[$i]); $pos = $this->_getBlockOffset($mbatBlocks[$i]);
fseek($fh, $pos); fseek($fh, $pos);
for ($j = 0 ; $j < $this->bigBlockSize / 4; ++$j) { for ($j = 0; $j < $this->bigBlockSize / 4; ++$j) {
$this->bbat[] = self::_readInt4($fh); $this->bbat[] = self::_readInt4($fh);
} }
} }
@ -198,8 +198,7 @@ class PHPExcel_Shared_OLE
{ {
static $isRegistered = false; static $isRegistered = false;
if (!$isRegistered) { if (!$isRegistered) {
stream_wrapper_register('ole-chainedblockstream', stream_wrapper_register('ole-chainedblockstream', 'PHPExcel_Shared_OLE_ChainedBlockStream');
'PHPExcel_Shared_OLE_ChainedBlockStream');
$isRegistered = true; $isRegistered = true;
} }
@ -266,7 +265,7 @@ class PHPExcel_Shared_OLE
public function _readPpsWks($blockId) public function _readPpsWks($blockId)
{ {
$fh = $this->getStream($blockId); $fh = $this->getStream($blockId);
for ($pos = 0; ; $pos += 128) { for ($pos = 0;; $pos += 128) {
fseek($fh, $pos, SEEK_SET); fseek($fh, $pos, SEEK_SET);
$nameUtf16 = fread($fh, 64); $nameUtf16 = fread($fh, 64);
$nameLength = self::_readInt2($fh); $nameLength = self::_readInt2($fh);
@ -275,19 +274,18 @@ class PHPExcel_Shared_OLE
$name = str_replace("\x00", "", $nameUtf16); $name = str_replace("\x00", "", $nameUtf16);
$type = self::_readInt1($fh); $type = self::_readInt1($fh);
switch ($type) { switch ($type) {
case self::OLE_PPS_TYPE_ROOT: case self::OLE_PPS_TYPE_ROOT:
$pps = new PHPExcel_Shared_OLE_PPS_Root(null, null, array()); $pps = new PHPExcel_Shared_OLE_PPS_Root(null, null, array());
$this->root = $pps; $this->root = $pps;
break; break;
case self::OLE_PPS_TYPE_DIR: case self::OLE_PPS_TYPE_DIR:
$pps = new PHPExcel_Shared_OLE_PPS(null, null, null, null, null, $pps = new PHPExcel_Shared_OLE_PPS(null, null, null, null, null, null, null, null, null, array());
null, null, null, null, array()); break;
break; case self::OLE_PPS_TYPE_FILE:
case self::OLE_PPS_TYPE_FILE: $pps = new PHPExcel_Shared_OLE_PPS_File($name);
$pps = new PHPExcel_Shared_OLE_PPS_File($name); break;
break; default:
default: continue;
continue;
} }
fseek($fh, 1, SEEK_CUR); fseek($fh, 1, SEEK_CUR);
$pps->Type = $type; $pps->Type = $type;
@ -304,9 +302,7 @@ class PHPExcel_Shared_OLE
$this->_list[] = $pps; $this->_list[] = $pps;
// check if the PPS tree (starting from root) is complete // check if the PPS tree (starting from root) is complete
if (isset($this->root) && if (isset($this->root) && $this->_ppsTreeComplete($this->root->No)) {
$this->_ppsTreeComplete($this->root->No)) {
break; break;
} }
} }
@ -473,8 +469,7 @@ class PHPExcel_Shared_OLE
// days from 1-1-1601 until the beggining of UNIX era // days from 1-1-1601 until the beggining of UNIX era
$days = 134774; $days = 134774;
// calculate seconds // calculate seconds
$big_date = $days*24*3600 + gmmktime(date("H", $date),date("i", $date),date("s", $date), $big_date = $days*24*3600 + gmmktime(date("H", $date), date("i", $date), date("s", $date), date("m", $date), date("d", $date), date("Y", $date));
date("m", $date),date("d", $date),date("Y", $date));
// multiply just to make MS happy // multiply just to make MS happy
$big_date *= 10000000; $big_date *= 10000000;
@ -513,7 +508,7 @@ class PHPExcel_Shared_OLE
} }
// factor used for separating numbers into 4 bytes parts // factor used for separating numbers into 4 bytes parts
$factor = pow(2,32); $factor = pow(2, 32);
list(, $high_part) = unpack('V', substr($string, 4, 4)); list(, $high_part) = unpack('V', substr($string, 4, 4));
list(, $low_part) = unpack('V', substr($string, 0, 4)); list(, $low_part) = unpack('V', substr($string, 0, 4));

File diff suppressed because it is too large Load Diff

View File

@ -57,9 +57,10 @@ class PHPExcel_Shared_ZipStreamWrapper {
/** /**
* Register wrapper * Register wrapper
*/ */
public static function register() { public static function register()
@stream_wrapper_unregister("zip"); {
@stream_wrapper_register("zip", __CLASS__); @stream_wrapper_unregister('zip');
@stream_wrapper_register('zip', __CLASS__);
} }
/** /**
@ -71,7 +72,8 @@ class PHPExcel_Shared_ZipStreamWrapper {
* @param string &$openedPath absolute path of the opened stream (out parameter) * @param string &$openedPath absolute path of the opened stream (out parameter)
* @return bool true on success * @return bool true on success
*/ */
public function stream_open($path, $mode, $options, &$opened_path) { public function stream_open($path, $mode, $options, &$opened_path)
{
// Check for mode // Check for mode
if ($mode{0} != 'r') { if ($mode{0} != 'r') {
throw new PHPExcel_Reader_Exception('Mode ' . $mode . ' is not supported. Only read mode is supported.'); throw new PHPExcel_Reader_Exception('Mode ' . $mode . ' is not supported. Only read mode is supported.');
@ -87,7 +89,7 @@ class PHPExcel_Shared_ZipStreamWrapper {
$this->_fileNameInArchive = $url['fragment']; $this->_fileNameInArchive = $url['fragment'];
$this->_position = 0; $this->_position = 0;
$this->_data = $this->_archive->getFromName( $this->_fileNameInArchive ); $this->_data = $this->_archive->getFromName($this->_fileNameInArchive);
return true; return true;
} }
@ -97,7 +99,8 @@ class PHPExcel_Shared_ZipStreamWrapper {
* *
* @return boolean * @return boolean
*/ */
public function statName() { public function statName()
{
return $this->_fileNameInArchive; return $this->_fileNameInArchive;
} }
@ -106,8 +109,9 @@ class PHPExcel_Shared_ZipStreamWrapper {
* *
* @return boolean * @return boolean
*/ */
public function url_stat() { public function url_stat()
return $this->statName( $this->_fileNameInArchive ); {
return $this->statName($this->_fileNameInArchive);
} }
/** /**
@ -115,8 +119,9 @@ class PHPExcel_Shared_ZipStreamWrapper {
* *
* @return boolean * @return boolean
*/ */
public function stream_stat() { public function stream_stat()
return $this->_archive->statName( $this->_fileNameInArchive ); {
return $this->_archive->statName($this->_fileNameInArchive);
} }
/** /**
@ -125,7 +130,8 @@ class PHPExcel_Shared_ZipStreamWrapper {
* @param int $count maximum number of bytes to read * @param int $count maximum number of bytes to read
* @return string * @return string
*/ */
function stream_read($count) { function stream_read($count)
{
$ret = substr($this->_data, $this->_position, $count); $ret = substr($this->_data, $this->_position, $count);
$this->_position += strlen($ret); $this->_position += strlen($ret);
return $ret; return $ret;
@ -137,7 +143,8 @@ class PHPExcel_Shared_ZipStreamWrapper {
* *
* @return int * @return int
*/ */
public function stream_tell() { public function stream_tell()
{
return $this->_position; return $this->_position;
} }
@ -146,7 +153,8 @@ class PHPExcel_Shared_ZipStreamWrapper {
* *
* @return bool * @return bool
*/ */
public function stream_eof() { public function stream_eof()
{
return $this->_position >= strlen($this->_data); return $this->_position >= strlen($this->_data);
} }
@ -157,7 +165,8 @@ class PHPExcel_Shared_ZipStreamWrapper {
* @param int $whence SEEK_SET, SEEK_CUR or SEEK_END * @param int $whence SEEK_SET, SEEK_CUR or SEEK_END
* @return bool * @return bool
*/ */
public function stream_seek($offset, $whence) { public function stream_seek($offset, $whence)
{
switch ($whence) { switch ($whence) {
case SEEK_SET: case SEEK_SET:
if ($offset < strlen($this->_data) && $offset >= 0) { if ($offset < strlen($this->_data) && $offset >= 0) {
@ -167,7 +176,6 @@ class PHPExcel_Shared_ZipStreamWrapper {
return false; return false;
} }
break; break;
case SEEK_CUR: case SEEK_CUR:
if ($offset >= 0) { if ($offset >= 0) {
$this->_position += $offset; $this->_position += $offset;
@ -176,7 +184,6 @@ class PHPExcel_Shared_ZipStreamWrapper {
return false; return false;
} }
break; break;
case SEEK_END: case SEEK_END:
if (strlen($this->_data) + $offset >= 0) { if (strlen($this->_data) + $offset >= 0) {
$this->_position = strlen($this->_data) + $offset; $this->_position = strlen($this->_data) + $offset;
@ -185,7 +192,6 @@ class PHPExcel_Shared_ZipStreamWrapper {
return false; return false;
} }
break; break;
default: default:
return false; return false;
} }

View File

@ -210,7 +210,6 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp
{ {
if (is_array($pStyles)) { if (is_array($pStyles)) {
if ($this->isSupervisor) { if ($this->isSupervisor) {
$pRange = $this->getSelectedCells(); $pRange = $this->getSelectedCells();
// Uppercase coordinate // Uppercase coordinate
@ -322,7 +321,7 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp
unset($regionStyles['borders']['inside']); unset($regionStyles['borders']['inside']);
// what are the inner edges of the region when looking at the selection // what are the inner edges of the region when looking at the selection
$innerEdges = array_diff( array('top', 'right', 'bottom', 'left'), $edges ); $innerEdges = array_diff(array('top', 'right', 'bottom', 'left'), $edges);
// inner edges that are not touching the region should take the 'inside' border properties if they have been set // inner edges that are not touching the region should take the 'inside' border properties if they have been set
foreach ($innerEdges as $innerEdge) { foreach ($innerEdges as $innerEdge) {

View File

@ -240,21 +240,21 @@ class PHPExcel_Writer_Excel2007_DocProps extends PHPExcel_Writer_Excel2007_Write
$objWriter->writeAttribute('name', $customProperty); $objWriter->writeAttribute('name', $customProperty);
switch ($propertyType) { switch ($propertyType) {
case 'i' : case 'i':
$objWriter->writeElement('vt:i4', $propertyValue); $objWriter->writeElement('vt:i4', $propertyValue);
break; break;
case 'f' : case 'f':
$objWriter->writeElement('vt:r8', $propertyValue); $objWriter->writeElement('vt:r8', $propertyValue);
break; break;
case 'b' : case 'b':
$objWriter->writeElement('vt:bool', ($propertyValue) ? 'true' : 'false'); $objWriter->writeElement('vt:bool', ($propertyValue) ? 'true' : 'false');
break; break;
case 'd' : case 'd':
$objWriter->startElement('vt:filetime'); $objWriter->startElement('vt:filetime');
$objWriter->writeRawData(date(DATE_W3C, $propertyValue)); $objWriter->writeRawData(date(DATE_W3C, $propertyValue));
$objWriter->endElement(); $objWriter->endElement();
break; break;
default : default:
$objWriter->writeElement('vt:lpwstr', $propertyValue); $objWriter->writeElement('vt:lpwstr', $propertyValue);
break; break;
} }

View File

@ -44,7 +44,7 @@ class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_Writer
* @return string XML Output * @return string XML Output
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function writeDrawings(PHPExcel_Worksheet $pWorksheet = null, &$chartRef, $includeCharts = FALSE) public function writeDrawings(PHPExcel_Worksheet $pWorksheet = null, &$chartRef, $includeCharts = false)
{ {
// Create XML writer // Create XML writer
$objWriter = null; $objWriter = null;
@ -62,26 +62,25 @@ class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_Writer
$objWriter->writeAttribute('xmlns:xdr', 'http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing'); $objWriter->writeAttribute('xmlns:xdr', 'http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing');
$objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main'); $objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main');
// Loop through images and write drawings // Loop through images and write drawings
$i = 1; $i = 1;
$iterator = $pWorksheet->getDrawingCollection()->getIterator(); $iterator = $pWorksheet->getDrawingCollection()->getIterator();
while ($iterator->valid()) { while ($iterator->valid()) {
$this->_writeDrawing($objWriter, $iterator->current(), $i); $this->_writeDrawing($objWriter, $iterator->current(), $i);
$iterator->next(); $iterator->next();
++$i; ++$i;
} }
if ($includeCharts) { if ($includeCharts) {
$chartCount = $pWorksheet->getChartCount(); $chartCount = $pWorksheet->getChartCount();
// Loop through charts and write the chart position // Loop through charts and write the chart position
if ($chartCount > 0) { if ($chartCount > 0) {
for ($c = 0; $c < $chartCount; ++$c) { for ($c = 0; $c < $chartCount; ++$c) {
$this->_writeChart($objWriter, $pWorksheet->getChartByIndex($c), $c+$i); $this->_writeChart($objWriter, $pWorksheet->getChartByIndex($c), $c+$i);
}
} }
} }
}
$objWriter->endElement(); $objWriter->endElement();
@ -174,81 +173,81 @@ class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_Writer
if ($pRelationId >= 0) { if ($pRelationId >= 0) {
// xdr:oneCellAnchor // xdr:oneCellAnchor
$objWriter->startElement('xdr:oneCellAnchor'); $objWriter->startElement('xdr:oneCellAnchor');
// Image location // Image location
$aCoordinates = PHPExcel_Cell::coordinateFromString($pDrawing->getCoordinates()); $aCoordinates = PHPExcel_Cell::coordinateFromString($pDrawing->getCoordinates());
$aCoordinates[0] = PHPExcel_Cell::columnIndexFromString($aCoordinates[0]); $aCoordinates[0] = PHPExcel_Cell::columnIndexFromString($aCoordinates[0]);
// xdr:from // xdr:from
$objWriter->startElement('xdr:from'); $objWriter->startElement('xdr:from');
$objWriter->writeElement('xdr:col', $aCoordinates[0] - 1); $objWriter->writeElement('xdr:col', $aCoordinates[0] - 1);
$objWriter->writeElement('xdr:colOff', PHPExcel_Shared_Drawing::pixelsToEMU($pDrawing->getOffsetX())); $objWriter->writeElement('xdr:colOff', PHPExcel_Shared_Drawing::pixelsToEMU($pDrawing->getOffsetX()));
$objWriter->writeElement('xdr:row', $aCoordinates[1] - 1); $objWriter->writeElement('xdr:row', $aCoordinates[1] - 1);
$objWriter->writeElement('xdr:rowOff', PHPExcel_Shared_Drawing::pixelsToEMU($pDrawing->getOffsetY())); $objWriter->writeElement('xdr:rowOff', PHPExcel_Shared_Drawing::pixelsToEMU($pDrawing->getOffsetY()));
$objWriter->endElement(); $objWriter->endElement();
// xdr:ext // xdr:ext
$objWriter->startElement('xdr:ext'); $objWriter->startElement('xdr:ext');
$objWriter->writeAttribute('cx', PHPExcel_Shared_Drawing::pixelsToEMU($pDrawing->getWidth())); $objWriter->writeAttribute('cx', PHPExcel_Shared_Drawing::pixelsToEMU($pDrawing->getWidth()));
$objWriter->writeAttribute('cy', PHPExcel_Shared_Drawing::pixelsToEMU($pDrawing->getHeight())); $objWriter->writeAttribute('cy', PHPExcel_Shared_Drawing::pixelsToEMU($pDrawing->getHeight()));
$objWriter->endElement(); $objWriter->endElement();
// xdr:pic // xdr:pic
$objWriter->startElement('xdr:pic'); $objWriter->startElement('xdr:pic');
// xdr:nvPicPr // xdr:nvPicPr
$objWriter->startElement('xdr:nvPicPr'); $objWriter->startElement('xdr:nvPicPr');
// xdr:cNvPr // xdr:cNvPr
$objWriter->startElement('xdr:cNvPr'); $objWriter->startElement('xdr:cNvPr');
$objWriter->writeAttribute('id', $pRelationId); $objWriter->writeAttribute('id', $pRelationId);
$objWriter->writeAttribute('name', $pDrawing->getName()); $objWriter->writeAttribute('name', $pDrawing->getName());
$objWriter->writeAttribute('descr', $pDrawing->getDescription()); $objWriter->writeAttribute('descr', $pDrawing->getDescription());
$objWriter->endElement(); $objWriter->endElement();
// xdr:cNvPicPr // xdr:cNvPicPr
$objWriter->startElement('xdr:cNvPicPr'); $objWriter->startElement('xdr:cNvPicPr');
// a:picLocks // a:picLocks
$objWriter->startElement('a:picLocks'); $objWriter->startElement('a:picLocks');
$objWriter->writeAttribute('noChangeAspect', '1'); $objWriter->writeAttribute('noChangeAspect', '1');
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
// xdr:blipFill // xdr:blipFill
$objWriter->startElement('xdr:blipFill'); $objWriter->startElement('xdr:blipFill');
// a:blip // a:blip
$objWriter->startElement('a:blip'); $objWriter->startElement('a:blip');
$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
$objWriter->writeAttribute('r:embed', 'rId' . $pRelationId); $objWriter->writeAttribute('r:embed', 'rId' . $pRelationId);
$objWriter->endElement(); $objWriter->endElement();
// a:stretch // a:stretch
$objWriter->startElement('a:stretch'); $objWriter->startElement('a:stretch');
$objWriter->writeElement('a:fillRect', null); $objWriter->writeElement('a:fillRect', null);
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
// xdr:spPr // xdr:spPr
$objWriter->startElement('xdr:spPr'); $objWriter->startElement('xdr:spPr');
// a:xfrm // a:xfrm
$objWriter->startElement('a:xfrm'); $objWriter->startElement('a:xfrm');
$objWriter->writeAttribute('rot', PHPExcel_Shared_Drawing::degreesToAngle($pDrawing->getRotation())); $objWriter->writeAttribute('rot', PHPExcel_Shared_Drawing::degreesToAngle($pDrawing->getRotation()));
$objWriter->endElement(); $objWriter->endElement();
// a:prstGeom // a:prstGeom
$objWriter->startElement('a:prstGeom'); $objWriter->startElement('a:prstGeom');
$objWriter->writeAttribute('prst', 'rect'); $objWriter->writeAttribute('prst', 'rect');
// a:avLst // a:avLst
$objWriter->writeElement('a:avLst', null); $objWriter->writeElement('a:avLst', null);
$objWriter->endElement(); $objWriter->endElement();
// // a:solidFill // // a:solidFill
// $objWriter->startElement('a:solidFill'); // $objWriter->startElement('a:solidFill');
@ -268,110 +267,110 @@ class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_Writer
// $objWriter->endElement(); // $objWriter->endElement();
/* /*
// a:ln // a:ln
$objWriter->startElement('a:ln'); $objWriter->startElement('a:ln');
$objWriter->writeAttribute('w', '88900'); $objWriter->writeAttribute('w', '88900');
$objWriter->writeAttribute('cap', 'sq'); $objWriter->writeAttribute('cap', 'sq');
// a:solidFill // a:solidFill
$objWriter->startElement('a:solidFill'); $objWriter->startElement('a:solidFill');
// a:srgbClr // a:srgbClr
$objWriter->startElement('a:srgbClr'); $objWriter->startElement('a:srgbClr');
$objWriter->writeAttribute('val', 'FFFFFF'); $objWriter->writeAttribute('val', 'FFFFFF');
$objWriter->endElement();
$objWriter->endElement();
// a:miter
$objWriter->startElement('a:miter');
$objWriter->writeAttribute('lim', '800000');
$objWriter->endElement();
$objWriter->endElement();
*/
if ($pDrawing->getShadow()->getVisible()) {
// a:effectLst
$objWriter->startElement('a:effectLst');
// a:outerShdw
$objWriter->startElement('a:outerShdw');
$objWriter->writeAttribute('blurRad', PHPExcel_Shared_Drawing::pixelsToEMU($pDrawing->getShadow()->getBlurRadius()));
$objWriter->writeAttribute('dist', PHPExcel_Shared_Drawing::pixelsToEMU($pDrawing->getShadow()->getDistance()));
$objWriter->writeAttribute('dir', PHPExcel_Shared_Drawing::degreesToAngle($pDrawing->getShadow()->getDirection()));
$objWriter->writeAttribute('algn', $pDrawing->getShadow()->getAlignment());
$objWriter->writeAttribute('rotWithShape', '0');
// a:srgbClr
$objWriter->startElement('a:srgbClr');
$objWriter->writeAttribute('val', $pDrawing->getShadow()->getColor()->getRGB());
// a:alpha
$objWriter->startElement('a:alpha');
$objWriter->writeAttribute('val', $pDrawing->getShadow()->getAlpha() * 1000);
$objWriter->endElement();
$objWriter->endElement();
$objWriter->endElement();
$objWriter->endElement();
}
/*
// a:scene3d
$objWriter->startElement('a:scene3d');
// a:camera
$objWriter->startElement('a:camera');
$objWriter->writeAttribute('prst', 'orthographicFront');
$objWriter->endElement();
// a:lightRig
$objWriter->startElement('a:lightRig');
$objWriter->writeAttribute('rig', 'twoPt');
$objWriter->writeAttribute('dir', 't');
// a:rot
$objWriter->startElement('a:rot');
$objWriter->writeAttribute('lat', '0');
$objWriter->writeAttribute('lon', '0');
$objWriter->writeAttribute('rev', '0');
$objWriter->endElement();
$objWriter->endElement();
$objWriter->endElement();
*/
/*
// a:sp3d
$objWriter->startElement('a:sp3d');
// a:bevelT
$objWriter->startElement('a:bevelT');
$objWriter->writeAttribute('w', '25400');
$objWriter->writeAttribute('h', '19050');
$objWriter->endElement();
// a:contourClr
$objWriter->startElement('a:contourClr');
// a:srgbClr
$objWriter->startElement('a:srgbClr');
$objWriter->writeAttribute('val', 'FFFFFF');
$objWriter->endElement();
$objWriter->endElement();
$objWriter->endElement();
*/
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
// xdr:clientData // a:miter
$objWriter->writeElement('xdr:clientData', null); $objWriter->startElement('a:miter');
$objWriter->writeAttribute('lim', '800000');
$objWriter->endElement();
$objWriter->endElement();
*/
if ($pDrawing->getShadow()->getVisible()) {
// a:effectLst
$objWriter->startElement('a:effectLst');
// a:outerShdw
$objWriter->startElement('a:outerShdw');
$objWriter->writeAttribute('blurRad', PHPExcel_Shared_Drawing::pixelsToEMU($pDrawing->getShadow()->getBlurRadius()));
$objWriter->writeAttribute('dist', PHPExcel_Shared_Drawing::pixelsToEMU($pDrawing->getShadow()->getDistance()));
$objWriter->writeAttribute('dir', PHPExcel_Shared_Drawing::degreesToAngle($pDrawing->getShadow()->getDirection()));
$objWriter->writeAttribute('algn', $pDrawing->getShadow()->getAlignment());
$objWriter->writeAttribute('rotWithShape', '0');
// a:srgbClr
$objWriter->startElement('a:srgbClr');
$objWriter->writeAttribute('val', $pDrawing->getShadow()->getColor()->getRGB());
// a:alpha
$objWriter->startElement('a:alpha');
$objWriter->writeAttribute('val', $pDrawing->getShadow()->getAlpha() * 1000);
$objWriter->endElement();
$objWriter->endElement();
$objWriter->endElement();
$objWriter->endElement();
}
/*
// a:scene3d
$objWriter->startElement('a:scene3d');
// a:camera
$objWriter->startElement('a:camera');
$objWriter->writeAttribute('prst', 'orthographicFront');
$objWriter->endElement();
// a:lightRig
$objWriter->startElement('a:lightRig');
$objWriter->writeAttribute('rig', 'twoPt');
$objWriter->writeAttribute('dir', 't');
// a:rot
$objWriter->startElement('a:rot');
$objWriter->writeAttribute('lat', '0');
$objWriter->writeAttribute('lon', '0');
$objWriter->writeAttribute('rev', '0');
$objWriter->endElement();
$objWriter->endElement();
$objWriter->endElement();
*/
/*
// a:sp3d
$objWriter->startElement('a:sp3d');
// a:bevelT
$objWriter->startElement('a:bevelT');
$objWriter->writeAttribute('w', '25400');
$objWriter->writeAttribute('h', '19050');
$objWriter->endElement();
// a:contourClr
$objWriter->startElement('a:contourClr');
// a:srgbClr
$objWriter->startElement('a:srgbClr');
$objWriter->writeAttribute('val', 'FFFFFF');
$objWriter->endElement();
$objWriter->endElement();
$objWriter->endElement();
*/
$objWriter->endElement();
$objWriter->endElement();
// xdr:clientData
$objWriter->writeElement('xdr:clientData', null);
$objWriter->endElement(); $objWriter->endElement();
} else { } else {
@ -399,8 +398,8 @@ class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_Writer
// XML header // XML header
$objWriter->startDocument('1.0', 'UTF-8', 'yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// Header/footer images // Header/footer images
$images = $pWorksheet->getHeaderFooter()->getImages(); $images = $pWorksheet->getHeaderFooter()->getImages();
// xml // xml
$objWriter->startElement('xml'); $objWriter->startElement('xml');
@ -408,117 +407,117 @@ class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_Writer
$objWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office'); $objWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office');
$objWriter->writeAttribute('xmlns:x', 'urn:schemas-microsoft-com:office:excel'); $objWriter->writeAttribute('xmlns:x', 'urn:schemas-microsoft-com:office:excel');
// o:shapelayout // o:shapelayout
$objWriter->startElement('o:shapelayout'); $objWriter->startElement('o:shapelayout');
$objWriter->writeAttribute('v:ext', 'edit'); $objWriter->writeAttribute('v:ext', 'edit');
// o:idmap // o:idmap
$objWriter->startElement('o:idmap'); $objWriter->startElement('o:idmap');
$objWriter->writeAttribute('v:ext', 'edit'); $objWriter->writeAttribute('v:ext', 'edit');
$objWriter->writeAttribute('data', '1'); $objWriter->writeAttribute('data', '1');
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
// v:shapetype // v:shapetype
$objWriter->startElement('v:shapetype'); $objWriter->startElement('v:shapetype');
$objWriter->writeAttribute('id', '_x0000_t75'); $objWriter->writeAttribute('id', '_x0000_t75');
$objWriter->writeAttribute('coordsize', '21600,21600'); $objWriter->writeAttribute('coordsize', '21600,21600');
$objWriter->writeAttribute('o:spt', '75'); $objWriter->writeAttribute('o:spt', '75');
$objWriter->writeAttribute('o:preferrelative', 't'); $objWriter->writeAttribute('o:preferrelative', 't');
$objWriter->writeAttribute('path', 'm@4@5l@4@11@9@11@9@5xe'); $objWriter->writeAttribute('path', 'm@4@5l@4@11@9@11@9@5xe');
$objWriter->writeAttribute('filled', 'f'); $objWriter->writeAttribute('filled', 'f');
$objWriter->writeAttribute('stroked', 'f'); $objWriter->writeAttribute('stroked', 'f');
// v:stroke // v:stroke
$objWriter->startElement('v:stroke'); $objWriter->startElement('v:stroke');
$objWriter->writeAttribute('joinstyle', 'miter'); $objWriter->writeAttribute('joinstyle', 'miter');
$objWriter->endElement(); $objWriter->endElement();
// v:formulas // v:formulas
$objWriter->startElement('v:formulas'); $objWriter->startElement('v:formulas');
// v:f // v:f
$objWriter->startElement('v:f'); $objWriter->startElement('v:f');
$objWriter->writeAttribute('eqn', 'if lineDrawn pixelLineWidth 0'); $objWriter->writeAttribute('eqn', 'if lineDrawn pixelLineWidth 0');
$objWriter->endElement(); $objWriter->endElement();
// v:f // v:f
$objWriter->startElement('v:f'); $objWriter->startElement('v:f');
$objWriter->writeAttribute('eqn', 'sum @0 1 0'); $objWriter->writeAttribute('eqn', 'sum @0 1 0');
$objWriter->endElement(); $objWriter->endElement();
// v:f // v:f
$objWriter->startElement('v:f'); $objWriter->startElement('v:f');
$objWriter->writeAttribute('eqn', 'sum 0 0 @1'); $objWriter->writeAttribute('eqn', 'sum 0 0 @1');
$objWriter->endElement(); $objWriter->endElement();
// v:f // v:f
$objWriter->startElement('v:f'); $objWriter->startElement('v:f');
$objWriter->writeAttribute('eqn', 'prod @2 1 2'); $objWriter->writeAttribute('eqn', 'prod @2 1 2');
$objWriter->endElement(); $objWriter->endElement();
// v:f // v:f
$objWriter->startElement('v:f'); $objWriter->startElement('v:f');
$objWriter->writeAttribute('eqn', 'prod @3 21600 pixelWidth'); $objWriter->writeAttribute('eqn', 'prod @3 21600 pixelWidth');
$objWriter->endElement(); $objWriter->endElement();
// v:f // v:f
$objWriter->startElement('v:f'); $objWriter->startElement('v:f');
$objWriter->writeAttribute('eqn', 'prod @3 21600 pixelHeight'); $objWriter->writeAttribute('eqn', 'prod @3 21600 pixelHeight');
$objWriter->endElement(); $objWriter->endElement();
// v:f // v:f
$objWriter->startElement('v:f'); $objWriter->startElement('v:f');
$objWriter->writeAttribute('eqn', 'sum @0 0 1'); $objWriter->writeAttribute('eqn', 'sum @0 0 1');
$objWriter->endElement(); $objWriter->endElement();
// v:f // v:f
$objWriter->startElement('v:f'); $objWriter->startElement('v:f');
$objWriter->writeAttribute('eqn', 'prod @6 1 2'); $objWriter->writeAttribute('eqn', 'prod @6 1 2');
$objWriter->endElement(); $objWriter->endElement();
// v:f // v:f
$objWriter->startElement('v:f'); $objWriter->startElement('v:f');
$objWriter->writeAttribute('eqn', 'prod @7 21600 pixelWidth'); $objWriter->writeAttribute('eqn', 'prod @7 21600 pixelWidth');
$objWriter->endElement(); $objWriter->endElement();
// v:f // v:f
$objWriter->startElement('v:f'); $objWriter->startElement('v:f');
$objWriter->writeAttribute('eqn', 'sum @8 21600 0'); $objWriter->writeAttribute('eqn', 'sum @8 21600 0');
$objWriter->endElement(); $objWriter->endElement();
// v:f // v:f
$objWriter->startElement('v:f'); $objWriter->startElement('v:f');
$objWriter->writeAttribute('eqn', 'prod @7 21600 pixelHeight'); $objWriter->writeAttribute('eqn', 'prod @7 21600 pixelHeight');
$objWriter->endElement(); $objWriter->endElement();
// v:f // v:f
$objWriter->startElement('v:f'); $objWriter->startElement('v:f');
$objWriter->writeAttribute('eqn', 'sum @10 21600 0'); $objWriter->writeAttribute('eqn', 'sum @10 21600 0');
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
// v:path // v:path
$objWriter->startElement('v:path'); $objWriter->startElement('v:path');
$objWriter->writeAttribute('o:extrusionok', 'f'); $objWriter->writeAttribute('o:extrusionok', 'f');
$objWriter->writeAttribute('gradientshapeok', 't'); $objWriter->writeAttribute('gradientshapeok', 't');
$objWriter->writeAttribute('o:connecttype', 'rect'); $objWriter->writeAttribute('o:connecttype', 'rect');
$objWriter->endElement(); $objWriter->endElement();
// o:lock // o:lock
$objWriter->startElement('o:lock'); $objWriter->startElement('o:lock');
$objWriter->writeAttribute('v:ext', 'edit'); $objWriter->writeAttribute('v:ext', 'edit');
$objWriter->writeAttribute('aspectratio', 't'); $objWriter->writeAttribute('aspectratio', 't');
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
// Loop through images // Loop through images
foreach ($images as $key => $value) { foreach ($images as $key => $value) {
$this->_writeVMLHeaderFooterImage($objWriter, $key, $value); $this->_writeVMLHeaderFooterImage($objWriter, $key, $value);
} }
$objWriter->endElement(); $objWriter->endElement();
@ -548,22 +547,22 @@ class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_Writer
// v:shape // v:shape
$objWriter->startElement('v:shape'); $objWriter->startElement('v:shape');
$objWriter->writeAttribute('id', $pReference); $objWriter->writeAttribute('id', $pReference);
$objWriter->writeAttribute('o:spid', '_x0000_s' . $id); $objWriter->writeAttribute('o:spid', '_x0000_s' . $id);
$objWriter->writeAttribute('type', '#_x0000_t75'); $objWriter->writeAttribute('type', '#_x0000_t75');
$objWriter->writeAttribute('style', "position:absolute;margin-left:{$marginLeft}px;margin-top:{$marginTop}px;width:{$width}px;height:{$height}px;z-index:1"); $objWriter->writeAttribute('style', "position:absolute;margin-left:{$marginLeft}px;margin-top:{$marginTop}px;width:{$width}px;height:{$height}px;z-index:1");
// v:imagedata // v:imagedata
$objWriter->startElement('v:imagedata'); $objWriter->startElement('v:imagedata');
$objWriter->writeAttribute('o:relid', 'rId' . $pReference); $objWriter->writeAttribute('o:relid', 'rId' . $pReference);
$objWriter->writeAttribute('o:title', $pImage->getName()); $objWriter->writeAttribute('o:title', $pImage->getName());
$objWriter->endElement(); $objWriter->endElement();
// o:lock // o:lock
$objWriter->startElement('o:lock'); $objWriter->startElement('o:lock');
$objWriter->writeAttribute('v:ext', 'edit'); $objWriter->writeAttribute('v:ext', 'edit');
$objWriter->writeAttribute('rotation', 't'); $objWriter->writeAttribute('rotation', 't');
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
} }

View File

@ -259,10 +259,10 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
// Underline // Underline
$underlineType = $element->getFont()->getUnderline(); $underlineType = $element->getFont()->getUnderline();
switch ($underlineType) { switch ($underlineType) {
case 'single' : case 'single':
$underlineType = 'sng'; $underlineType = 'sng';
break; break;
case 'double' : case 'double':
$underlineType = 'dbl'; $underlineType = 'dbl';
break; break;
} }
@ -304,7 +304,8 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
* @param array $stringTable Stringtable * @param array $stringTable Stringtable
* @return array * @return array
*/ */
public function flipStringTable($stringTable = array()) { public function flipStringTable($stringTable = array())
{
// Return value // Return value
$returnValue = array(); $returnValue = array();

View File

@ -210,102 +210,103 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
// sheetViews // sheetViews
$objWriter->startElement('sheetViews'); $objWriter->startElement('sheetViews');
// Sheet selected? // Sheet selected?
$sheetSelected = false; $sheetSelected = false;
if ($this->getParentWriter()->getPHPExcel()->getIndex($pSheet) == $this->getParentWriter()->getPHPExcel()->getActiveSheetIndex()) { if ($this->getParentWriter()->getPHPExcel()->getIndex($pSheet) == $this->getParentWriter()->getPHPExcel()->getActiveSheetIndex()) {
$sheetSelected = true; $sheetSelected = true;
}
// sheetView
$objWriter->startElement('sheetView');
$objWriter->writeAttribute('tabSelected', $sheetSelected ? '1' : '0');
$objWriter->writeAttribute('workbookViewId', '0');
// Zoom scales
if ($pSheet->getSheetView()->getZoomScale() != 100) {
$objWriter->writeAttribute('zoomScale', $pSheet->getSheetView()->getZoomScale());
}
if ($pSheet->getSheetView()->getZoomScaleNormal() != 100) {
$objWriter->writeAttribute('zoomScaleNormal', $pSheet->getSheetView()->getZoomScaleNormal());
}
// View Layout Type
if ($pSheet->getSheetView()->getView() !== PHPExcel_Worksheet_SheetView::SHEETVIEW_NORMAL) {
$objWriter->writeAttribute('view', $pSheet->getSheetView()->getView());
}
// Gridlines
if ($pSheet->getShowGridlines()) {
$objWriter->writeAttribute('showGridLines', 'true');
} else {
$objWriter->writeAttribute('showGridLines', 'false');
}
// Row and column headers
if ($pSheet->getShowRowColHeaders()) {
$objWriter->writeAttribute('showRowColHeaders', '1');
} else {
$objWriter->writeAttribute('showRowColHeaders', '0');
}
// Right-to-left
if ($pSheet->getRightToLeft()) {
$objWriter->writeAttribute('rightToLeft', 'true');
}
$activeCell = $pSheet->getActiveCell();
// Pane
$pane = '';
$topLeftCell = $pSheet->getFreezePane();
if (($topLeftCell != '') && ($topLeftCell != 'A1')) {
$activeCell = $topLeftCell;
// Calculate freeze coordinates
$xSplit = $ySplit = 0;
list($xSplit, $ySplit) = PHPExcel_Cell::coordinateFromString($topLeftCell);
$xSplit = PHPExcel_Cell::columnIndexFromString($xSplit);
// pane
$pane = 'topRight';
$objWriter->startElement('pane');
if ($xSplit > 1) {
$objWriter->writeAttribute('xSplit', $xSplit - 1);
} }
if ($ySplit > 1) {
// sheetView $objWriter->writeAttribute('ySplit', $ySplit - 1);
$objWriter->startElement('sheetView'); $pane = ($xSplit > 1) ? 'bottomRight' : 'bottomLeft';
$objWriter->writeAttribute('tabSelected', $sheetSelected ? '1' : '0'); }
$objWriter->writeAttribute('workbookViewId', '0'); $objWriter->writeAttribute('topLeftCell', $topLeftCell);
$objWriter->writeAttribute('activePane', $pane);
// Zoom scales $objWriter->writeAttribute('state', 'frozen');
if ($pSheet->getSheetView()->getZoomScale() != 100) {
$objWriter->writeAttribute('zoomScale', $pSheet->getSheetView()->getZoomScale());
}
if ($pSheet->getSheetView()->getZoomScaleNormal() != 100) {
$objWriter->writeAttribute('zoomScaleNormal', $pSheet->getSheetView()->getZoomScaleNormal());
}
// View Layout Type
if ($pSheet->getSheetView()->getView() !== PHPExcel_Worksheet_SheetView::SHEETVIEW_NORMAL) {
$objWriter->writeAttribute('view', $pSheet->getSheetView()->getView());
}
// Gridlines
if ($pSheet->getShowGridlines()) {
$objWriter->writeAttribute('showGridLines', 'true');
} else {
$objWriter->writeAttribute('showGridLines', 'false');
}
// Row and column headers
if ($pSheet->getShowRowColHeaders()) {
$objWriter->writeAttribute('showRowColHeaders', '1');
} else {
$objWriter->writeAttribute('showRowColHeaders', '0');
}
// Right-to-left
if ($pSheet->getRightToLeft()) {
$objWriter->writeAttribute('rightToLeft', 'true');
}
$activeCell = $pSheet->getActiveCell();
// Pane
$pane = '';
$topLeftCell = $pSheet->getFreezePane();
if (($topLeftCell != '') && ($topLeftCell != 'A1')) {
$activeCell = $topLeftCell;
// Calculate freeze coordinates
$xSplit = $ySplit = 0;
list($xSplit, $ySplit) = PHPExcel_Cell::coordinateFromString($topLeftCell);
$xSplit = PHPExcel_Cell::columnIndexFromString($xSplit);
// pane
$pane = 'topRight';
$objWriter->startElement('pane');
if ($xSplit > 1)
$objWriter->writeAttribute('xSplit', $xSplit - 1);
if ($ySplit > 1) {
$objWriter->writeAttribute('ySplit', $ySplit - 1);
$pane = ($xSplit > 1) ? 'bottomRight' : 'bottomLeft';
}
$objWriter->writeAttribute('topLeftCell', $topLeftCell);
$objWriter->writeAttribute('activePane', $pane);
$objWriter->writeAttribute('state', 'frozen');
$objWriter->endElement();
if (($xSplit > 1) && ($ySplit > 1)) {
// Write additional selections if more than two panes (ie both an X and a Y split)
$objWriter->startElement('selection');
$objWriter->writeAttribute('pane', 'topRight');
$objWriter->endElement();
$objWriter->startElement('selection');
$objWriter->writeAttribute('pane', 'bottomLeft');
$objWriter->endElement();
}
}
// Selection
// if ($pane != '') {
// Only need to write selection element if we have a split pane
// We cheat a little by over-riding the active cell selection, setting it to the split cell
$objWriter->startElement('selection');
if ($pane != '') {
$objWriter->writeAttribute('pane', $pane);
}
$objWriter->writeAttribute('activeCell', $activeCell);
$objWriter->writeAttribute('sqref', $activeCell);
$objWriter->endElement();
// }
$objWriter->endElement(); $objWriter->endElement();
if (($xSplit > 1) && ($ySplit > 1)) {
// Write additional selections if more than two panes (ie both an X and a Y split)
$objWriter->startElement('selection');
$objWriter->writeAttribute('pane', 'topRight');
$objWriter->endElement();
$objWriter->startElement('selection');
$objWriter->writeAttribute('pane', 'bottomLeft');
$objWriter->endElement();
}
}
// Selection
// if ($pane != '') {
// Only need to write selection element if we have a split pane
// We cheat a little by over-riding the active cell selection, setting it to the split cell
$objWriter->startElement('selection');
if ($pane != '') {
$objWriter->writeAttribute('pane', $pane);
}
$objWriter->writeAttribute('activeCell', $activeCell);
$objWriter->writeAttribute('sqref', $activeCell);
$objWriter->endElement();
// }
$objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
} }
@ -371,7 +372,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
private function _writeCols(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null) private function _writeCols(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null)
{ {
// cols // cols
if (count($pSheet->getColumnDimensions()) > 0) { if (count($pSheet->getColumnDimensions()) > 0) {
$objWriter->startElement('cols'); $objWriter->startElement('cols');
$pSheet->calculateColumnWidths(); $pSheet->calculateColumnWidths();
@ -485,50 +486,48 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
$objWriter->startElement('conditionalFormatting'); $objWriter->startElement('conditionalFormatting');
$objWriter->writeAttribute('sqref', $cellCoordinate); $objWriter->writeAttribute('sqref', $cellCoordinate);
// cfRule // cfRule
$objWriter->startElement('cfRule'); $objWriter->startElement('cfRule');
$objWriter->writeAttribute('type', $conditional->getConditionType()); $objWriter->writeAttribute('type', $conditional->getConditionType());
$objWriter->writeAttribute('dxfId', $this->getParentWriter()->getStylesConditionalHashTable()->getIndexForHashCode($conditional->getHashCode())); $objWriter->writeAttribute('dxfId', $this->getParentWriter()->getStylesConditionalHashTable()->getIndexForHashCode($conditional->getHashCode()));
$objWriter->writeAttribute('priority', $id++); $objWriter->writeAttribute('priority', $id++);
if (($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CELLIS if (($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CELLIS || $conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT)
|| && $conditional->getOperatorType() != PHPExcel_Style_Conditional::OPERATOR_NONE) {
$conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT) $objWriter->writeAttribute('operator', $conditional->getOperatorType());
&& $conditional->getOperatorType() != PHPExcel_Style_Conditional::OPERATOR_NONE) { }
$objWriter->writeAttribute('operator', $conditional->getOperatorType());
if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT
&& !is_null($conditional->getText())) {
$objWriter->writeAttribute('text', $conditional->getText());
}
if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT
&& $conditional->getOperatorType() == PHPExcel_Style_Conditional::OPERATOR_CONTAINSTEXT
&& !is_null($conditional->getText())) {
$objWriter->writeElement('formula', 'NOT(ISERROR(SEARCH("' . $conditional->getText() . '",' . $cellCoordinate . ')))');
} else if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT
&& $conditional->getOperatorType() == PHPExcel_Style_Conditional::OPERATOR_BEGINSWITH
&& !is_null($conditional->getText())) {
$objWriter->writeElement('formula', 'LEFT(' . $cellCoordinate . ',' . strlen($conditional->getText()) . ')="' . $conditional->getText() . '"');
} else if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT
&& $conditional->getOperatorType() == PHPExcel_Style_Conditional::OPERATOR_ENDSWITH
&& !is_null($conditional->getText())) {
$objWriter->writeElement('formula', 'RIGHT(' . $cellCoordinate . ',' . strlen($conditional->getText()) . ')="' . $conditional->getText() . '"');
} else if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT
&& $conditional->getOperatorType() == PHPExcel_Style_Conditional::OPERATOR_NOTCONTAINS
&& !is_null($conditional->getText())) {
$objWriter->writeElement('formula', 'ISERROR(SEARCH("' . $conditional->getText() . '",' . $cellCoordinate . '))');
} else if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CELLIS
|| $conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT
|| $conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_EXPRESSION) {
foreach ($conditional->getConditions() as $formula) {
// Formula
$objWriter->writeElement('formula', $formula);
} }
}
if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT $objWriter->endElement();
&& !is_null($conditional->getText())) {
$objWriter->writeAttribute('text', $conditional->getText());
}
if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT
&& $conditional->getOperatorType() == PHPExcel_Style_Conditional::OPERATOR_CONTAINSTEXT
&& !is_null($conditional->getText())) {
$objWriter->writeElement('formula', 'NOT(ISERROR(SEARCH("' . $conditional->getText() . '",' . $cellCoordinate . ')))');
} else if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT
&& $conditional->getOperatorType() == PHPExcel_Style_Conditional::OPERATOR_BEGINSWITH
&& !is_null($conditional->getText())) {
$objWriter->writeElement('formula', 'LEFT(' . $cellCoordinate . ',' . strlen($conditional->getText()) . ')="' . $conditional->getText() . '"');
} else if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT
&& $conditional->getOperatorType() == PHPExcel_Style_Conditional::OPERATOR_ENDSWITH
&& !is_null($conditional->getText())) {
$objWriter->writeElement('formula', 'RIGHT(' . $cellCoordinate . ',' . strlen($conditional->getText()) . ')="' . $conditional->getText() . '"');
} else if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT
&& $conditional->getOperatorType() == PHPExcel_Style_Conditional::OPERATOR_NOTCONTAINS
&& !is_null($conditional->getText())) {
$objWriter->writeElement('formula', 'ISERROR(SEARCH("' . $conditional->getText() . '",' . $cellCoordinate . '))');
} else if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CELLIS
|| $conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT
|| $conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_EXPRESSION) {
foreach ($conditional->getConditions() as $formula) {
// Formula
$objWriter->writeElement('formula', $formula);
}
}
$objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
} }
@ -656,17 +655,17 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
// protectedRanges // protectedRanges
$objWriter->startElement('protectedRanges'); $objWriter->startElement('protectedRanges');
// Loop protectedRanges // Loop protectedRanges
foreach ($pSheet->getProtectedCells() as $protectedCell => $passwordHash) { foreach ($pSheet->getProtectedCells() as $protectedCell => $passwordHash) {
// protectedRange // protectedRange
$objWriter->startElement('protectedRange'); $objWriter->startElement('protectedRange');
$objWriter->writeAttribute('name', 'p' . md5($protectedCell)); $objWriter->writeAttribute('name', 'p' . md5($protectedCell));
$objWriter->writeAttribute('sqref', $protectedCell); $objWriter->writeAttribute('sqref', $protectedCell);
if (!empty($passwordHash)) { if (!empty($passwordHash)) {
$objWriter->writeAttribute('password', $passwordHash); $objWriter->writeAttribute('password', $passwordHash);
}
$objWriter->endElement();
} }
$objWriter->endElement();
}
$objWriter->endElement(); $objWriter->endElement();
} }
@ -685,13 +684,13 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
// mergeCells // mergeCells
$objWriter->startElement('mergeCells'); $objWriter->startElement('mergeCells');
// Loop mergeCells // Loop mergeCells
foreach ($pSheet->getMergeCells() as $mergeCell) { foreach ($pSheet->getMergeCells() as $mergeCell) {
// mergeCell // mergeCell
$objWriter->startElement('mergeCell'); $objWriter->startElement('mergeCell');
$objWriter->writeAttribute('ref', $mergeCell); $objWriter->writeAttribute('ref', $mergeCell);
$objWriter->endElement(); $objWriter->endElement();
} }
$objWriter->endElement(); $objWriter->endElement();
} }
@ -766,71 +765,70 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
} }
$range = implode(':', $range); $range = implode(':', $range);
$objWriter->writeAttribute('ref', str_replace('$','', $range)); $objWriter->writeAttribute('ref', str_replace('$', '', $range));
$columns = $pSheet->getAutoFilter()->getColumns(); $columns = $pSheet->getAutoFilter()->getColumns();
if (count($columns > 0)) { if (count($columns > 0)) {
foreach ($columns as $columnID => $column) { foreach ($columns as $columnID => $column) {
$rules = $column->getRules(); $rules = $column->getRules();
if (count($rules > 0)) { if (count($rules) > 0) {
$objWriter->startElement('filterColumn'); $objWriter->startElement('filterColumn');
$objWriter->writeAttribute('colId', $pSheet->getAutoFilter()->getColumnOffset($columnID)); $objWriter->writeAttribute('colId', $pSheet->getAutoFilter()->getColumnOffset($columnID));
$objWriter->startElement($column->getFilterType()); $objWriter->startElement($column->getFilterType());
if ($column->getJoin() == PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_AND) { if ($column->getJoin() == PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_AND) {
$objWriter->writeAttribute('and', 1); $objWriter->writeAttribute('and', 1);
}
foreach ($rules as $rule) {
if (($column->getFilterType() === PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_FILTER) &&
($rule->getOperator() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_EQUAL) &&
($rule->getValue() === '')) {
// Filter rule for Blanks
$objWriter->writeAttribute('blank', 1);
} elseif ($rule->getRuleType() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMICFILTER) {
// Dynamic Filter Rule
$objWriter->writeAttribute('type', $rule->getGrouping());
$val = $column->getAttribute('val');
if ($val !== null) {
$objWriter->writeAttribute('val', $val);
} }
$maxVal = $column->getAttribute('maxVal');
if ($maxVal !== null) {
$objWriter->writeAttribute('maxVal', $maxVal);
}
} elseif ($rule->getRuleType() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_TOPTENFILTER) {
// Top 10 Filter Rule
$objWriter->writeAttribute('val', $rule->getValue());
$objWriter->writeAttribute('percent', (($rule->getOperator() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT) ? '1' : '0'));
$objWriter->writeAttribute('top', (($rule->getGrouping() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP) ? '1': '0'));
} else {
// Filter, DateGroupItem or CustomFilter
$objWriter->startElement($rule->getRuleType());
foreach ($rules as $rule) { if ($rule->getOperator() !== PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_EQUAL) {
if (($column->getFilterType() === PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_FILTER) && $objWriter->writeAttribute('operator', $rule->getOperator());
($rule->getOperator() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_EQUAL) && }
($rule->getValue() === '')) { if ($rule->getRuleType() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP) {
// Filter rule for Blanks // Date Group filters
$objWriter->writeAttribute('blank', 1); foreach ($rule->getValue() as $key => $value) {
} elseif ($rule->getRuleType() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMICFILTER) { if ($value > '') $objWriter->writeAttribute($key, $value);
// Dynamic Filter Rule
$objWriter->writeAttribute('type', $rule->getGrouping());
$val = $column->getAttribute('val');
if ($val !== null) {
$objWriter->writeAttribute('val', $val);
}
$maxVal = $column->getAttribute('maxVal');
if ($maxVal !== null) {
$objWriter->writeAttribute('maxVal', $maxVal);
}
} elseif ($rule->getRuleType() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_TOPTENFILTER) {
// Top 10 Filter Rule
$objWriter->writeAttribute('val', $rule->getValue());
$objWriter->writeAttribute('percent', (($rule->getOperator() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT) ? '1' : '0'));
$objWriter->writeAttribute('top', (($rule->getGrouping() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP) ? '1': '0'));
} else {
// Filter, DateGroupItem or CustomFilter
$objWriter->startElement($rule->getRuleType());
if ($rule->getOperator() !== PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_EQUAL) {
$objWriter->writeAttribute('operator', $rule->getOperator());
}
if ($rule->getRuleType() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP) {
// Date Group filters
foreach ($rule->getValue() as $key => $value) {
if ($value > '') $objWriter->writeAttribute($key, $value);
}
$objWriter->writeAttribute('dateTimeGrouping', $rule->getGrouping());
} else {
$objWriter->writeAttribute('val', $rule->getValue());
}
$objWriter->endElement();
} }
$objWriter->writeAttribute('dateTimeGrouping', $rule->getGrouping());
} else {
$objWriter->writeAttribute('val', $rule->getValue());
} }
$objWriter->endElement(); $objWriter->endElement();
}
}
$objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
} }
} }
} }
$objWriter->endElement(); $objWriter->endElement();
} }
} }
@ -921,14 +919,14 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
$objWriter->writeAttribute('count', count($aRowBreaks)); $objWriter->writeAttribute('count', count($aRowBreaks));
$objWriter->writeAttribute('manualBreakCount', count($aRowBreaks)); $objWriter->writeAttribute('manualBreakCount', count($aRowBreaks));
foreach ($aRowBreaks as $cell) { foreach ($aRowBreaks as $cell) {
$coords = PHPExcel_Cell::coordinateFromString($cell); $coords = PHPExcel_Cell::coordinateFromString($cell);
$objWriter->startElement('brk'); $objWriter->startElement('brk');
$objWriter->writeAttribute('id', $coords[1]); $objWriter->writeAttribute('id', $coords[1]);
$objWriter->writeAttribute('man', '1'); $objWriter->writeAttribute('man', '1');
$objWriter->endElement(); $objWriter->endElement();
} }
$objWriter->endElement(); $objWriter->endElement();
} }
@ -939,14 +937,14 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
$objWriter->writeAttribute('count', count($aColumnBreaks)); $objWriter->writeAttribute('count', count($aColumnBreaks));
$objWriter->writeAttribute('manualBreakCount', count($aColumnBreaks)); $objWriter->writeAttribute('manualBreakCount', count($aColumnBreaks));
foreach ($aColumnBreaks as $cell) { foreach ($aColumnBreaks as $cell) {
$coords = PHPExcel_Cell::coordinateFromString($cell); $coords = PHPExcel_Cell::coordinateFromString($cell);
$objWriter->startElement('brk'); $objWriter->startElement('brk');
$objWriter->writeAttribute('id', PHPExcel_Cell::columnIndexFromString($coords[0]) - 1); $objWriter->writeAttribute('id', PHPExcel_Cell::columnIndexFromString($coords[0]) - 1);
$objWriter->writeAttribute('man', '1'); $objWriter->writeAttribute('man', '1');
$objWriter->endElement(); $objWriter->endElement();
} }
$objWriter->endElement(); $objWriter->endElement();
} }

View File

@ -1135,8 +1135,7 @@ class PHPExcel_Writer_Excel5_Parser
} elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u", $token) and !preg_match("/[0-9]/", $this->_lookahead) and ($this->_lookahead != ':') and ($this->_lookahead != '.')) { } elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u", $token) and !preg_match("/[0-9]/", $this->_lookahead) and ($this->_lookahead != ':') and ($this->_lookahead != '.')) {
// If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1) // If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1)
return $token; return $token;
} } elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u", $token) and !preg_match("/[0-9]/", $this->_lookahead) and ($this->_lookahead != ':') and ($this->_lookahead != '.')) {
elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u", $token) and !preg_match("/[0-9]/", $this->_lookahead) and ($this->_lookahead != ':') and ($this->_lookahead != '.')) {
// If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1) // If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1)
return $token; return $token;
} elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/', $token) && !preg_match("/[0-9]/", $this->_lookahead)) { } elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/', $token) && !preg_match("/[0-9]/", $this->_lookahead)) {
@ -1253,7 +1252,7 @@ class PHPExcel_Writer_Excel5_Parser
$this->_advance(); $this->_advance();
return $result; return $result;
// If it's an error code // If it's an error code
} elseif (preg_match("/^#[A-Z0\/]{3,5}[!?]{1}$/", $this->_current_token) or $this->_current_token == '#N/A'){ } elseif (preg_match("/^#[A-Z0\/]{3,5}[!?]{1}$/", $this->_current_token) or $this->_current_token == '#N/A') {
$result = $this->_createTree($this->_current_token, 'ptgErr', ''); $result = $this->_createTree($this->_current_token, 'ptgErr', '');
$this->_advance(); $this->_advance();
return $result; return $result;
@ -1361,45 +1360,39 @@ class PHPExcel_Writer_Excel5_Parser
$result = $this->_createTree($this->_current_token, '', ''); $result = $this->_createTree($this->_current_token, '', '');
$this->_advance(); $this->_advance();
return $result; return $result;
} } elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u", $this->_current_token)) {
// If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1) // If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1)
elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u", $this->_current_token)) {
$result = $this->_createTree($this->_current_token, '', ''); $result = $this->_createTree($this->_current_token, '', '');
$this->_advance(); $this->_advance();
return $result; return $result;
} } elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u", $this->_current_token)) {
// If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1) // If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1)
elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u", $this->_current_token)) {
$result = $this->_createTree($this->_current_token, '', ''); $result = $this->_createTree($this->_current_token, '', '');
$this->_advance(); $this->_advance();
return $result; return $result;
} } elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/', $this->_current_token) or
// if it's a range A1:B2 or $A$1:$B$2
elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/', $this->_current_token) or
preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/', $this->_current_token)) { preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/', $this->_current_token)) {
// if it's a range A1:B2 or $A$1:$B$2
// must be an error? // must be an error?
$result = $this->_createTree($this->_current_token, '', ''); $result = $this->_createTree($this->_current_token, '', '');
$this->_advance(); $this->_advance();
return $result; return $result;
} } elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u", $this->_current_token)) {
// If it's an external range (Sheet1!A1:B2 or Sheet1:Sheet2!A1:B2 or Sheet1!$A$1:$B$2 or Sheet1:Sheet2!$A$1:$B$2) // If it's an external range (Sheet1!A1:B2 or Sheet1:Sheet2!A1:B2 or Sheet1!$A$1:$B$2 or Sheet1:Sheet2!$A$1:$B$2)
elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u", $this->_current_token)) {
// must be an error? // must be an error?
//$result = $this->_current_token; //$result = $this->_current_token;
$result = $this->_createTree($this->_current_token, '', ''); $result = $this->_createTree($this->_current_token, '', '');
$this->_advance(); $this->_advance();
return $result; return $result;
} } elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u", $this->_current_token)) {
// If it's an external range ('Sheet1'!A1:B2 or 'Sheet1'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1'!$A$1:$B$2) // If it's an external range ('Sheet1'!A1:B2 or 'Sheet1'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1'!$A$1:$B$2)
elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u", $this->_current_token)) {
// must be an error? // must be an error?
//$result = $this->_current_token; //$result = $this->_current_token;
$result = $this->_createTree($this->_current_token, '', ''); $result = $this->_createTree($this->_current_token, '', '');
$this->_advance(); $this->_advance();
return $result; return $result;
} } elseif (is_numeric($this->_current_token)) {
// If it's a number or a percent // If it's a number or a percent
elseif (is_numeric($this->_current_token)) {
if ($this->_lookahead == '%') { if ($this->_lookahead == '%') {
$result = $this->_createTree('ptgPercent', $this->_current_token, ''); $result = $this->_createTree('ptgPercent', $this->_current_token, '');
$this->_advance(); // Skip the percentage operator once we've pre-built that tree $this->_advance(); // Skip the percentage operator once we've pre-built that tree
@ -1408,15 +1401,12 @@ class PHPExcel_Writer_Excel5_Parser
} }
$this->_advance(); $this->_advance();
return $result; return $result;
} } elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i", $this->_current_token)) {
// if it's a function call // if it's a function call
elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i", $this->_current_token)) {
$result = $this->_func(); $result = $this->_func();
return $result; return $result;
} }
throw new PHPExcel_Writer_Exception("Syntax error: ".$this->_current_token. throw new PHPExcel_Writer_Exception("Syntax error: ".$this->_current_token.", lookahead: ".$this->_lookahead.", current char: ".$this->_current_char);
", lookahead: ".$this->_lookahead.
", current char: ".$this->_current_char);
} }
/** /**