From 4f8c9bfc966c0b77a8353f422b8f485d035edd2a Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Thu, 7 May 2015 01:14:36 +0100 Subject: [PATCH] More PSR-2 work --- Classes/PHPExcel/RichText.php | 32 +- Classes/PHPExcel/RichText/ITextElement.php | 64 ++-- Classes/PHPExcel/RichText/Run.php | 128 ++++--- Classes/PHPExcel/RichText/TextElement.php | 141 ++++---- Classes/PHPExcel/Settings.php | 212 ++++++------ Classes/PHPExcel/Worksheet/CellIterator.php | 107 +++--- Classes/PHPExcel/Worksheet/Column.php | 114 +++--- .../PHPExcel/Worksheet/ColumnCellIterator.php | 291 ++++++++-------- .../PHPExcel/Worksheet/ColumnDimension.php | 253 +++++++------- Classes/PHPExcel/Worksheet/ColumnIterator.php | 285 +++++++-------- Classes/PHPExcel/Worksheet/Row.php | 114 +++--- .../PHPExcel/Worksheet/RowCellIterator.php | 325 +++++++++--------- Classes/PHPExcel/Worksheet/RowDimension.php | 281 +++++++-------- Classes/PHPExcel/Worksheet/RowIterator.php | 259 +++++++------- Classes/PHPExcel/WorksheetIterator.php | 32 +- 15 files changed, 1298 insertions(+), 1340 deletions(-) diff --git a/Classes/PHPExcel/RichText.php b/Classes/PHPExcel/RichText.php index 30ba2c34..74a3534a 100644 --- a/Classes/PHPExcel/RichText.php +++ b/Classes/PHPExcel/RichText.php @@ -1,6 +1,7 @@ _richTextElements = array(); + $this->richTextElements = array(); // Rich-Text string attached to cell? - if ($pCell !== NULL) { + if ($pCell !== null) { // Add cell text and style if ($pCell->getValue() != "") { $objRun = new PHPExcel_RichText_Run($pCell->getValue()); @@ -76,7 +68,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable */ public function addText(PHPExcel_RichText_ITextElement $pText = null) { - $this->_richTextElements[] = $pText; + $this->richTextElements[] = $pText; return $this; } @@ -119,7 +111,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable $returnValue = ''; // Loop through all PHPExcel_RichText_ITextElement - foreach ($this->_richTextElements as $text) { + foreach ($this->richTextElements as $text) { $returnValue .= $text->getText(); } @@ -144,7 +136,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable */ public function getRichTextElements() { - return $this->_richTextElements; + return $this->richTextElements; } /** @@ -157,7 +149,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable public function setRichTextElements($pElements = null) { if (is_array($pElements)) { - $this->_richTextElements = $pElements; + $this->richTextElements = $pElements; } else { throw new PHPExcel_Exception("Invalid PHPExcel_RichText_ITextElement[] array passed."); } @@ -172,13 +164,13 @@ class PHPExcel_RichText implements PHPExcel_IComparable public function getHashCode() { $hashElements = ''; - foreach ($this->_richTextElements as $element) { + foreach ($this->richTextElements as $element) { $hashElements .= $element->getHashCode(); } return md5( - $hashElements - . __CLASS__ + $hashElements . + __CLASS__ ); } diff --git a/Classes/PHPExcel/RichText/ITextElement.php b/Classes/PHPExcel/RichText/ITextElement.php index 816cc696..5db34320 100644 --- a/Classes/PHPExcel/RichText/ITextElement.php +++ b/Classes/PHPExcel/RichText/ITextElement.php @@ -1,6 +1,7 @@ setText($pText); - $this->_font = new PHPExcel_Style_Font(); + // Initialise variables + $this->setText($pText); + $this->font = new PHPExcel_Style_Font(); } - /** - * Get font - * - * @return PHPExcel_Style_Font - */ - public function getFont() { - return $this->_font; - } - - /** - * Set font - * - * @param PHPExcel_Style_Font $pFont Font - * @throws PHPExcel_Exception - * @return PHPExcel_RichText_ITextElement - */ - public function setFont(PHPExcel_Style_Font $pFont = null) { - $this->_font = $pFont; - return $this; - } - - /** - * Get hash code - * - * @return string Hash code - */ - public function getHashCode() { - return md5( - $this->getText() - . $this->_font->getHashCode() - . __CLASS__ - ); + /** + * Get font + * + * @return PHPExcel_Style_Font + */ + public function getFont() + { + return $this->font; } - /** - * Implement PHP __clone to create a deep clone, not just a shallow copy. - */ - public function __clone() { - $vars = get_object_vars($this); - foreach ($vars as $key => $value) { - if (is_object($value)) { - $this->$key = clone $value; - } else { - $this->$key = $value; - } - } - } + /** + * Set font + * + * @param PHPExcel_Style_Font $pFont Font + * @throws PHPExcel_Exception + * @return PHPExcel_RichText_ITextElement + */ + public function setFont(PHPExcel_Style_Font $pFont = null) + { + $this->font = $pFont; + return $this; + } + + /** + * Get hash code + * + * @return string Hash code + */ + public function getHashCode() + { + return md5( + $this->getText() . + $this->_font->getHashCode() . + __CLASS__ + ); + } + + /** + * Implement PHP __clone to create a deep clone, not just a shallow copy. + */ + public function __clone() + { + $vars = get_object_vars($this); + foreach ($vars as $key => $value) { + if (is_object($value)) { + $this->$key = clone $value; + } else { + $this->$key = $value; + } + } + } } diff --git a/Classes/PHPExcel/RichText/TextElement.php b/Classes/PHPExcel/RichText/TextElement.php index 3524446a..3558db32 100644 --- a/Classes/PHPExcel/RichText/TextElement.php +++ b/Classes/PHPExcel/RichText/TextElement.php @@ -1,6 +1,7 @@ _text = $pText; + // Initialise variables + $this->text = $pText; } - /** - * Get text - * - * @return string Text - */ - public function getText() { - return $this->_text; - } - - /** - * Set text - * - * @param $pText string Text - * @return PHPExcel_RichText_ITextElement - */ - public function setText($pText = '') { - $this->_text = $pText; - return $this; - } - - /** - * Get font - * - * @return PHPExcel_Style_Font - */ - public function getFont() { - return null; - } - - /** - * Get hash code - * - * @return string Hash code - */ - public function getHashCode() { - return md5( - $this->_text - . __CLASS__ - ); + /** + * Get text + * + * @return string Text + */ + public function getText() + { + return $this->text; } - /** - * Implement PHP __clone to create a deep clone, not just a shallow copy. - */ - public function __clone() { - $vars = get_object_vars($this); - foreach ($vars as $key => $value) { - if (is_object($value)) { - $this->$key = clone $value; - } else { - $this->$key = $value; - } - } - } + /** + * Set text + * + * @param $pText string Text + * @return PHPExcel_RichText_ITextElement + */ + public function setText($pText = '') + { + $this->text = $pText; + return $this; + } + + /** + * Get font + * + * @return PHPExcel_Style_Font + */ + public function getFont() + { + return null; + } + + /** + * Get hash code + * + * @return string Hash code + */ + public function getHashCode() + { + return md5( + $this->_text . + __CLASS__ + ); + } + + /** + * Implement PHP __clone to create a deep clone, not just a shallow copy. + */ + public function __clone() + { + $vars = get_object_vars($this); + foreach ($vars as $key => $value) { + if (is_object($value)) { + $this->$key = clone $value; + } else { + $this->$key = $value; + } + } + } } diff --git a/Classes/PHPExcel/Settings.php b/Classes/PHPExcel/Settings.php index 69beb1a1..13655422 100644 --- a/Classes/PHPExcel/Settings.php +++ b/Classes/PHPExcel/Settings.php @@ -1,6 +1,16 @@ setLocale($locale); - } // function setLocale() + } /** * Set details of the external library that PHPExcel should use for rendering charts * - * @param string $libraryName Internal reference name of the library - * e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH + * @param string $libraryName Internal reference name of the library + * e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH * @param string $libraryBaseDir Directory path to the library's base folder * - * @return boolean Success or failure + * @return boolean Success or failure */ public static function setChartRenderer($libraryName, $libraryBaseDir) { - if (!self::setChartRendererName($libraryName)) - return FALSE; + if (!self::setChartRendererName($libraryName)) { + return false; + } return self::setChartRendererPath($libraryBaseDir); - } // function setChartRenderer() + } /** * Identify to PHPExcel the external library to use for rendering charts * - * @param string $libraryName Internal reference name of the library - * e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH + * @param string $libraryName Internal reference name of the library + * e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH * - * @return boolean Success or failure + * @return boolean Success or failure */ public static function setChartRendererName($libraryName) { - if (!in_array($libraryName,self::$_chartRenderers)) { - return FALSE; + if (!in_array($libraryName, self::$chartRenderers)) { + return false; } + self::$chartRendererName = $libraryName; - self::$_chartRendererName = $libraryName; - - return TRUE; - } // function setChartRendererName() + return true; + } /** * Tell PHPExcel where to find the external library to use for rendering charts * - * @param string $libraryBaseDir Directory path to the library's base folder - * @return boolean Success or failure + * @param string $libraryBaseDir Directory path to the library's base folder + * @return boolean Success or failure */ public static function setChartRendererPath($libraryBaseDir) { if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) { - return FALSE; + return false; } - self::$_chartRendererPath = $libraryBaseDir; + self::$chartRendererPath = $libraryBaseDir; - return TRUE; - } // function setChartRendererPath() + return true; + } /** * Return the Chart Rendering Library that PHPExcel is currently configured to use (e.g. jpgraph) * * @return string|NULL Internal reference name of the Chart Rendering Library that PHPExcel is - * currently configured to use - * e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH + * currently configured to use + * e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH */ public static function getChartRendererName() { - return self::$_chartRendererName; - } // function getChartRendererName() + return self::$chartRendererName; + } /** * Return the directory path to the Chart Rendering Library that PHPExcel is currently configured to use * * @return string|NULL Directory Path to the Chart Rendering Library that PHPExcel is - * currently configured to use + * currently configured to use */ public static function getChartRendererPath() { - return self::$_chartRendererPath; - } // function getChartRendererPath() + return self::$chartRendererPath; + } /** * Set details of the external library that PHPExcel should use for rendering PDF files * * @param string $libraryName Internal reference name of the library - * e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF, - * PHPExcel_Settings::PDF_RENDERER_DOMPDF + * e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF, + * PHPExcel_Settings::PDF_RENDERER_DOMPDF * or PHPExcel_Settings::PDF_RENDERER_MPDF * @param string $libraryBaseDir Directory path to the library's base folder * @@ -286,32 +282,32 @@ class PHPExcel_Settings */ public static function setPdfRenderer($libraryName, $libraryBaseDir) { - if (!self::setPdfRendererName($libraryName)) - return FALSE; + if (!self::setPdfRendererName($libraryName)) { + return false; + } return self::setPdfRendererPath($libraryBaseDir); - } // function setPdfRenderer() + } /** * Identify to PHPExcel the external library to use for rendering PDF files * * @param string $libraryName Internal reference name of the library - * e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF, - * PHPExcel_Settings::PDF_RENDERER_DOMPDF - * or PHPExcel_Settings::PDF_RENDERER_MPDF + * e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF, + * PHPExcel_Settings::PDF_RENDERER_DOMPDF + * or PHPExcel_Settings::PDF_RENDERER_MPDF * * @return boolean Success or failure */ public static function setPdfRendererName($libraryName) { - if (!in_array($libraryName,self::$_pdfRenderers)) { - return FALSE; + if (!in_array($libraryName, self::$pdfRenderers)) { + return false; } - self::$_pdfRendererName = $libraryName; - return TRUE; - } // function setPdfRendererName() + return true; + } /** @@ -323,38 +319,38 @@ class PHPExcel_Settings public static function setPdfRendererPath($libraryBaseDir) { if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) { - return FALSE; + return false; } - self::$_pdfRendererPath = $libraryBaseDir; + self::$pdfRendererPath = $libraryBaseDir; - return TRUE; - } // function setPdfRendererPath() + return true; + } /** * Return the PDF Rendering Library that PHPExcel is currently configured to use (e.g. dompdf) * * @return string|NULL Internal reference name of the PDF Rendering Library that PHPExcel is - * currently configured to use + * currently configured to use * e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF, * PHPExcel_Settings::PDF_RENDERER_DOMPDF * or PHPExcel_Settings::PDF_RENDERER_MPDF */ public static function getPdfRendererName() { - return self::$_pdfRendererName; - } // function getPdfRendererName() + return self::$pdfRendererName; + } /** * Return the directory path to the PDF Rendering Library that PHPExcel is currently configured to use * * @return string|NULL Directory Path to the PDF Rendering Library that PHPExcel is - * currently configured to use + * currently configured to use */ public static function getPdfRendererPath() { - return self::$_pdfRendererPath; - } // function getPdfRendererPath() + return self::$pdfRendererPath; + } /** * Set default options for libxml loader @@ -367,10 +363,10 @@ class PHPExcel_Settings $options = LIBXML_DTDLOAD | LIBXML_DTDATTR; } if (version_compare(PHP_VERSION, '5.2.11') >= 0) { - @libxml_disable_entity_loader($options == (LIBXML_DTDLOAD | LIBXML_DTDATTR)); + @libxml_disable_entity_loader($options == (LIBXML_DTDLOAD | LIBXML_DTDATTR)); } self::$_libXmlLoaderOptions = $options; - } // function setLibXmlLoaderOptions + } /** * Get default options for libxml loader. @@ -384,8 +380,8 @@ class PHPExcel_Settings self::setLibXmlLoaderOptions(LIBXML_DTDLOAD | LIBXML_DTDATTR); } if (version_compare(PHP_VERSION, '5.2.11') >= 0) { - @libxml_disable_entity_loader(self::$_libXmlLoaderOptions == (LIBXML_DTDLOAD | LIBXML_DTDATTR)); + @libxml_disable_entity_loader(self::$libXmlLoaderOptions == (LIBXML_DTDLOAD | LIBXML_DTDATTR)); } return self::$_libXmlLoaderOptions; - } // function getLibXmlLoaderOptions + } } diff --git a/Classes/PHPExcel/Worksheet/CellIterator.php b/Classes/PHPExcel/Worksheet/CellIterator.php index 37f6a12a..151c17f5 100644 --- a/Classes/PHPExcel/Worksheet/CellIterator.php +++ b/Classes/PHPExcel/Worksheet/CellIterator.php @@ -1,6 +1,7 @@ _subject); - } - - /** - * Get loop only existing cells - * - * @return boolean - */ - public function getIterateOnlyExistingCells() { - return $this->_onlyExistingCells; + /** + * Destructor + */ + public function __destruct() + { + unset($this->subject); } - /** - * Validate start/end values for "IterateOnlyExistingCells" mode, and adjust if necessary - * + /** + * Get loop only existing cells + * + * @return boolean + */ + public function getIterateOnlyExistingCells() + { + return $this->onlyExistingCells; + } + + /** + * Validate start/end values for "IterateOnlyExistingCells" mode, and adjust if necessary + * * @throws PHPExcel_Exception - */ + */ abstract protected function adjustForExistingOnlyRange(); - /** - * Set the iterator to loop only existing cells - * - * @param boolean $value + /** + * Set the iterator to loop only existing cells + * + * @param boolean $value * @throws PHPExcel_Exception - */ - public function setIterateOnlyExistingCells($value = true) { - $this->_onlyExistingCells = (boolean) $value; + */ + public function setIterateOnlyExistingCells($value = true) + { + $this->onlyExistingCells = (boolean) $value; $this->adjustForExistingOnlyRange(); } diff --git a/Classes/PHPExcel/Worksheet/Column.php b/Classes/PHPExcel/Worksheet/Column.php index b0ba6837..8c561fa8 100644 --- a/Classes/PHPExcel/Worksheet/Column.php +++ b/Classes/PHPExcel/Worksheet/Column.php @@ -1,6 +1,7 @@ _parent = $parent; - $this->_columnIndex = $columnIndex; - } + /** + * Create a new column + * + * @param PHPExcel_Worksheet $parent + * @param string $columnIndex + */ + public function __construct(PHPExcel_Worksheet $parent = null, $columnIndex = 'A') + { + // Set parent and column index + $this->parent = $parent; + $this->columnIndex = $columnIndex; + } - /** - * Destructor - */ - public function __destruct() { - unset($this->_parent); - } + /** + * Destructor + */ + public function __destruct() + { + unset($this->parent); + } - /** - * Get column index - * - * @return int - */ - public function getColumnIndex() { - return $this->_columnIndex; - } + /** + * Get column index + * + * @return int + */ + public function getColumnIndex() + { + return $this->columnIndex; + } - /** - * Get cell iterator - * - * @param integer $startRow The row number at which to start iterating - * @param integer $endRow Optionally, the row number at which to stop iterating - * @return PHPExcel_Worksheet_CellIterator - */ - public function getCellIterator($startRow = 1, $endRow = null) { - return new PHPExcel_Worksheet_ColumnCellIterator($this->_parent, $this->_columnIndex, $startRow, $endRow); - } + /** + * Get cell iterator + * + * @param integer $startRow The row number at which to start iterating + * @param integer $endRow Optionally, the row number at which to stop iterating + * @return PHPExcel_Worksheet_CellIterator + */ + public function getCellIterator($startRow = 1, $endRow = null) + { + return new PHPExcel_Worksheet_ColumnCellIterator($this->parent, $this->columnIndex, $startRow, $endRow); + } } diff --git a/Classes/PHPExcel/Worksheet/ColumnCellIterator.php b/Classes/PHPExcel/Worksheet/ColumnCellIterator.php index c7953ea2..7b8c2190 100644 --- a/Classes/PHPExcel/Worksheet/ColumnCellIterator.php +++ b/Classes/PHPExcel/Worksheet/ColumnCellIterator.php @@ -1,6 +1,7 @@ _subject = $subject; - $this->_columnIndex = PHPExcel_Cell::columnIndexFromString($columnIndex) - 1; - $this->resetEnd($endRow); - $this->resetStart($startRow); - } + * @param integer $startRow The row number at which to start iterating + * @param integer $endRow Optionally, the row number at which to stop iterating + */ + public function __construct(PHPExcel_Worksheet $subject = null, $columnIndex = 'A', $startRow = 1, $endRow = null) + { + // Set subject + $this->subject = $subject; + $this->columnIndex = PHPExcel_Cell::columnIndexFromString($columnIndex) - 1; + $this->resetEnd($endRow); + $this->resetStart($startRow); + } - /** - * Destructor - */ - public function __destruct() { - unset($this->_subject); - } + /** + * Destructor + */ + public function __destruct() + { + unset($this->subject); + } - /** - * (Re)Set the start row and the current row pointer - * - * @param integer $startRow The row number at which to start iterating + /** + * (Re)Set the start row and the current row pointer + * + * @param integer $startRow The row number at which to start iterating * @return PHPExcel_Worksheet_ColumnCellIterator * @throws PHPExcel_Exception - */ - public function resetStart($startRow = 1) { - $this->_startRow = $startRow; + */ + public function resetStart($startRow = 1) + { + $this->startRow = $startRow; $this->adjustForExistingOnlyRange(); - $this->seek($startRow); + $this->seek($startRow); return $this; - } + } - /** - * (Re)Set the end row - * - * @param integer $endRow The row number at which to stop iterating + /** + * (Re)Set the end row + * + * @param integer $endRow The row number at which to stop iterating * @return PHPExcel_Worksheet_ColumnCellIterator * @throws PHPExcel_Exception - */ - public function resetEnd($endRow = null) { - $this->_endRow = ($endRow) ? $endRow : $this->_subject->getHighestRow(); + */ + public function resetEnd($endRow = null) + { + $this->endRow = ($endRow) ? $endRow : $this->subject->getHighestRow(); $this->adjustForExistingOnlyRange(); return $this; - } + } - /** - * Set the row pointer to the selected row - * - * @param integer $row The row number to set the current pointer at + /** + * Set the row pointer to the selected row + * + * @param integer $row The row number to set the current pointer at * @return PHPExcel_Worksheet_ColumnCellIterator * @throws PHPExcel_Exception - */ - public function seek($row = 1) { - if (($row < $this->_startRow) || ($row > $this->_endRow)) { - throw new PHPExcel_Exception("Row $row is out of range ({$this->_startRow} - {$this->_endRow})"); - } elseif ($this->_onlyExistingCells && !($this->_subject->cellExistsByColumnAndRow($this->_columnIndex, $row))) { + */ + public function seek($row = 1) + { + if (($row < $this->startRow) || ($row > $this->endRow)) { + throw new PHPExcel_Exception("Row $row is out of range ({$this->startRow} - {$this->endRow})"); + } elseif ($this->onlyExistingCells && !($this->subject->cellExistsByColumnAndRow($this->columnIndex, $row))) { throw new PHPExcel_Exception('In "IterateOnlyExistingCells" mode and Cell does not exist'); } - $this->_position = $row; + $this->position = $row; return $this; - } + } - /** - * Rewind the iterator to the starting row - */ - public function rewind() { - $this->_position = $this->_startRow; - } + /** + * Rewind the iterator to the starting row + */ + public function rewind() + { + $this->position = $this->startRow; + } - /** - * Return the current cell in this worksheet column - * - * @return PHPExcel_Worksheet_Row - */ - public function current() { - return $this->_subject->getCellByColumnAndRow($this->_columnIndex, $this->_position); - } + /** + * Return the current cell in this worksheet column + * + * @return PHPExcel_Worksheet_Row + */ + public function current() + { + return $this->subject->getCellByColumnAndRow($this->columnIndex, $this->position); + } - /** - * Return the current iterator key - * - * @return int - */ - public function key() { - return $this->_position; - } + /** + * Return the current iterator key + * + * @return int + */ + public function key() + { + return $this->position; + } - /** - * Set the iterator to its next value - */ - public function next() { + /** + * Set the iterator to its next value + */ + public function next() + { do { - ++$this->_position; - } while (($this->_onlyExistingCells) && - (!$this->_subject->cellExistsByColumnAndRow($this->_columnIndex, $this->_position)) && - ($this->_position <= $this->_endRow)); - } + ++$this->position; + } while (($this->onlyExistingCells) && + (!$this->subject->cellExistsByColumnAndRow($this->columnIndex, $this->position)) && + ($this->position <= $this->endRow)); + } - /** - * Set the iterator to its previous value - */ - public function prev() { - if ($this->_position <= $this->_startRow) { - throw new PHPExcel_Exception("Row is already at the beginning of range ({$this->_startRow} - {$this->_endRow})"); + /** + * Set the iterator to its previous value + */ + public function prev() + { + if ($this->position <= $this->startRow) { + throw new PHPExcel_Exception("Row is already at the beginning of range ({$this->startRow} - {$this->endRow})"); } do { - --$this->_position; - } while (($this->_onlyExistingCells) && - (!$this->_subject->cellExistsByColumnAndRow($this->_columnIndex, $this->_position)) && - ($this->_position >= $this->_startRow)); - } + --$this->position; + } while (($this->onlyExistingCells) && + (!$this->subject->cellExistsByColumnAndRow($this->columnIndex, $this->position)) && + ($this->position >= $this->startRow)); + } - /** - * Indicate if more rows exist in the worksheet range of rows that we're iterating - * - * @return boolean - */ - public function valid() { - return $this->_position <= $this->_endRow; - } + /** + * Indicate if more rows exist in the worksheet range of rows that we're iterating + * + * @return boolean + */ + public function valid() + { + return $this->position <= $this->endRow; + } - /** - * Validate start/end values for "IterateOnlyExistingCells" mode, and adjust if necessary - * + /** + * Validate start/end values for "IterateOnlyExistingCells" mode, and adjust if necessary + * * @throws PHPExcel_Exception - */ - protected function adjustForExistingOnlyRange() { - if ($this->_onlyExistingCells) { - while ((!$this->_subject->cellExistsByColumnAndRow($this->_columnIndex, $this->_startRow)) && - ($this->_startRow <= $this->_endRow)) { - ++$this->_startRow; + */ + protected function adjustForExistingOnlyRange() + { + if ($this->onlyExistingCells) { + while ((!$this->subject->cellExistsByColumnAndRow($this->columnIndex, $this->startRow)) && + ($this->startRow <= $this->endRow)) { + ++$this->startRow; } - if ($this->_startRow > $this->_endRow) { + if ($this->startRow > $this->endRow) { throw new PHPExcel_Exception('No cells exist within the specified range'); } - while ((!$this->_subject->cellExistsByColumnAndRow($this->_columnIndex, $this->_endRow)) && - ($this->_endRow >= $this->_startRow)) { - --$this->_endRow; + while ((!$this->subject->cellExistsByColumnAndRow($this->columnIndex, $this->endRow)) && + ($this->endRow >= $this->startRow)) { + --$this->endRow; } - if ($this->_endRow < $this->_startRow) { + if ($this->endRow < $this->startRow) { throw new PHPExcel_Exception('No cells exist within the specified range'); } } } - } diff --git a/Classes/PHPExcel/Worksheet/ColumnDimension.php b/Classes/PHPExcel/Worksheet/ColumnDimension.php index e52a3f40..956ffdce 100644 --- a/Classes/PHPExcel/Worksheet/ColumnDimension.php +++ b/Classes/PHPExcel/Worksheet/ColumnDimension.php @@ -1,6 +1,7 @@ _columnIndex = $pIndex; + // Initialise values + $this->_columnIndex = $pIndex; - // set default index to cellXf - $this->_xfIndex = 0; + // set default index to cellXf + $this->_xfIndex = 0; } /** @@ -105,8 +97,9 @@ class PHPExcel_Worksheet_ColumnDimension * * @return string */ - public function getColumnIndex() { - return $this->_columnIndex; + public function getColumnIndex() + { + return $this->_columnIndex; } /** @@ -115,9 +108,10 @@ class PHPExcel_Worksheet_ColumnDimension * @param string $pValue * @return PHPExcel_Worksheet_ColumnDimension */ - public function setColumnIndex($pValue) { - $this->_columnIndex = $pValue; - return $this; + public function setColumnIndex($pValue) + { + $this->_columnIndex = $pValue; + return $this; } /** @@ -125,8 +119,9 @@ class PHPExcel_Worksheet_ColumnDimension * * @return double */ - public function getWidth() { - return $this->_width; + public function getWidth() + { + return $this->_width; } /** @@ -135,9 +130,10 @@ class PHPExcel_Worksheet_ColumnDimension * @param double $pValue * @return PHPExcel_Worksheet_ColumnDimension */ - public function setWidth($pValue = -1) { - $this->_width = $pValue; - return $this; + public function setWidth($pValue = -1) + { + $this->_width = $pValue; + return $this; } /** @@ -145,8 +141,9 @@ class PHPExcel_Worksheet_ColumnDimension * * @return bool */ - public function getAutoSize() { - return $this->_autoSize; + public function getAutoSize() + { + return $this->_autoSize; } /** @@ -155,9 +152,10 @@ class PHPExcel_Worksheet_ColumnDimension * @param bool $pValue * @return PHPExcel_Worksheet_ColumnDimension */ - public function setAutoSize($pValue = false) { - $this->_autoSize = $pValue; - return $this; + public function setAutoSize($pValue = false) + { + $this->_autoSize = $pValue; + return $this; } /** @@ -165,8 +163,9 @@ class PHPExcel_Worksheet_ColumnDimension * * @return bool */ - public function getVisible() { - return $this->_visible; + public function getVisible() + { + return $this->_visible; } /** @@ -175,9 +174,10 @@ class PHPExcel_Worksheet_ColumnDimension * @param bool $pValue * @return PHPExcel_Worksheet_ColumnDimension */ - public function setVisible($pValue = true) { - $this->_visible = $pValue; - return $this; + public function setVisible($pValue = true) + { + $this->_visible = $pValue; + return $this; } /** @@ -185,8 +185,9 @@ class PHPExcel_Worksheet_ColumnDimension * * @return int */ - public function getOutlineLevel() { - return $this->_outlineLevel; + public function getOutlineLevel() + { + return $this->_outlineLevel; } /** @@ -198,13 +199,14 @@ class PHPExcel_Worksheet_ColumnDimension * @throws PHPExcel_Exception * @return PHPExcel_Worksheet_ColumnDimension */ - public function setOutlineLevel($pValue) { - if ($pValue < 0 || $pValue > 7) { - throw new PHPExcel_Exception("Outline level must range between 0 and 7."); - } + public function setOutlineLevel($pValue) + { + if ($pValue < 0 || $pValue > 7) { + throw new PHPExcel_Exception("Outline level must range between 0 and 7."); + } - $this->_outlineLevel = $pValue; - return $this; + $this->_outlineLevel = $pValue; + return $this; } /** @@ -212,8 +214,9 @@ class PHPExcel_Worksheet_ColumnDimension * * @return bool */ - public function getCollapsed() { - return $this->_collapsed; + public function getCollapsed() + { + return $this->_collapsed; } /** @@ -222,45 +225,47 @@ class PHPExcel_Worksheet_ColumnDimension * @param bool $pValue * @return PHPExcel_Worksheet_ColumnDimension */ - public function setCollapsed($pValue = true) { - $this->_collapsed = $pValue; - return $this; + public function setCollapsed($pValue = true) + { + $this->_collapsed = $pValue; + return $this; } - /** - * Get index to cellXf - * - * @return int - */ - public function getXfIndex() - { - return $this->_xfIndex; - } + /** + * Get index to cellXf + * + * @return int + */ + public function getXfIndex() + { + return $this->_xfIndex; + } - /** - * Set index to cellXf - * - * @param int $pValue - * @return PHPExcel_Worksheet_ColumnDimension - */ - public function setXfIndex($pValue = 0) - { - $this->_xfIndex = $pValue; - return $this; - } + /** + * Set index to cellXf + * + * @param int $pValue + * @return PHPExcel_Worksheet_ColumnDimension + */ + public function setXfIndex($pValue = 0) + { + $this->_xfIndex = $pValue; + return $this; + } - /** - * Implement PHP __clone to create a deep clone, not just a shallow copy. - */ - public function __clone() { - $vars = get_object_vars($this); - foreach ($vars as $key => $value) { - if (is_object($value)) { - $this->$key = clone $value; - } else { - $this->$key = $value; - } - } - } + /** + * Implement PHP __clone to create a deep clone, not just a shallow copy. + */ + public function __clone() + { + $vars = get_object_vars($this); + foreach ($vars as $key => $value) { + if (is_object($value)) { + $this->$key = clone $value; + } else { + $this->$key = $value; + } + } + } } diff --git a/Classes/PHPExcel/Worksheet/ColumnIterator.php b/Classes/PHPExcel/Worksheet/ColumnIterator.php index bec14d5a..270bca65 100644 --- a/Classes/PHPExcel/Worksheet/ColumnIterator.php +++ b/Classes/PHPExcel/Worksheet/ColumnIterator.php @@ -1,6 +1,7 @@ _subject = $subject; - $this->resetEnd($endColumn); - $this->resetStart($startColumn); - } + /** + * Create a new column iterator + * + * @param PHPExcel_Worksheet $subject The worksheet to iterate over + * @param string $startColumn The column address at which to start iterating + * @param string $endColumn Optionally, the column address at which to stop iterating + */ + public function __construct(PHPExcel_Worksheet $subject = null, $startColumn = 'A', $endColumn = null) + { + // Set subject + $this->subject = $subject; + $this->resetEnd($endColumn); + $this->resetStart($startColumn); + } - /** - * Destructor - */ - public function __destruct() { - unset($this->_subject); - } + /** + * Destructor + */ + public function __destruct() + { + unset($this->subject); + } - /** - * (Re)Set the start column and the current column pointer - * - * @param integer $startColumn The column address at which to start iterating + /** + * (Re)Set the start column and the current column pointer + * + * @param integer $startColumn The column address at which to start iterating * @return PHPExcel_Worksheet_ColumnIterator - */ - public function resetStart($startColumn = 'A') { + */ + public function resetStart($startColumn = 'A') + { $startColumnIndex = PHPExcel_Cell::columnIndexFromString($startColumn) - 1; - $this->_startColumn = $startColumnIndex; - $this->seek($startColumn); - - return $this; - } - - /** - * (Re)Set the end column - * - * @param string $endColumn The column address at which to stop iterating - * @return PHPExcel_Worksheet_ColumnIterator - */ - public function resetEnd($endColumn = null) { - $endColumn = ($endColumn) ? $endColumn : $this->_subject->getHighestColumn(); - $this->_endColumn = PHPExcel_Cell::columnIndexFromString($endColumn) - 1; - - return $this; - } - - /** - * Set the column pointer to the selected column - * - * @param string $column The column address to set the current pointer at - * @return PHPExcel_Worksheet_ColumnIterator - * @throws PHPExcel_Exception - */ - public function seek($column = 'A') { - $column = PHPExcel_Cell::columnIndexFromString($column) - 1; - if (($column < $this->_startColumn) || ($column > $this->_endColumn)) { - throw new PHPExcel_Exception("Column $column is out of range ({$this->_startColumn} - {$this->_endColumn})"); - } - $this->_position = $column; + $this->startColumn = $startColumnIndex; + $this->seek($startColumn); return $this; } - /** - * Rewind the iterator to the starting column - */ - public function rewind() { - $this->_position = $this->_startColumn; - } + /** + * (Re)Set the end column + * + * @param string $endColumn The column address at which to stop iterating + * @return PHPExcel_Worksheet_ColumnIterator + */ + public function resetEnd($endColumn = null) + { + $endColumn = ($endColumn) ? $endColumn : $this->subject->getHighestColumn(); + $this->endColumn = PHPExcel_Cell::columnIndexFromString($endColumn) - 1; - /** - * Return the current column in this worksheet - * - * @return PHPExcel_Worksheet_Column - */ - public function current() { - return new PHPExcel_Worksheet_Column($this->_subject, PHPExcel_Cell::stringFromColumnIndex($this->_position)); - } + return $this; + } - /** - * Return the current iterator key - * - * @return string - */ - public function key() { - return PHPExcel_Cell::stringFromColumnIndex($this->_position); - } + /** + * Set the column pointer to the selected column + * + * @param string $column The column address to set the current pointer at + * @return PHPExcel_Worksheet_ColumnIterator + * @throws PHPExcel_Exception + */ + public function seek($column = 'A') + { + $column = PHPExcel_Cell::columnIndexFromString($column) - 1; + if (($column < $this->startColumn) || ($column > $this->endColumn)) { + throw new PHPExcel_Exception("Column $column is out of range ({$this->startColumn} - {$this->endColumn})"); + } + $this->position = $column; - /** - * Set the iterator to its next value - */ - public function next() { - ++$this->_position; - } + return $this; + } - /** - * Set the iterator to its previous value + /** + * Rewind the iterator to the starting column + */ + public function rewind() + { + $this->position = $this->startColumn; + } + + /** + * Return the current column in this worksheet + * + * @return PHPExcel_Worksheet_Column + */ + public function current() + { + return new PHPExcel_Worksheet_Column($this->subject, PHPExcel_Cell::stringFromColumnIndex($this->position)); + } + + /** + * Return the current iterator key + * + * @return string + */ + public function key() + { + return PHPExcel_Cell::stringFromColumnIndex($this->position); + } + + /** + * Set the iterator to its next value + */ + public function next() + { + ++$this->position; + } + + /** + * Set the iterator to its previous value * * @throws PHPExcel_Exception - */ - public function prev() { - if ($this->_position <= $this->_startColumn) { + */ + public function prev() + { + if ($this->position <= $this->startColumn) { throw new PHPExcel_Exception( - "Column is already at the beginning of range (" . - PHPExcel_Cell::stringFromColumnIndex($this->_endColumn) . " - " . - PHPExcel_Cell::stringFromColumnIndex($this->_endColumn) . ")" + "Column is already at the beginning of range (" . + PHPExcel_Cell::stringFromColumnIndex($this->endColumn) . " - " . + PHPExcel_Cell::stringFromColumnIndex($this->endColumn) . ")" ); } - --$this->_position; - } + --$this->position; + } - /** - * Indicate if more columns exist in the worksheet range of columns that we're iterating - * - * @return boolean - */ - public function valid() { - return $this->_position <= $this->_endColumn; - } + /** + * Indicate if more columns exist in the worksheet range of columns that we're iterating + * + * @return boolean + */ + public function valid() + { + return $this->position <= $this->endColumn; + } } diff --git a/Classes/PHPExcel/Worksheet/Row.php b/Classes/PHPExcel/Worksheet/Row.php index 11fadba5..4f6034f5 100644 --- a/Classes/PHPExcel/Worksheet/Row.php +++ b/Classes/PHPExcel/Worksheet/Row.php @@ -1,6 +1,7 @@ _parent = $parent; - $this->_rowIndex = $rowIndex; - } + /** + * Create a new row + * + * @param PHPExcel_Worksheet $parent + * @param int $rowIndex + */ + public function __construct(PHPExcel_Worksheet $parent = null, $rowIndex = 1) + { + // Set parent and row index + $this->parent = $parent; + $this->rowIndex = $rowIndex; + } - /** - * Destructor - */ - public function __destruct() { - unset($this->_parent); - } + /** + * Destructor + */ + public function __destruct() + { + unset($this->parent); + } - /** - * Get row index - * - * @return int - */ - public function getRowIndex() { - return $this->_rowIndex; - } + /** + * Get row index + * + * @return int + */ + public function getRowIndex() + { + return $this->rowIndex; + } - /** - * Get cell iterator - * - * @param string $startColumn The column address at which to start iterating - * @param string $endColumn Optionally, the column address at which to stop iterating - * @return PHPExcel_Worksheet_CellIterator - */ - public function getCellIterator($startColumn = 'A', $endColumn = null) { - return new PHPExcel_Worksheet_RowCellIterator($this->_parent, $this->_rowIndex, $startColumn, $endColumn); - } + /** + * Get cell iterator + * + * @param string $startColumn The column address at which to start iterating + * @param string $endColumn Optionally, the column address at which to stop iterating + * @return PHPExcel_Worksheet_CellIterator + */ + public function getCellIterator($startColumn = 'A', $endColumn = null) + { + return new PHPExcel_Worksheet_RowCellIterator($this->parent, $this->rowIndex, $startColumn, $endColumn); + } } diff --git a/Classes/PHPExcel/Worksheet/RowCellIterator.php b/Classes/PHPExcel/Worksheet/RowCellIterator.php index df5bbe5a..90eb9c9f 100644 --- a/Classes/PHPExcel/Worksheet/RowCellIterator.php +++ b/Classes/PHPExcel/Worksheet/RowCellIterator.php @@ -1,6 +1,7 @@ _subject = $subject; - $this->_rowIndex = $rowIndex; - $this->resetEnd($endColumn); - $this->resetStart($startColumn); - } + * @param string $startColumn The column address at which to start iterating + * @param string $endColumn Optionally, the column address at which to stop iterating + */ + public function __construct(PHPExcel_Worksheet $subject = null, $rowIndex = 1, $startColumn = 'A', $endColumn = null) + { + // Set subject and row index + $this->subject = $subject; + $this->rowIndex = $rowIndex; + $this->resetEnd($endColumn); + $this->resetStart($startColumn); + } - /** - * Destructor - */ - public function __destruct() { - unset($this->_subject); - } + /** + * Destructor + */ + public function __destruct() + { + unset($this->subject); + } - /** - * (Re)Set the start column and the current column pointer - * - * @param integer $startColumn The column address at which to start iterating + /** + * (Re)Set the start column and the current column pointer + * + * @param integer $startColumn The column address at which to start iterating * @return PHPExcel_Worksheet_RowCellIterator * @throws PHPExcel_Exception - */ - public function resetStart($startColumn = 'A') { + */ + public function resetStart($startColumn = 'A') + { $startColumnIndex = PHPExcel_Cell::columnIndexFromString($startColumn) - 1; - $this->_startColumn = $startColumnIndex; + $this->startColumn = $startColumnIndex; $this->adjustForExistingOnlyRange(); - $this->seek(PHPExcel_Cell::stringFromColumnIndex($this->_startColumn)); - - return $this; - } - - /** - * (Re)Set the end column - * - * @param string $endColumn The column address at which to stop iterating - * @return PHPExcel_Worksheet_RowCellIterator - * @throws PHPExcel_Exception - */ - public function resetEnd($endColumn = null) { - $endColumn = ($endColumn) ? $endColumn : $this->_subject->getHighestColumn(); - $this->_endColumn = PHPExcel_Cell::columnIndexFromString($endColumn) - 1; - $this->adjustForExistingOnlyRange(); - - return $this; - } - - /** - * Set the column pointer to the selected column - * - * @param string $column The column address to set the current pointer at - * @return PHPExcel_Worksheet_RowCellIterator - * @throws PHPExcel_Exception - */ - public function seek($column = 'A') { - $column = PHPExcel_Cell::columnIndexFromString($column) - 1; - if (($column < $this->_startColumn) || ($column > $this->_endColumn)) { - throw new PHPExcel_Exception("Column $column is out of range ({$this->_startColumn} - {$this->_endColumn})"); - } elseif ($this->_onlyExistingCells && !($this->_subject->cellExistsByColumnAndRow($column, $this->_rowIndex))) { - throw new PHPExcel_Exception('In "IterateOnlyExistingCells" mode and Cell does not exist'); - } - $this->_position = $column; + $this->seek(PHPExcel_Cell::stringFromColumnIndex($this->startColumn)); return $this; } - /** - * Rewind the iterator to the starting column - */ - public function rewind() { - $this->_position = $this->_startColumn; - } + /** + * (Re)Set the end column + * + * @param string $endColumn The column address at which to stop iterating + * @return PHPExcel_Worksheet_RowCellIterator + * @throws PHPExcel_Exception + */ + public function resetEnd($endColumn = null) + { + $endColumn = ($endColumn) ? $endColumn : $this->subject->getHighestColumn(); + $this->endColumn = PHPExcel_Cell::columnIndexFromString($endColumn) - 1; + $this->adjustForExistingOnlyRange(); - /** - * Return the current cell in this worksheet row - * - * @return PHPExcel_Cell - */ - public function current() { - return $this->_subject->getCellByColumnAndRow($this->_position, $this->_rowIndex); - } + return $this; + } - /** - * Return the current iterator key - * - * @return string - */ - public function key() { - return PHPExcel_Cell::stringFromColumnIndex($this->_position); - } + /** + * Set the column pointer to the selected column + * + * @param string $column The column address to set the current pointer at + * @return PHPExcel_Worksheet_RowCellIterator + * @throws PHPExcel_Exception + */ + public function seek($column = 'A') + { + $column = PHPExcel_Cell::columnIndexFromString($column) - 1; + if (($column < $this->startColumn) || ($column > $this->endColumn)) { + throw new PHPExcel_Exception("Column $column is out of range ({$this->startColumn} - {$this->endColumn})"); + } elseif ($this->onlyExistingCells && !($this->subject->cellExistsByColumnAndRow($column, $this->rowIndex))) { + throw new PHPExcel_Exception('In "IterateOnlyExistingCells" mode and Cell does not exist'); + } + $this->position = $column; - /** - * Set the iterator to its next value - */ - public function next() { + return $this; + } + + /** + * Rewind the iterator to the starting column + */ + public function rewind() + { + $this->position = $this->startColumn; + } + + /** + * Return the current cell in this worksheet row + * + * @return PHPExcel_Cell + */ + public function current() + { + return $this->subject->getCellByColumnAndRow($this->position, $this->rowIndex); + } + + /** + * Return the current iterator key + * + * @return string + */ + public function key() + { + return PHPExcel_Cell::stringFromColumnIndex($this->position); + } + + /** + * Set the iterator to its next value + */ + public function next() + { do { - ++$this->_position; - } while (($this->_onlyExistingCells) && - (!$this->_subject->cellExistsByColumnAndRow($this->_position, $this->_rowIndex)) && - ($this->_position <= $this->_endColumn)); - } + ++$this->position; + } while (($this->onlyExistingCells) && + (!$this->subject->cellExistsByColumnAndRow($this->position, $this->rowIndex)) && + ($this->position <= $this->endColumn)); + } - /** - * Set the iterator to its previous value + /** + * Set the iterator to its previous value * * @throws PHPExcel_Exception - */ - public function prev() { - if ($this->_position <= $this->_startColumn) { + */ + public function prev() + { + if ($this->position <= $this->startColumn) { throw new PHPExcel_Exception( - "Column is already at the beginning of range (" . - PHPExcel_Cell::stringFromColumnIndex($this->_endColumn) . " - " . - PHPExcel_Cell::stringFromColumnIndex($this->_endColumn) . ")" + "Column is already at the beginning of range (" . + PHPExcel_Cell::stringFromColumnIndex($this->endColumn) . " - " . + PHPExcel_Cell::stringFromColumnIndex($this->endColumn) . ")" ); } do { - --$this->_position; - } while (($this->_onlyExistingCells) && - (!$this->_subject->cellExistsByColumnAndRow($this->_position, $this->_rowIndex)) && - ($this->_position >= $this->_startColumn)); - } + --$this->position; + } while (($this->onlyExistingCells) && + (!$this->subject->cellExistsByColumnAndRow($this->position, $this->rowIndex)) && + ($this->position >= $this->startColumn)); + } - /** - * Indicate if more columns exist in the worksheet range of columns that we're iterating - * - * @return boolean - */ - public function valid() { - return $this->_position <= $this->_endColumn; - } + /** + * Indicate if more columns exist in the worksheet range of columns that we're iterating + * + * @return boolean + */ + public function valid() + { + return $this->position <= $this->endColumn; + } - /** - * Validate start/end values for "IterateOnlyExistingCells" mode, and adjust if necessary - * + /** + * Validate start/end values for "IterateOnlyExistingCells" mode, and adjust if necessary + * * @throws PHPExcel_Exception - */ - protected function adjustForExistingOnlyRange() { - if ($this->_onlyExistingCells) { - while ((!$this->_subject->cellExistsByColumnAndRow($this->_startColumn, $this->_rowIndex)) && - ($this->_startColumn <= $this->_endColumn)) { - ++$this->_startColumn; + */ + protected function adjustForExistingOnlyRange() + { + if ($this->onlyExistingCells) { + while ((!$this->subject->cellExistsByColumnAndRow($this->startColumn, $this->rowIndex)) && + ($this->startColumn <= $this->endColumn)) { + ++$this->startColumn; } - if ($this->_startColumn > $this->_endColumn) { + if ($this->startColumn > $this->endColumn) { throw new PHPExcel_Exception('No cells exist within the specified range'); } - while ((!$this->_subject->cellExistsByColumnAndRow($this->_endColumn, $this->_rowIndex)) && - ($this->_endColumn >= $this->_startColumn)) { - --$this->_endColumn; + while ((!$this->subject->cellExistsByColumnAndRow($this->endColumn, $this->rowIndex)) && + ($this->endColumn >= $this->startColumn)) { + --$this->endColumn; } - if ($this->_endColumn < $this->_startColumn) { + if ($this->endColumn < $this->startColumn) { throw new PHPExcel_Exception('No cells exist within the specified range'); } } } - } diff --git a/Classes/PHPExcel/Worksheet/RowDimension.php b/Classes/PHPExcel/Worksheet/RowDimension.php index 00f7c56b..5314f9c1 100644 --- a/Classes/PHPExcel/Worksheet/RowDimension.php +++ b/Classes/PHPExcel/Worksheet/RowDimension.php @@ -1,6 +1,7 @@ _rowIndex = $pIndex; + // Initialise values + $this->_rowIndex = $pIndex; - // set row dimension as unformatted by default - $this->_xfIndex = null; + // set row dimension as unformatted by default + $this->_xfIndex = null; } /** @@ -105,8 +97,9 @@ class PHPExcel_Worksheet_RowDimension * * @return int */ - public function getRowIndex() { - return $this->_rowIndex; + public function getRowIndex() + { + return $this->_rowIndex; } /** @@ -115,9 +108,10 @@ class PHPExcel_Worksheet_RowDimension * @param int $pValue * @return PHPExcel_Worksheet_RowDimension */ - public function setRowIndex($pValue) { - $this->_rowIndex = $pValue; - return $this; + public function setRowIndex($pValue) + { + $this->_rowIndex = $pValue; + return $this; } /** @@ -125,8 +119,9 @@ class PHPExcel_Worksheet_RowDimension * * @return double */ - public function getRowHeight() { - return $this->_rowHeight; + public function getRowHeight() + { + return $this->_rowHeight; } /** @@ -135,38 +130,42 @@ class PHPExcel_Worksheet_RowDimension * @param double $pValue * @return PHPExcel_Worksheet_RowDimension */ - public function setRowHeight($pValue = -1) { - $this->_rowHeight = $pValue; - return $this; + public function setRowHeight($pValue = -1) + { + $this->_rowHeight = $pValue; + return $this; } - /** - * Get ZeroHeight - * - * @return bool - */ - public function getZeroHeight() { - return $this->_zeroHeight; - } + /** + * Get ZeroHeight + * + * @return bool + */ + public function getZeroHeight() + { + return $this->_zeroHeight; + } - /** - * Set ZeroHeight - * - * @param bool $pValue - * @return PHPExcel_Worksheet_RowDimension - */ - public function setZeroHeight($pValue = false) { - $this->_zeroHeight = $pValue; - return $this; - } + /** + * Set ZeroHeight + * + * @param bool $pValue + * @return PHPExcel_Worksheet_RowDimension + */ + public function setZeroHeight($pValue = false) + { + $this->_zeroHeight = $pValue; + return $this; + } /** * Get Visible * * @return bool */ - public function getVisible() { - return $this->_visible; + public function getVisible() + { + return $this->_visible; } /** @@ -175,9 +174,10 @@ class PHPExcel_Worksheet_RowDimension * @param bool $pValue * @return PHPExcel_Worksheet_RowDimension */ - public function setVisible($pValue = true) { - $this->_visible = $pValue; - return $this; + public function setVisible($pValue = true) + { + $this->_visible = $pValue; + return $this; } /** @@ -185,8 +185,9 @@ class PHPExcel_Worksheet_RowDimension * * @return int */ - public function getOutlineLevel() { - return $this->_outlineLevel; + public function getOutlineLevel() + { + return $this->_outlineLevel; } /** @@ -198,13 +199,14 @@ class PHPExcel_Worksheet_RowDimension * @throws PHPExcel_Exception * @return PHPExcel_Worksheet_RowDimension */ - public function setOutlineLevel($pValue) { - if ($pValue < 0 || $pValue > 7) { - throw new PHPExcel_Exception("Outline level must range between 0 and 7."); - } + public function setOutlineLevel($pValue) + { + if ($pValue < 0 || $pValue > 7) { + throw new PHPExcel_Exception("Outline level must range between 0 and 7."); + } - $this->_outlineLevel = $pValue; - return $this; + $this->_outlineLevel = $pValue; + return $this; } /** @@ -212,8 +214,9 @@ class PHPExcel_Worksheet_RowDimension * * @return bool */ - public function getCollapsed() { - return $this->_collapsed; + public function getCollapsed() + { + return $this->_collapsed; } /** @@ -222,44 +225,46 @@ class PHPExcel_Worksheet_RowDimension * @param bool $pValue * @return PHPExcel_Worksheet_RowDimension */ - public function setCollapsed($pValue = true) { - $this->_collapsed = $pValue; - return $this; + public function setCollapsed($pValue = true) + { + $this->_collapsed = $pValue; + return $this; } - /** - * Get index to cellXf - * - * @return int - */ - public function getXfIndex() - { - return $this->_xfIndex; - } + /** + * Get index to cellXf + * + * @return int + */ + public function getXfIndex() + { + return $this->_xfIndex; + } - /** - * Set index to cellXf - * - * @param int $pValue - * @return PHPExcel_Worksheet_RowDimension - */ - public function setXfIndex($pValue = 0) - { - $this->_xfIndex = $pValue; - return $this; - } + /** + * Set index to cellXf + * + * @param int $pValue + * @return PHPExcel_Worksheet_RowDimension + */ + public function setXfIndex($pValue = 0) + { + $this->_xfIndex = $pValue; + return $this; + } - /** - * Implement PHP __clone to create a deep clone, not just a shallow copy. - */ - public function __clone() { - $vars = get_object_vars($this); - foreach ($vars as $key => $value) { - if (is_object($value)) { - $this->$key = clone $value; - } else { - $this->$key = $value; - } - } - } + /** + * Implement PHP __clone to create a deep clone, not just a shallow copy. + */ + public function __clone() + { + $vars = get_object_vars($this); + foreach ($vars as $key => $value) { + if (is_object($value)) { + $this->$key = clone $value; + } else { + $this->$key = $value; + } + } + } } diff --git a/Classes/PHPExcel/Worksheet/RowIterator.php b/Classes/PHPExcel/Worksheet/RowIterator.php index f01c7f50..6c88d50c 100644 --- a/Classes/PHPExcel/Worksheet/RowIterator.php +++ b/Classes/PHPExcel/Worksheet/RowIterator.php @@ -1,6 +1,7 @@ _subject = $subject; - $this->resetEnd($endRow); - $this->resetStart($startRow); - } + /** + * Create a new row iterator + * + * @param PHPExcel_Worksheet $subject The worksheet to iterate over + * @param integer $startRow The row number at which to start iterating + * @param integer $endRow Optionally, the row number at which to stop iterating + */ + public function __construct(PHPExcel_Worksheet $subject = null, $startRow = 1, $endRow = null) + { + // Set subject + $this->subject = $subject; + $this->resetEnd($endRow); + $this->resetStart($startRow); + } - /** - * Destructor - */ - public function __destruct() { - unset($this->_subject); - } + /** + * Destructor + */ + public function __destruct() + { + unset($this->subject); + } - /** - * (Re)Set the start row and the current row pointer - * - * @param integer $startRow The row number at which to start iterating + /** + * (Re)Set the start row and the current row pointer + * + * @param integer $startRow The row number at which to start iterating * @return PHPExcel_Worksheet_RowIterator - */ - public function resetStart($startRow = 1) { - $this->_startRow = $startRow; - $this->seek($startRow); + */ + public function resetStart($startRow = 1) + { + $this->startRow = $startRow; + $this->seek($startRow); return $this; - } + } - /** - * (Re)Set the end row - * - * @param integer $endRow The row number at which to stop iterating + /** + * (Re)Set the end row + * + * @param integer $endRow The row number at which to stop iterating * @return PHPExcel_Worksheet_RowIterator - */ - public function resetEnd($endRow = null) { - $this->_endRow = ($endRow) ? $endRow : $this->_subject->getHighestRow(); + */ + public function resetEnd($endRow = null) + { + $this->endRow = ($endRow) ? $endRow : $this->subject->getHighestRow(); return $this; - } + } - /** - * Set the row pointer to the selected row - * - * @param integer $row The row number to set the current pointer at + /** + * Set the row pointer to the selected row + * + * @param integer $row The row number to set the current pointer at * @return PHPExcel_Worksheet_RowIterator * @throws PHPExcel_Exception - */ - public function seek($row = 1) { - if (($row < $this->_startRow) || ($row > $this->_endRow)) { - throw new PHPExcel_Exception("Row $row is out of range ({$this->_startRow} - {$this->_endRow})"); + */ + public function seek($row = 1) + { + if (($row < $this->startRow) || ($row > $this->endRow)) { + throw new PHPExcel_Exception("Row $row is out of range ({$this->startRow} - {$this->endRow})"); } - $this->_position = $row; + $this->position = $row; return $this; - } + } - /** - * Rewind the iterator to the starting row - */ - public function rewind() { - $this->_position = $this->_startRow; - } + /** + * Rewind the iterator to the starting row + */ + public function rewind() + { + $this->position = $this->startRow; + } - /** - * Return the current row in this worksheet - * - * @return PHPExcel_Worksheet_Row - */ - public function current() { - return new PHPExcel_Worksheet_Row($this->_subject, $this->_position); - } + /** + * Return the current row in this worksheet + * + * @return PHPExcel_Worksheet_Row + */ + public function current() + { + return new PHPExcel_Worksheet_Row($this->subject, $this->position); + } - /** - * Return the current iterator key - * - * @return int - */ - public function key() { - return $this->_position; - } + /** + * Return the current iterator key + * + * @return int + */ + public function key() + { + return $this->position; + } - /** - * Set the iterator to its next value - */ - public function next() { - ++$this->_position; - } + /** + * Set the iterator to its next value + */ + public function next() + { + ++$this->position; + } - /** - * Set the iterator to its previous value - */ - public function prev() { - if ($this->_position <= $this->_startRow) { - throw new PHPExcel_Exception("Row is already at the beginning of range ({$this->_startRow} - {$this->_endRow})"); + /** + * Set the iterator to its previous value + */ + public function prev() + { + if ($this->position <= $this->startRow) { + throw new PHPExcel_Exception("Row is already at the beginning of range ({$this->startRow} - {$this->endRow})"); } - --$this->_position; - } + --$this->position; + } - /** - * Indicate if more rows exist in the worksheet range of rows that we're iterating - * - * @return boolean - */ - public function valid() { - return $this->_position <= $this->_endRow; - } + /** + * Indicate if more rows exist in the worksheet range of rows that we're iterating + * + * @return boolean + */ + public function valid() + { + return $this->position <= $this->endRow; + } } diff --git a/Classes/PHPExcel/WorksheetIterator.php b/Classes/PHPExcel/WorksheetIterator.php index 065bfe3f..cb1b2811 100644 --- a/Classes/PHPExcel/WorksheetIterator.php +++ b/Classes/PHPExcel/WorksheetIterator.php @@ -1,6 +1,7 @@ _subject = $subject; + $this->subject = $subject; } /** @@ -67,7 +57,7 @@ class PHPExcel_WorksheetIterator implements Iterator */ public function __destruct() { - unset($this->_subject); + unset($this->subject); } /** @@ -75,7 +65,7 @@ class PHPExcel_WorksheetIterator implements Iterator */ public function rewind() { - $this->_position = 0; + $this->position = 0; } /** @@ -85,7 +75,7 @@ class PHPExcel_WorksheetIterator implements Iterator */ public function current() { - return $this->_subject->getSheet($this->_position); + return $this->subject->getSheet($this->position); } /** @@ -95,7 +85,7 @@ class PHPExcel_WorksheetIterator implements Iterator */ public function key() { - return $this->_position; + return $this->position; } /** @@ -103,7 +93,7 @@ class PHPExcel_WorksheetIterator implements Iterator */ public function next() { - ++$this->_position; + ++$this->position; } /** @@ -113,6 +103,6 @@ class PHPExcel_WorksheetIterator implements Iterator */ public function valid() { - return $this->_position < $this->_subject->getSheetCount(); + return $this->position < $this->subject->getSheetCount(); } }