Exemple #1
0
 /**
  * Get the shared style component for the currently active cell in currently active sheet.
  * Only used for style supervisor
  *
  * @return Style_Borders
  */
 public function getSharedComponent()
 {
     return $this->_parent->getSharedComponent()->getBorders();
 }
Exemple #2
0
 /**
  * Get the shared style component for the currently active cell in currently active sheet.
  * Only used for style supervisor
  *
  * @return Style_Protection
  */
 public function getSharedComponent()
 {
     return $this->_parent->getSharedComponent()->getProtection();
 }
Exemple #3
0
 /**
  * Get the shared style component for the currently active cell in currently active sheet.
  * Only used for style supervisor
  *
  * @return Style_Alignment
  */
 public function getSharedComponent()
 {
     return $this->_parent->getSharedComponent()->getAlignment();
 }
Exemple #4
0
 /**
  * Duplicate cell style to a range of cells
  *
  * Please note that this will overwrite existing cell styles for cells in range!
  *
  * @param 	Style	$pCellStyle	Cell style to duplicate
  * @param 	string			$pRange		Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1")
  * @throws	Exception
  * @return Worksheet
  */
 public function duplicateStyle(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
     $workbook = $this->_parent;
     if ($existingStyle = $this->_parent->getCellXfByHashCode($pCellStyle->getHashCode())) {
         // there is already such cell Xf in our collection
         $xfIndex = $existingStyle->getIndex();
     } else {
         // we don't have such a cell Xf, need to add
         $workbook->addCellXf($pCellStyle);
         $xfIndex = $pCellStyle->getIndex();
     }
     // Uppercase coordinate
     $pRange = strtoupper($pRange);
     // Is it a cell range or a single cell?
     $rangeA = '';
     $rangeB = '';
     if (strpos($pRange, ':') === false) {
         $rangeA = $pRange;
         $rangeB = $pRange;
     } else {
         list($rangeA, $rangeB) = explode(':', $pRange);
     }
     // Calculate range outer borders
     $rangeStart = Cell::coordinateFromString($rangeA);
     $rangeEnd = Cell::coordinateFromString($rangeB);
     // Translate column into index
     $rangeStart[0] = Cell::columnIndexFromString($rangeStart[0]) - 1;
     $rangeEnd[0] = Cell::columnIndexFromString($rangeEnd[0]) - 1;
     // Make sure we can loop upwards on rows and columns
     if ($rangeStart[0] > $rangeEnd[0] && $rangeStart[1] > $rangeEnd[1]) {
         $tmp = $rangeStart;
         $rangeStart = $rangeEnd;
         $rangeEnd = $tmp;
     }
     // Loop through cells and apply styles
     for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) {
         for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) {
             $this->getCell(Cell::stringFromColumnIndex($col) . $row)->setXfIndex($xfIndex);
         }
     }
     return $this;
 }
 /**
  * Duplicate cell style to a range of cells
  *
  * Please note that this will overwrite existing cell styles for cells in range!
  *
  * @param Style $pCellStyle Cell style to duplicate
  * @param string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1")
  * @throws Exception
  * @return Worksheet
  */
 public function duplicateStyle(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
     $workbook = $this->parent;
     if ($existingStyle = $this->parent->getCellXfByHashCode($pCellStyle->getHashCode())) {
         // there is already such cell Xf in our collection
         $xfIndex = $existingStyle->getIndex();
     } else {
         // we don't have such a cell Xf, need to add
         $workbook->addCellXf($pCellStyle);
         $xfIndex = $pCellStyle->getIndex();
     }
     // Calculate range outer borders
     list($rangeStart, $rangeEnd) = Cell::rangeBoundaries($pRange . ':' . $pRange);
     // Make sure we can loop upwards on rows and columns
     if ($rangeStart[0] > $rangeEnd[0] && $rangeStart[1] > $rangeEnd[1]) {
         $tmp = $rangeStart;
         $rangeStart = $rangeEnd;
         $rangeEnd = $tmp;
     }
     // Loop through cells and apply styles
     for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) {
         for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) {
             $this->getCell(Cell::stringFromColumnIndex($col - 1) . $row)->setXfIndex($xfIndex);
         }
     }
     return $this;
 }
Exemple #6
0
 /**
  * Get the shared style component for the currently active cell in currently active sheet.
  * Only used for style supervisor
  *
  * @return Style_NumberFormat
  */
 public function getSharedComponent()
 {
     return $this->_parent->getSharedComponent()->getNumberFormat();
 }