Exemplo n.º 1
0
 /**
  * Run PHPExcel garabage collector.
  *
  * @return PHPExcel_Worksheet
  */
 public function garbageCollect()
 {
     // Flush cache
     $this->_cellCollection->getCacheData('A1');
     // Build a reference table from images
     //        $imageCoordinates = array();
     //        $iterator = $this->getDrawingCollection()->getIterator();
     //        while ($iterator->valid()) {
     //            $imageCoordinates[$iterator->current()->getCoordinates()] = true;
     //
     //            $iterator->next();
     //        }
     //
     // Lookup highest column and highest row if cells are cleaned
     $colRow = $this->_cellCollection->getHighestRowAndColumn();
     $highestRow = $colRow['row'];
     $highestColumn = PHPExcel_Cell::columnIndexFromString($colRow['column']);
     // Loop through column dimensions
     foreach ($this->_columnDimensions as $dimension) {
         $highestColumn = max($highestColumn, PHPExcel_Cell::columnIndexFromString($dimension->getColumnIndex()));
     }
     // Loop through row dimensions
     foreach ($this->_rowDimensions as $dimension) {
         $highestRow = max($highestRow, $dimension->getRowIndex());
     }
     // Cache values
     if ($highestColumn < 0) {
         $this->_cachedHighestColumn = 'A';
     } else {
         $this->_cachedHighestColumn = PHPExcel_Cell::stringFromColumnIndex(--$highestColumn);
     }
     $this->_cachedHighestRow = $highestRow;
     // Return
     return $this;
 }
Exemplo n.º 2
0
 /**
  * Run PHPExcel garabage collector.
  *
  * @return PHPExcel_Worksheet
  */
 public function garbageCollect()
 {
     // Flush cache
     $this->_cellCollection->getCacheData('A1');
     // Lookup highest column and highest row if cells are cleaned
     $colRow = $this->_cellCollection->getHighestRowAndColumn();
     $highestRow = $colRow['row'];
     $highestColumn = PHPExcel_Cell::columnIndexFromString($colRow['column']);
     // Loop through column dimensions
     foreach ($this->_columnDimensions as $dimension) {
         $highestColumn = max($highestColumn, PHPExcel_Cell::columnIndexFromString($dimension->getColumnIndex()));
     }
     // Loop through row dimensions
     foreach ($this->_rowDimensions as $dimension) {
         $highestRow = max($highestRow, $dimension->getRowIndex());
     }
     // Cache values
     if ($highestColumn < 0) {
         $this->_cachedHighestColumn = 'A';
     } else {
         $this->_cachedHighestColumn = PHPExcel_Cell::stringFromColumnIndex(--$highestColumn);
     }
     $this->_cachedHighestRow = $highestRow;
     return $this;
 }
Exemplo n.º 3
0
	/**
	 * Run PHPExcel garabage collector.
	 *
	 * @return PHPExcel_Worksheet
	 */
	public function garbageCollect() {
		// Build a reference table from images
		// $imageCoordinates = array();
		// $iterator = $this->getDrawingCollection()->getIterator();
		// while ($iterator->valid()) {
		// $imageCoordinates[$iterator->current()->getCoordinates()] = true;
		//
		// $iterator->next();
		// }
		//
		// Lookup highest column and highest row if cells are cleaned
		$highestColumn = - 1;
		$highestRow = 1;
		
		// Find cells that can be cleaned
		$col = $row = array ();
		foreach ( $this->_cellCollection->getCellList () as $coord ) {
			list ( $c, $r ) = sscanf ( $coord, '%[A-Z]%d' );
			$row [$r] = $r;
			$col [$c] = strlen ( $c ) . $c;
		}
		if (count ( $row ) > 0) {
			// Determine highest column and row
			$highestRow = max ( $row );
			$highestColumn = PHPExcel_Cell::columnIndexFromString ( substr ( max ( $col ), 1 ) );
		}
		
		// Loop through column dimensions
		foreach ( $this->_columnDimensions as $dimension ) {
			$highestColumn = max ( $highestColumn, PHPExcel_Cell::columnIndexFromString ( $dimension->getColumnIndex () ) );
		}
		
		// Loop through row dimensions
		foreach ( $this->_rowDimensions as $dimension ) {
			$highestRow = max ( $highestRow, $dimension->getRowIndex () );
		}
		
		// Cache values
		if ($highestColumn < 0) {
			$this->_cachedHighestColumn = 'A';
		} else {
			$this->_cachedHighestColumn = PHPExcel_Cell::stringFromColumnIndex ( -- $highestColumn );
		}
		$this->_cachedHighestRow = $highestRow;
		
		// Return
		return $this;
	}
