Source for file Worksheet.php
Documentation is available at Worksheet.php 
 * Copyright (c) 2006 - 2009 PHPExcel  
 * This library is free software; you can redistribute it and/or  
 * modify it under the terms of the GNU Lesser General Public  
 * License as published by the Free Software Foundation; either  
 * version 2.1 of the License, or (at your option) any later version.  
 * This library is distributed in the hope that it will be useful,  
 * but WITHOUT ANY WARRANTY; without even the implied warranty of  
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  
 * Lesser General Public License for more details.  
 * You should have received a copy of the GNU Lesser General Public  
 * License along with this library; if not, write to the Free Software  
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA  
 * @package    PHPExcel_Worksheet  
 * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)  
 * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL  
 * @version    1.7.0, 2009-08-10  
    define('PHPEXCEL_ROOT', dirname(__FILE__ ) .  '/../');  
require_once PHPEXCEL_ROOT .  'PHPExcel.php';  
require_once PHPEXCEL_ROOT .  'PHPExcel/Cell.php';  
/** PHPExcel_Cell_DataType */  
require_once PHPEXCEL_ROOT .  'PHPExcel/Cell/DataType.php';  
/** PHPExcel_Worksheet_RowDimension */  
require_once PHPEXCEL_ROOT .  'PHPExcel/Worksheet/RowDimension.php';  
/** PHPExcel_Worksheet_ColumnDimension */  
require_once PHPEXCEL_ROOT .  'PHPExcel/Worksheet/ColumnDimension.php';  
/** PHPExcel_Worksheet_PageSetup */  
require_once PHPEXCEL_ROOT .  'PHPExcel/Worksheet/PageSetup.php';  
/** PHPExcel_Worksheet_PageMargins */  
require_once PHPEXCEL_ROOT .  'PHPExcel/Worksheet/PageMargins.php';  
/** PHPExcel_Worksheet_HeaderFooter */  
require_once PHPEXCEL_ROOT .  'PHPExcel/Worksheet/HeaderFooter.php';  
/** PHPExcel_Worksheet_BaseDrawing */  
require_once PHPEXCEL_ROOT .  'PHPExcel/Worksheet/BaseDrawing.php';  
/** PHPExcel_Worksheet_Drawing */  
require_once PHPEXCEL_ROOT .  'PHPExcel/Worksheet/Drawing.php';  
/** PHPExcel_Worksheet_MemoryDrawing */  
require_once PHPEXCEL_ROOT .  'PHPExcel/Worksheet/MemoryDrawing.php';  
/** PHPExcel_Worksheet_HeaderFooterDrawing */  
require_once PHPEXCEL_ROOT .  'PHPExcel/Worksheet/HeaderFooterDrawing.php';  
/** PHPExcel_Worksheet_SheetView */  
require_once PHPEXCEL_ROOT .  'PHPExcel/Worksheet/SheetView.php';  
/** PHPExcel_Worksheet_Protection */  
require_once PHPEXCEL_ROOT .  'PHPExcel/Worksheet/Protection.php';  
/** PHPExcel_Worksheet_RowIterator */  
require_once PHPEXCEL_ROOT .  'PHPExcel/Worksheet/RowIterator.php';  
require_once PHPEXCEL_ROOT .  'PHPExcel/Comment.php';  
require_once PHPEXCEL_ROOT .  'PHPExcel/Style.php';  
/** PHPExcel_Style_Fill */  
require_once PHPEXCEL_ROOT .  'PHPExcel/Style/Fill.php';  
/** PHPExcel_Style_NumberFormat */  
require_once PHPEXCEL_ROOT .  'PHPExcel/Style/NumberFormat.php';  
/** PHPExcel_IComparable */  
require_once PHPEXCEL_ROOT .  'PHPExcel/IComparable.php';  
/** PHPExcel_Shared_Font */  
require_once PHPEXCEL_ROOT .  'PHPExcel/Shared/Font.php';  
/** PHPExcel_Shared_String */  
require_once PHPEXCEL_ROOT .  'PHPExcel/Shared/String.php';  
/** PHPExcel_Shared_PasswordHasher */  
require_once PHPEXCEL_ROOT .  'PHPExcel/Shared/PasswordHasher.php';  
/** PHPExcel_ReferenceHelper */  
require_once PHPEXCEL_ROOT .  'PHPExcel/ReferenceHelper.php';  
 * @package    PHPExcel_Worksheet  
 * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)  
     * Collection of row dimensions  
     * @var PHPExcel_Worksheet_RowDimension[]   
     * @var PHPExcel_Worksheet_RowDimension   
     * Collection of column dimensions  
     * @var PHPExcel_Worksheet_ColumnDimension[]   
     * Default column dimension  
     * @var PHPExcel_Worksheet_ColumnDimension   
     * @var PHPExcel_Worksheet_BaseDrawing[]   
     * @var PHPExcel_Worksheet_PageSetup   
     * @var PHPExcel_Worksheet_PageMargins   
     * @var PHPExcel_Worksheet_HeaderFooter   
     * @var PHPExcel_Worksheet_SheetView   
     * @var PHPExcel_Worksheet_Protection   
     * Conditional styles. Indexed by cell coordinate, e.g. 'A1'  
     * Is the current cell collection sorted already?  
     * Collection of merged cell ranges  
     * Collection of protected cell ranges  
     * Show summary below? (Row/Column outline)  
     * Show summary right? (Row/Column outline)  
     * @var PHPExcel_Comment[]   
     * Temporary property used by style supervisor. Will be removed  
     * Temporary property used by style supervisor. Will be removed  
     * Hyperlinks. Indexed by cell coordinate, e.g. 'A1'  
     * Data validation objects. Indexed by cell coordinate, e.g. 'A1'  
     * @param PHPExcel         $pParent   
    public function __construct(PHPExcel $pParent =  null, $pTitle =  'Worksheet')  
        // Set page header/footer  
        // Default column dimension  
     * Get collection of cells  
     * @param boolean $pSorted Also sort the cell collection?  
     * @return PHPExcel_Cell[]   
            // Re-order cell collection  
     * Sort collection of cells  
     * @return PHPExcel_Worksheet   
            // Re-order cell collection  
            // uasort($this->_cellCollection, array('PHPExcel_Cell', 'compareCells')); <-- slow  
                // Columns are limited to ZZZ (18278), so 20000 is plenty to assure no conflicts  
                $key =   $rowNum *  20000 +  $colNum;  
                $indexed[$key] =  $index; // &$this->_cellCollection[$index];  
            // Rebuild cellCollection from the sorted index  
            $newCellCollection =  array();  
            foreach ($indexed as $index) {  
     * Get collection of row dimensions  
     * @return PHPExcel_Worksheet_RowDimension[]   
     * Get default row dimension  
     * @return PHPExcel_Worksheet_RowDimension   
     * Get collection of column dimensions  
     * @return PHPExcel_Worksheet_ColumnDimension[]   
     * Get default column dimension  
     * @return PHPExcel_Worksheet_ColumnDimension   
     * Get collection of drawings  
     * @return PHPExcel_Worksheet_BaseDrawing[]   
     * Refresh column dimensions  
     * @return PHPExcel_Worksheet   
        $newColumnDimensions =  array();  
        foreach ($currentColumnDimensions as $objColumnDimension) {  
            $newColumnDimensions[$objColumnDimension->getColumnIndex()] =  $objColumnDimension;  
     * @return PHPExcel_Worksheet   
        $newRowDimensions =  array();  
        foreach ($currentRowDimensions as $objRowDimension) {  
            $newRowDimensions[$objRowDimension->getRowIndex()] =  $objRowDimension;  
     * Calculate worksheet dimension  
     * @return string  String containing the dimension of this worksheet  
     * Calculate widths for auto-size columns  
     * @param  boolean  $calculateMergeCells  Calculate merge cell width  
     * @return PHPExcel_Worksheet;   
            if ($colDimension->getAutoSize()) {  
                $autoSizes[$colDimension->getColumnIndex()] = - 1;  
            if (isset ($autoSizes[$cell->getColumn()])) {  
                $cellValue =  $cell->getCalculatedValue();  
                    if ($cell->isInRange($cells) &&  !$calculateMergeCells) {  
                        $cellValue =  ''; // do not calculate merge cells  
                $autoSizes[$cell->getColumn()] =  max(  
                    (float) $autoSizes[$cell->getColumn()], 
                        $this->getParent()->getCellXfByIndex($cell->getXfIndex())->getFont()->getSize(),  
                        $this->getParent()->getCellXfByIndex($cell->getXfIndex())->getAlignment()->getTextRotation()  
        foreach ($autoSizes as $columnIndex =>  $width) {  
     * @param PHPExcel $parent   
     * @return PHPExcel_Worksheet   
        $namedRanges =  $this->_parent->getNamedRanges();  
        foreach ($namedRanges as $namedRange) {  
            $parent->addNamedRange($namedRange);  
        $this->_parent->removeSheetByIndex(  
     * @param string $pValue String containing the dimension of this worksheet  
     * @return PHPExcel_Worksheet   
    public function setTitle($pValue =  'Worksheet')  
        // Is this a 'rename' or not?  
        // Maximum 31 characters allowed for sheet title  
            throw  new Exception('Maximum 31 characters allowed in sheet title.'); 
        // Is there already such sheet name?  
        if ($this->getParent()->getSheetByName($pValue)) {  
            // Use name, but append with lowest possible integer  
            while ($this->getParent()->getSheetByName($pValue .  ' ' .  $i)) {  
            $altTitle =  $pValue .  ' ' .  $i;  
     * @return PHPExcel_Worksheet_PageSetup   
     * @param PHPExcel_Worksheet_PageSetup    $pValue   
     * @return PHPExcel_Worksheet   
    public function setPageSetup(PHPExcel_Worksheet_PageSetup $pValue)  
     * @return PHPExcel_Worksheet_PageMargins   
     * @param PHPExcel_Worksheet_PageMargins    $pValue   
     * @return PHPExcel_Worksheet   
    public function setPageMargins(PHPExcel_Worksheet_PageMargins $pValue)  
     * @return PHPExcel_Worksheet_HeaderFooter   
     * @param PHPExcel_Worksheet_HeaderFooter    $pValue   
     * @return PHPExcel_Worksheet   
     * @return PHPExcel_Worksheet_HeaderFooter   
     * @param PHPExcel_Worksheet_SheetView    $pValue   
     * @return PHPExcel_Worksheet   
    public function setSheetView(PHPExcel_Worksheet_SheetView $pValue)  
     * @return PHPExcel_Worksheet_Protection   
     * @param PHPExcel_Worksheet_Protection    $pValue   
     * @return PHPExcel_Worksheet   
    public function setProtection(PHPExcel_Worksheet_Protection $pValue)  
     * Get highest worksheet column  
     * @return string Highest column name  
        // Loop trough column dimensions  
        if ($highestColumn <  0) {  
     * Get highest worksheet row  
     * @return int Highest row number  
            if ($cell->getRow() >  $highestRow) {  
                $highestRow =  $cell->getRow();  
        // Loop trough row dimensions  
            if ($highestRow <  $dimension->getRowIndex()) {  
                $highestRow =  $dimension->getRowIndex();  
     * @param string     $pCoordinate    Coordinate of the cell  
     * @param mixed     $pValue            Value of the cell  
     * @return PHPExcel_Worksheet   
    public function setCellValue($pCoordinate =  'A1', $pValue =  null)  
        $this->getCell($pCoordinate)->setValue($pValue);  
     * Set a cell value by using numeric cell coordinates  
     * @param string     $pColumn        Numeric column coordinate of the cell  
     * @param string     $pRow            Numeric row coordinate of the cell  
     * @param mixed     $pValue            Value of the cell  
     * @return PHPExcel_Worksheet   
     * @param string     $pCoordinate    Coordinate of the cell  
     * @param mixed     $pValue            Value of the cell  
     * @param string    $pDataType        Explicit data type  
     * @return PHPExcel_Worksheet   
    public function setCellValueExplicit($pCoordinate =  'A1', $pValue =  null, $pDataType =  PHPExcel_Cell_DataType::TYPE_STRING)  
        $this->getCell($pCoordinate)->setValueExplicit($pValue, $pDataType);  
     * Set a cell value by using numeric cell coordinates  
     * @param string     $pColumn        Numeric column coordinate of the cell  
     * @param string     $pRow            Numeric row coordinate of the cell  
     * @param mixed     $pValue            Value of the cell  
     * @param string    $pDataType        Explicit data type  
     * @return PHPExcel_Worksheet   
     * Get cell at a specific coordinate  
     * @param     string             $pCoordinate    Coordinate of the cell  
     * @return     PHPExcel_Cell     Cell that was found  
    public function getCell($pCoordinate =  'A1')  
        if (strpos($pCoordinate, '!') !==  false) {  
            return $this->getParent()->getSheetByName($worksheetReference[0])->getCell($worksheetReference[1]);  
                $pCoordinate =  $namedRange->getRange();  
                if ($this->getHashCode() !=  $namedRange->getWorksheet()->getHashCode()) {  
                    if (!$namedRange->getLocalOnly()) {  
                        return $namedRange->getWorksheet()->getCell($pCoordinate);  
                        throw  new Exception('Named range ' .  $namedRange->getName() .  ' is not accessible from within sheet ' .  $this->getTitle()); 
        if (strpos($pCoordinate,':') !==  false ||  strpos($pCoordinate,',') !==  false) {  
            throw  new Exception('Cell coordinate can not be a range of cells.'); 
        } elseif (strpos($pCoordinate,'$') !==  false) {  
            throw  new Exception('Cell coordinate must not be absolute.'); 
     * Get cell at a specific coordinate by using numeric cell coordinates  
     * @param     string $pColumn        Numeric column coordinate of the cell  
     * @param     string $pRow        Numeric row coordinate of the cell  
     * @return     PHPExcel_Cell         Cell that was found  
     * Cell at a specific coordinate exists?  
     * @param     string             $pCoordinate    Coordinate of the cell  
        if (strpos($pCoordinate, '!') !==  false) {  
            return $this->getParent()->getSheetByName($worksheetReference[0])->cellExists($worksheetReference[1]);  
                $pCoordinate =  $namedRange->getRange();  
                if ($this->getHashCode() !=  $namedRange->getWorksheet()->getHashCode()) {  
                    if (!$namedRange->getLocalOnly()) {  
                        return $namedRange->getWorksheet()->cellExists($pCoordinate);  
                        throw  new Exception('Named range ' .  $namedRange->getName() .  ' is not accessible from within sheet ' .  $this->getTitle()); 
        if (strpos($pCoordinate,':') !==  false ||  strpos($pCoordinate,',') !==  false) {  
            throw  new Exception('Cell coordinate can not be a range of cells.'); 
        } elseif (strpos($pCoordinate,'$') !==  false) {  
            throw  new Exception('Cell coordinate must not be absolute.'); 
     * Cell at a specific coordinate by using numeric cell coordinates exists?  
     * @param     string $pColumn        Numeric column coordinate of the cell  
     * @param     string $pRow        Numeric row coordinate of the cell  
     * Get row dimension at a specific row  
     * @param int $pRow    Numeric index of the row  
     * @return PHPExcel_Worksheet_RowDimension   
     * Get column dimension at a specific column  
     * @param string $pColumn    String index of the column  
     * @return PHPExcel_Worksheet_ColumnDimension   
     * Get column dimension at a specific column by using numeric cell coordinates  
     * @param     string $pColumn        Numeric column coordinate of the cell  
     * @param     string $pRow        Numeric row coordinate of the cell  
     * @return     PHPExcel_Worksheet_ColumnDimension   
     * @return PHPExcel_Style[]   
     * Get default style of workbork.  
        return $this->_parent->getDefaultStyle();  
     * Set default style - should only be used by PHPExcel_IReader implementations!  
     * @param     PHPExcel_Style $value   
     * @return PHPExcel_Worksheet   
        $this->_parent->setDefaultStyle($value);  
     * @param     string     $pCellCoordinate    Cell coordinate to get style for  
    public function getStyle($pCellCoordinate =  'A1')  
        // set this sheet as active  
        // set cell coordinate as active  
        return $this->_parent->getCellXfSupervisor();  
     * Get conditional styles for a cell  
     * @param string $pCoordinate   
     * @return PHPExcel_Style_Conditional[]   
     * Do conditional styles exist for this cell?  
     * @param string $pCoordinate   
     * Removes conditional styles for a cell  
     * @param string $pCoordinate   
     * @return PHPExcel_Worksheet   
     * Get collection of conditional styles  
     * @param $pCoordinate string E.g. 'A1'  
     * @param $pValue PHPExcel_Style_Conditional[]  
     * @return PHPExcel_Worksheet   
     * Get style for cell by using numeric cell coordinates  
     * @param     int $pColumn    Numeric column coordinate of the cell  
     * @param     int $pRow        Numeric row coordinate of the cell  
     * Set shared cell style to a range of cells  
     * Please note that this will overwrite existing cell styles for cells in range!  
     * @param     PHPExcel_Style    $pSharedCellStyle    Cell style to share  
     * @param     string            $pRange                Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1")  
     * @return PHPExcel_Worksheet   
     public function setSharedStyle(PHPExcel_Style $pSharedCellStyle =  null, $pRange =  '')  
     * Duplicate cell style to a range of cells  
     * Please note that this will overwrite existing cell styles for cells in range!  
     * @param     PHPExcel_Style    $pCellStyle    Cell style to duplicate  
     * @param     string            $pRange        Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1")  
     * @return PHPExcel_Worksheet   
    public function duplicateStyle(PHPExcel_Style $pCellStyle =  null, $pRange =  '')  
        // make sure we have a real style and not supervisor  
        $style =  $pCellStyle->getIsSupervisor() ?  $pCellStyle->getSharedComponent() :  $pCellStyle;  
        // Add the style to the workbook if necessary  
        if ($existingStyle =  $this->_parent->getCellXfByHashCode($pCellStyle->getHashCode())) {  
            // there is already such cell Xf in our collection  
            $xfIndex =  $existingStyle->getIndex();  
            // we don't have such a cell Xf, need to add  
            $workbook->addCellXf($pCellStyle);  
            $xfIndex =  $pCellStyle->getIndex();  
           // Is it a cell range or a single cell?  
           if (strpos($pRange, ':') ===  false) {  
               list ($rangeA, $rangeB) =  explode(':', $pRange); 
           // Calculate range outer borders  
           // Translate column into index  
           // Make sure we can loop upwards on rows and columns  
           if ($rangeStart[0] >  $rangeEnd[0] &&  $rangeStart[1] >  $rangeEnd[1]) {  
           // Loop trough cells and apply styles  
           for ($col =  $rangeStart[0]; $col <=  $rangeEnd[0]; ++ $col) {  
               for ($row =  $rangeStart[1]; $row <=  $rangeEnd[1]; ++ $row) {  
     * Duplicate cell style array to a range of cells  
     * Please note that this will overwrite existing cell styles for cells in range,  
     * if they are in the styles array. For example, if you decide to set a range of  
     * cells to font bold, only include font bold in the styles array.  
     * @param    array            $pStyles    Array containing style information  
     * @param     string            $pRange        Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1")  
     * @param     boolean            $pAdvanced    Advanced mode for setting borders.  
     * @return PHPExcel_Worksheet   
        $this->getStyle($pRange)->applyFromArray($pStyles, $pAdvanced);  
     * @param     string            $pCell        Cell coordinate (e.g. A1)  
     * @param     int                $pBreak        Break type (type of PHPExcel_Worksheet::BREAK_*)  
     * @return PHPExcel_Worksheet   
    public function setBreak($pCell =  'A1', $pBreak =  PHPExcel_Worksheet::BREAK_NONE)  
            throw  new Exception('No cell coordinate specified.'); 
     * Set break on a cell by using numeric cell coordinates  
     * @param     int     $pColumn    Numeric column coordinate of the cell  
     * @param     int     $pRow        Numeric row coordinate of the cell  
     * @param     int        $pBreak        Break type (type of PHPExcel_Worksheet::BREAK_*)  
     * @return PHPExcel_Worksheet   
     * Set merge on a cell range  
     * @param     string            $pRange        Cell range (e.g. A1:E1)  
     * @return PHPExcel_Worksheet   
        if (strpos($pRange,':') !==  false) {  
            throw  new Exception('Merge must be set on a range of cells.'); 
     * Set merge on a cell range by using numeric cell coordinates  
     * @param     int $pColumn1    Numeric column coordinate of the first cell  
     * @param     int $pRow1        Numeric row coordinate of the first cell  
     * @param     int $pColumn2    Numeric column coordinate of the last cell  
     * @param     int $pRow2        Numeric row coordinate of the last cell  
     * @return PHPExcel_Worksheet   
     * Remove merge on a cell range  
     * @param     string            $pRange        Cell range (e.g. A1:E1)  
     * @return PHPExcel_Worksheet   
        if (strpos($pRange,':') !==  false) {  
                throw  new Exception('Cell range ' .  $pRange .  ' not known as merged.'); 
            throw  new Exception('Merge can only be removed from a range of cells.'); 
     * Remove merge on a cell range by using numeric cell coordinates  
     * @param     int $pColumn1    Numeric column coordinate of the first cell  
     * @param     int $pRow1        Numeric row coordinate of the first cell  
     * @param     int $pColumn2    Numeric column coordinate of the last cell  
     * @param     int $pRow2        Numeric row coordinate of the last cell  
     * @return PHPExcel_Worksheet   
     * Set protection on a cell range  
     * @param     string            $pRange                Cell (e.g. A1) or cell range (e.g. A1:E1)  
     * @param     string            $pPassword            Password to unlock the protection  
     * @param     boolean         $pAlreadyHashed     If the password has already been hashed, set this to true  
     * @return PHPExcel_Worksheet   
    public function protectCells($pRange =  'A1', $pPassword =  '', $pAlreadyHashed =  false)  
     * Set protection on a cell range by using numeric cell coordinates  
     * @param     int     $pColumn1            Numeric column coordinate of the first cell  
     * @param     int     $pRow1                Numeric row coordinate of the first cell  
     * @param     int     $pColumn2            Numeric column coordinate of the last cell  
     * @param     int     $pRow2                Numeric row coordinate of the last cell  
     * @param     string    $pPassword            Password to unlock the protection  
     * @param     boolean $pAlreadyHashed     If the password has already been hashed, set this to true  
     * @return PHPExcel_Worksheet   
    public function protectCellsByColumnAndRow($pColumn1 =  0, $pRow1 =  0, $pColumn2 =  0, $pRow2 =  0, $pPassword =  '', $pAlreadyHashed =  false)  
        return $this->protectCells($cellRange, $pPassword, $pAlreadyHashed);  
     * Remove protection on a cell range  
     * @param     string            $pRange        Cell (e.g. A1) or cell range (e.g. A1:E1)  
     * @return PHPExcel_Worksheet   
            throw  new Exception('Cell range ' .  $pRange .  ' not known as protected.'); 
     * Remove protection on a cell range by using numeric cell coordinates  
     * @param     int     $pColumn1            Numeric column coordinate of the first cell  
     * @param     int     $pRow1                Numeric row coordinate of the first cell  
     * @param     int     $pColumn2            Numeric column coordinate of the last cell  
     * @param     int     $pRow2                Numeric row coordinate of the last cell  
     * @param     string    $pPassword            Password to unlock the protection  
     * @param     boolean $pAlreadyHashed     If the password has already been hashed, set this to true  
     * @return PHPExcel_Worksheet   
    public function unprotectCellsByColumnAndRow($pColumn1 =  0, $pRow1 =  0, $pColumn2 =  0, $pRow2 =  0, $pPassword =  '', $pAlreadyHashed =  false)  
        return $this->unprotectCells($cellRange, $pPassword, $pAlreadyHashed);  
     * @param     string        $pRange        Cell range (i.e. A1:E10)  
     * @return PHPExcel_Worksheet   
        if (strpos($pRange,':') !==  false) {  
            throw  new Exception('Autofilter must be set on a range of cells.'); 
     * Set Autofilter Range by using numeric cell coordinates  
     * @param     int     $pColumn1    Numeric column coordinate of the first cell  
     * @param     int     $pRow1        Numeric row coordinate of the first cell  
     * @param     int     $pColumn2    Numeric column coordinate of the second cell  
     * @param     int     $pRow2        Numeric row coordinate of the second cell  
     * @return PHPExcel_Worksheet   
     * @param     string        $pCell        Cell (i.e. A1)  
     * @return PHPExcel_Worksheet   
        if (strpos($pCell,':') ===  false &&  strpos($pCell,',') ===  false) {  
            throw  new Exception('Freeze pane can not be set on a range of cells.'); 
     * Freeze Pane by using numeric cell coordinates  
     * @param     int     $pColumn    Numeric column coordinate of the cell  
     * @param     int     $pRow        Numeric row coordinate of the cell  
     * @return PHPExcel_Worksheet   
     * @return PHPExcel_Worksheet   
     * Insert a new row, updating all possible related data  
     * @param     int    $pBefore    Insert before this one  
     * @param     int    $pNumRows    Number of rows to insert  
     * @return PHPExcel_Worksheet   
            $objReferenceHelper->insertNewBefore('A' .  $pBefore, 0, $pNumRows, $this);  
            throw  new Exception("Rows can only be inserted before at least row 1."); 
     * Insert a new column, updating all possible related data  
     * @param     int    $pBefore    Insert before this one  
     * @param     int    $pNumCols    Number of columns to insert  
     * @return PHPExcel_Worksheet   
            $objReferenceHelper->insertNewBefore($pBefore .  '1', $pNumCols, 0, $this);  
            throw  new Exception("Column references should not be numeric."); 
     * Insert a new column, updating all possible related data  
     * @param     int    $pBefore    Insert before this one (numeric column coordinate of the cell)  
     * @param     int    $pNumCols    Number of columns to insert  
     * @return PHPExcel_Worksheet   
            throw  new Exception("Columns can only be inserted before at least column A (0)."); 
     * Delete a row, updating all possible related data  
     * @param     int    $pRow        Remove starting with this one  
     * @param     int    $pNumRows    Number of rows to remove  
     * @return PHPExcel_Worksheet   
    public function removeRow($pRow =  1, $pNumRows =  1) {  
            $objReferenceHelper->insertNewBefore('A' .  ($pRow +  $pNumRows), 0, - $pNumRows, $this);  
            throw  new Exception("Rows to be deleted should at least start from row 1."); 
     * Remove a column, updating all possible related data  
     * @param     int    $pColumn    Remove starting with this one  
     * @param     int    $pNumCols    Number of columns to remove  
     * @return PHPExcel_Worksheet   
    public function removeColumn($pColumn =  'A', $pNumCols =  1) {  
            $objReferenceHelper->insertNewBefore($pColumn .  '1', - $pNumCols, 0, $this);  
            throw  new Exception("Column references should not be numeric."); 
     * Remove a column, updating all possible related data  
     * @param     int    $pColumn    Remove starting with this one (numeric column coordinate of the cell)  
     * @param     int    $pNumCols    Number of columns to remove  
     * @return PHPExcel_Worksheet   
            throw  new Exception("Columns can only be inserted before at least column A (0)."); 
     * @param boolean $pValue    Show gridlines (true/false)  
     * @return PHPExcel_Worksheet   
    * @param boolean $pValue Print gridlines (true/false)  
    * @return PHPExcel_Worksheet   
     * Show summary below? (Row/Column outlining)  
     * @param boolean $pValue    Show summary below (true/false)  
     * @return PHPExcel_Worksheet   
     * Show summary right? (Row/Column outlining)  
     * @param boolean $pValue    Show summary right (true/false)  
     * @return PHPExcel_Worksheet   
     * @return PHPExcel_Comment[]   
     * @param     string     $pCellCoordinate    Cell coordinate to get comment for  
     * @return     PHPExcel_Comment   
    public function getComment($pCellCoordinate =  'A1')  
        if (strpos($pCellCoordinate,':') !==  false ||  strpos($pCellCoordinate,',') !==  false) {  
            throw  new Exception('Cell coordinate string can not be a range of cells.'); 
        } else if (strpos($pCellCoordinate,'$') !==  false) {  
            throw  new Exception('Cell coordinate string must not be absolute.'); 
        } else if ($pCellCoordinate ==  '') {  
            throw  new Exception('Cell coordinate can not be zero-length string.'); 
            // Check if we already have a comment for this cell.  
            // If not, create a new comment.  
            if (isset ($this->_comments[$pCellCoordinate])) {  
                $this->_comments[$pCellCoordinate] =  $newComment;  
     * Get comment for cell by using numeric cell coordinates  
     * @param     int $pColumn    Numeric column coordinate of the cell  
     * @param     int $pRow        Numeric row coordinate of the cell  
     * @return     PHPExcel_Comment   
     * Temporary method used by style supervisor. Will be removed  
     * Temporary method used by style supervisor. Will be removed  
     * @param     string        $pCell        Cell (i.e. A1)  
     * @return PHPExcel_Worksheet   
        if (strpos($pCoordinate,':') !==  false ||  strpos($pCoordinate,',') !==  false) {  
            throw  new Exception('Selected cell can not be set on a range of cells.'); 
     * Temporary method used by style supervisor. Will be removed  
     * @param     string        $pCell        Cell (i.e. A1)  
     * @return PHPExcel_Worksheet   
        if (strpos($pCoordinate,':') !==  false ||  strpos($pCoordinate,',') !==  false) {  
     * Selected cell by using numeric cell coordinates  
     * @param     int     $pColumn    Numeric column coordinate of the cell  
     * @param     int     $pRow        Numeric row coordinate of the cell  
     * @return PHPExcel_Worksheet   
     * @param boolean $value Right-to-left true/false  
     * @return PHPExcel_Worksheet   
     * Fill worksheet from values in array  
     * @param array $source    Source array  
     * @param mixed $nullValue Value treated as "null"  
     * @return PHPExcel_Worksheet   
    public function fromArray($source =  null, $nullValue =  null, $pCell =  'A1') {  
            $currentRow =  $startRow -  1;  
            foreach ($source as $rowData) {  
                $rowCount =  count($rowData);  
                for ($i =  0; $i <  $rowCount; ++ $i) {  
                    if ($rowData[$i] !=  $nullValue) {  
            throw  new Exception("Parameter \$source should be an array."); 
     * Create array from worksheet  
     * @param mixed $nullValue Value treated as "null"  
     * @param boolean $calculateFormulas Should formulas be calculated?  
    public function toArray($nullValue =  null, $calculateFormulas =  true) {  
        // Get worksheet dimension  
        for ($row =  $dimension[0][1]; $row <=  $dimension[1][1]; ++ $row) {  
            for ($column =  $dimension[0][0]; $column <=  $dimension[1][0]; ++ $column) {  
                        $returnValue[$row][$column] =  $cell->getValue()->getPlainText();  
                        if ($calculateFormulas) {  
                            $returnValue[$row][$column] =  $cell->getCalculatedValue();  
                            $returnValue[$row][$column] =  $cell->getValue();  
                    $style =  $this->_parent->getCellXfByIndex($cell->getXfIndex());  
                    $returnValue[$row][$column] =  $nullValue;  
     * @return PHPExcel_Worksheet_RowIterator   
     * Run PHPExcel garabage collector.  
     * @return PHPExcel_Worksheet   
        // Build a reference table from images  
        $imageCoordinates =  array();  
           while ($iterator->valid()) {  
               $imageCoordinates[$iterator->current()->getCoordinates()] =  true;  
        // Find cells that can be cleaned  
            if (is_null($cell->getValue()) ||  (!is_object($cell->getValue()) &&  $cell->getValue() ===  '' &&  !$cell->hasHyperlink())) {  
                if ($cell->getXfIndex() ==  0) {  
            if (isset ($imageCoordinates[$coordinate]) &&  $imageCoordinates[$coordinate] ===  true) {  
     * @return string    Hash code  
            //. $this->calculateWorksheetDimension()  
     * Note that this index may vary during script execution! Only reliable moment is  
     * while doing a write of a workbook and when changes are not allowed.  
     * @return string    Hash index  
     * Note that this index may vary during script execution! Only reliable moment is  
     * while doing a write of a workbook and when changes are not allowed.  
     * @param string    $value    Hash index  
     * Extract worksheet title from range.  
     * Example: extractSheetTitle('test!A1') ==> 'A1'  
     * Example: extractSheetTitle('test!A1', true) ==> array('test', 'A1');  
     * @param string $pRange    Range to extract title from  
     * @param bool $returnRange    Return range? (see example)  
        if (strpos($pRange, '!') ===  false) {  
        // Position of separator exclamation mark  
        $reference[0] =  substr($pRange, 0, $sep);  
        $reference[1] =  substr($pRange, $sep +  1);  
        // Strip possible enclosing single quotes  
        if (strpos($reference[0], '\'') ===  0) {  
            $reference[0] =  substr($reference[0], 1);  
        if (strrpos($reference[0], '\'') ===  strlen($reference[0]) -  1) {  
            $reference[0] =  substr($reference[0], 0, strlen($reference[0]) -  1);  
     * @param string $pCellCoordinate    Cell coordinate to get hyperlink for  
        // return hyperlink if we already have one  
        $cell =  $this->getCell($pCellCoordinate);  
     * @param string $pCellCoordinate    Cell coordinate to insert hyperlink  
     * @param     PHPExcel_Cell_Hyperlink    $pHyperlink   
     * @return PHPExcel_Worksheet   
    public function setHyperlink($pCellCoordinate =  'A1', PHPExcel_Cell_Hyperlink $pHyperlink =  null)  
        if ($pHyperlink ===  null) {  
            $pHyperlink->setParent($this->getCell($pCellCoordinate));  
     * Hyperlink at a specific coordinate exists?  
     * @param string $pCellCoordinate   
     * Get collection of hyperlinks  
     * @return PHPExcel_Cell_Hyperlink[]   
     * @param string $pCellCoordinate    Cell coordinate to get data validation for  
        // return data validation if we already have one  
        // else create data validation  
        $cell =  $this->getCell($pCellCoordinate);  
     * @param string $pCellCoordinate    Cell coordinate to insert data validation  
     * @param     PHPExcel_Cell_DataValidation    $pDataValidation   
     * @return PHPExcel_Worksheet   
    public function setDataValidation($pCellCoordinate =  'A1', PHPExcel_Cell_DataValidation $pDataValidation =  null)  
        if ($pDataValidation ===  null) {  
            $pDataValidation->setParent($this->getCell($pCellCoordinate));  
     * Data validation at a specific coordinate exists?  
     * @param string $pCellCoordinate   
     * Get collection of data validations  
     * @return PHPExcel_Cell_DataValidation[]   
     * Copy worksheet (!= clone!)  
     * @return PHPExcel_Worksheet   
     * Implement PHP __clone to create a deep clone, not just a shallow copy.  
        foreach ($this as $key =>  $val) {  
 
 
        
       |