Exemplo n.º 4
0
 /**
  * Run PHPExcel garabage collector.
  *
  * @return PHPExcel_Worksheet
  */
 public function garbageCollect()
 {
     // Build a reference table from images
     $imageCoordinates = array();
     $iterator = $this->getDrawingCollection()->getIterator();
     while ($iterator->valid()) {
         $imageCoordinates[$iterator->current()->getCoordinates()] = true;
         $iterator->next();
     }
     // Lookup highest column and highest row if cells are cleaned
     $highestColumn = -1;
     $highestRow = 1;
     // Find cells that can be cleaned
     foreach ($this->_cellCollection->getCellList() as $coordinate) {
         preg_match('/^(\\w+)(\\d+)$/U', $coordinate, $matches);
         list(, $col, $row) = $matches;
         $column = PHPExcel_Cell::columnIndexFromString($col);
         // Determine highest column and row
         if ($highestColumn < $column) {
             $highestColumn = $column;
         }
         if ($row > $highestRow) {
             $highestRow = $row;
         }
     }
     // Loop through column dimensions
     foreach ($this->_columnDimensions as $dimension) {
         if ($highestColumn < PHPExcel_Cell::columnIndexFromString($dimension->getColumnIndex())) {
             $highestColumn = PHPExcel_Cell::columnIndexFromString($dimension->getColumnIndex());
         }
     }
     // Loop through row dimensions
     foreach ($this->_rowDimensions as $dimension) {
         if ($highestRow < $dimension->getRowIndex()) {
             $highestRow = $dimension->getRowIndex();
         }
     }
     // Cache values
     if ($highestColumn < 0) {
         $this->_cachedHighestColumn = 'A';
     } else {
         $this->_cachedHighestColumn = PHPExcel_Cell::stringFromColumnIndex(--$highestColumn);
     }
     $this->_cachedHighestRow = $highestRow;
     // Return
     return $this;
 }
Exemplo n.º 5
0
 /**
  * Run PHPExcel garabage collector.
  *
  * @return PHPExcel_Worksheet
  */
 public function garbageCollect()
 {
     // Build a reference table from images
     $imageCoordinates = array();
     $iterator = $this->getDrawingCollection()->getIterator();
     while ($iterator->valid()) {
         $imageCoordinates[$iterator->current()->getCoordinates()] = true;
         $iterator->next();
     }
     // Lookup highest column and highest row if cells are cleaned
     $highestColumn = -1;
     $highestRow = 1;
     // Find cells that can be cleaned
     foreach ($this->_cellCollection->getCellList() as $coordinate) {
         $cell = $this->getCell($coordinate);
         // Can be cleaned?
         $canBeCleaned = false;
         /* Excel doesn't remove such empty cells
         			// Empty value?
             		if (is_null($cell->getValue()) || (!is_object($cell->getValue()) && $cell->getValue() === '' && !$cell->hasHyperlink())) {
         				// default style ?
         				if ($cell->getXfIndex() == 0) {
         					$canBeCleaned = true;
         				}
             		}
         			*/
         // Referenced in image?
         if (isset($imageCoordinates[$coordinate]) && $imageCoordinates[$coordinate] === true) {
             $canBeCleaned = false;
         }
         // Clean?
         if ($canBeCleaned) {
             // Remove the cell
             $this->_cellCollection->deleteCacheData($coordinate);
         } else {
             // Determine highest column and row
             if ($highestColumn < PHPExcel_Cell::columnIndexFromString($cell->getColumn())) {
                 $highestColumn = PHPExcel_Cell::columnIndexFromString($cell->getColumn());
             }
             if ($cell->getRow() > $highestRow) {
                 $highestRow = $cell->getRow();
             }
         }
     }
     // Loop through column dimensions
     foreach ($this->_columnDimensions as $dimension) {
         if ($highestColumn < PHPExcel_Cell::columnIndexFromString($dimension->getColumnIndex())) {
             $highestColumn = PHPExcel_Cell::columnIndexFromString($dimension->getColumnIndex());
         }
     }
     // Loop through row dimensions
     foreach ($this->_rowDimensions as $dimension) {
         if ($highestRow < $dimension->getRowIndex()) {
             $highestRow = $dimension->getRowIndex();
         }
     }
     // Cache values
     if ($highestColumn < 0) {
         $this->_cachedHighestColumn = 'A';
     } else {
         $this->_cachedHighestColumn = PHPExcel_Cell::stringFromColumnIndex(--$highestColumn);
     }
     $this->_cachedHighestRow = $highestRow;
     // Return
     return $this;
 }