:call-seq:
 merge_cells(first_row, first_col, last_row, last_col)

 This is an Excel97/2000 method. It is required to perform more complicated
 merging than the normal align merge in Format.pm
962056
def merge_cells(*args) #:nodoc:
    # Check for a cell reference in A1 notation and substitute row and column
    args = row_col_notation(args)

    record  = 0x00E5                    # Record identifier
    length  = 0x000A                    # Bytes to follow

    cref     = 1                        # Number of refs
    rwFirst  = args[0]                  # First row in reference
    colFirst = args[1]                  # First col in reference
    rwLast   = args[2] || rwFirst       # Last  row in reference
    colLast  = args[3] || colFirst      # Last  col in reference

    # Excel doesn't allow a single cell to be merged
    return if rwFirst == rwLast and colFirst == colLast

    # Swap last row/col with first row/col as necessary
    rwFirst,  rwLast  = rwLast,  rwFirst  if rwFirst  > rwLast
    colFirst, colLast = colLast, colFirst if colFirst > colLast

    store_simple(record, length, cref, rwFirst, rwLast, colFirst, colLast)
  end
61050
def align(time, time2, magnitude, magnitude2, error, error2):
    

    error = np.zeros(time.shape) if error is None else error
    error2 = np.zeros(time2.shape) if error2 is None else error2

    # this asume that the first series is the short one
    sserie = pd.DataFrame({"mag": magnitude, "error": error}, index=time)
    lserie = pd.DataFrame({"mag": magnitude2, "error": error2}, index=time2)

    # if the second serie is logest then revert
    if len(time) > len(time2):
        sserie, lserie = lserie, sserie

    # make the merge
    merged = sserie.join(lserie, how="inner", rsuffix='2')

    # recreate columns
    new_time = merged.index.values
    new_mag, new_mag2 = merged.mag.values, merged.mag2.values
    new_error, new_error2 = merged.error.values, merged.error2.values

    if len(time) > len(time2):
        new_mag, new_mag2 = new_mag2, new_mag
        new_error, new_error2 = new_error2, new_error

    return new_time, new_mag, new_mag2, new_error, new_error2
1258639
def _format_multicolumn(self, row, ilevels):
        
        """
        row2 = list(row[:ilevels])
        ncol = 1
        coltext = ''

        def append_col():
            # write multicolumn if needed
            if ncol > 1:
                row2.append('\\multicolumn{{{ncol:d}}}{{{fmt:s}}}{{{txt:s}}}'
                            .format(ncol=ncol, fmt=self.multicolumn_format,
                                    txt=coltext.strip()))
            # don't modify where not needed
            else:
                row2.append(coltext)
        for c in row[ilevels:]:
            # if next col has text, write the previous
            if c.strip():
                if coltext:
                    append_col()
                coltext = c
                ncol = 1
            # if not, add it to the previous multicolumn
            else:
                ncol += 1
        # write last column name
        if coltext:
            append_col()
        return row2
282605
private function _writeMergedCells()
	{
		$mergeCells = $this->_phpSheet->getMergeCells();
		$countMergeCells = count($mergeCells);

		if ($countMergeCells == 0) {
			return;
		}

		// maximum allowed number of merged cells per record
		$maxCountMergeCellsPerRecord = 1027;

		// record identifier
		$record = 0x00E5;

		// counter for total number of merged cells treated so far by the writer
		$i = 0;

		// counter for number of merged cells written in record currently being written
		$j = 0;

		// initialize record data
		$recordData = '';

		// loop through the merged cells
		foreach ($mergeCells as $mergeCell) {
			++$i;
			++$j;

			// extract the row and column indexes
			$range = PHPExcel_Cell::splitRange($mergeCell);
			list($first, $last) = $range[0];
			list($firstColumn, $firstRow) = PHPExcel_Cell::coordinateFromString($first);
			list($lastColumn, $lastRow) = PHPExcel_Cell::coordinateFromString($last);

			$recordData .= pack('vvvv', $firstRow - 1, $lastRow - 1, PHPExcel_Cell::columnIndexFromString($firstColumn) - 1, PHPExcel_Cell::columnIndexFromString($lastColumn) - 1);

			// flush record if we have reached limit for number of merged cells, or reached final merged cell
			if ($j == $maxCountMergeCellsPerRecord or $i == $countMergeCells) {
				$recordData = pack('v', $j) . $recordData;
				$length = strlen($recordData);
				$header = pack('vv', $record, $length);
				$this->_append($header . $recordData);

				// initialize for next record, if any
				$recordData = '';
				$j = 0;
			}
		}
	}
54467
public void setCellMerge(final int colIndex, final int rowMerge, final int columnMerge) throws IOException {
        if (rowMerge <= 0 || columnMerge <= 0) return;
        if (rowMerge <= 1 && columnMerge <= 1) return;

        this.parent.setCellMerge(this.rowIndex, colIndex, rowMerge, columnMerge);
    }
512801
def concat_align(fastas):
    
    # read in sequences
    fa2len = {}
    seqs = {}
    IDs = []
    for fasta in fastas:
        seqs[fasta] = {}
        for seq in parse_fasta(fasta):
            ID = seq[0].split('>')[1].split()[0]
            IDs.append(ID)
            seqs[fasta][ID] = seq[1]
        fa2len[fasta] = len(seq[1])
    # concat sequences
    IDs = set(IDs)
    concat = {}
    for fasta in fastas:
        for ID in IDs:
            if ID not in concat:
                concat[ID] = []
            if ID not in seqs[fasta]:
                concat[ID].append('-'*fa2len[fasta])
            else:
                concat[ID].append(seqs[fasta][ID])
    return concat
143427
function(cell1,cell2){
		if(!cell1.room || !cell2.room || cell1.room===cell2.room){ return;}
		var merged, keep;
		var tcell1 = cell1.room.top;
		var tcell2 = cell2.room.top;
		if(tcell1.bx>tcell2.bx || (tcell1.bx===tcell2.bx && tcell1.by>tcell2.by)){ merged = tcell1; keep = tcell2;}
		else                                                                     { merged = tcell2; keep = tcell1;}

		// 消える部屋のほうの数字を消す
		if(merged.isNum()){
			// 数字が消える部屋にしかない場合 -> 残るほうに移動させる
			if(keep.noNum()){
				keep.setQnum(merged.qnum);
				keep.draw();
			}
			merged.setQnum(-1);
			merged.draw();
		}
	}
290346
public static int mergingCells(Sheet sheet, int firstRow, int lastRow, int firstColumn, int lastColumn, CellStyle cellStyle) {
		final CellRangeAddress cellRangeAddress = new CellRangeAddress(//
				firstRow, // first row (0-based)
				lastRow, // last row (0-based)
				firstColumn, // first column (0-based)
				lastColumn // last column (0-based)
		);

		if (null != cellStyle) {
			RegionUtil.setBorderTop(cellStyle.getBorderTopEnum(), cellRangeAddress, sheet);
			RegionUtil.setBorderRight(cellStyle.getBorderRightEnum(), cellRangeAddress, sheet);
			RegionUtil.setBorderBottom(cellStyle.getBorderBottomEnum(), cellRangeAddress, sheet);
			RegionUtil.setBorderLeft(cellStyle.getBorderLeftEnum(), cellRangeAddress, sheet);
		}
		return sheet.addMergedRegion(cellRangeAddress);
	}
648778
def cell_to_rowcol(cell)       #:nodoc:
    cell =~ /\$?([A-I]?[A-Z])\$?(\d+)/
    col     = $1
    row     = $2.to_i

    col = chars_to_col($1.split(//))

    # Convert 1-index to zero-index
    row -= 1
    col -= 1

    [row, col]
  end
36949
def merged_cell_ranges(self):
    
    for rlo, rhi, clo, chi in self.raw_sheet.merged_cells:
      yield ((clo, rlo), (chi, rhi))
900555
def _merge_last(values, merge_after, merge_with=' '):
    '''
    
    '''
    if len(values) > merge_after:
        values = values[0:(merge_after-1)] + [merge_with.join(values[(merge_after-1):])]

    return values
439996
def cell(self, row_idx, col_idx):
        
        cell_idx = col_idx + (row_idx * self._column_count)
        return self._cells[cell_idx]
888792
public void setCellMerge(final int rowIndex, final int colIndex, final int rowMerge,
                             final int columnMerge) throws IOException {
        this.builder.setCellMerge(this, this.appender, rowIndex, colIndex, rowMerge, columnMerge);
    }
259823
void cell(Cell cell) {
        int left = cell.getLeft();
        int right = cell.getRight();
        // first see if we've got a cell past the last col
        if (right > realColumnCount) {
            // are we past last col entirely?
            if (left == realColumnCount) {
                // single col?
                if (left + 1 != right) {
                    appendColumnRange(new ColumnRange(cell.elementName(), cell, left + 1, right));
                }
                realColumnCount = right;
                return;
            } else {
                // not past entirely
                appendColumnRange(new ColumnRange(cell.elementName(), cell, realColumnCount, right));                
                realColumnCount = right;
            }
        }
        while (currentColRange != null) {
            int hit = currentColRange.hits(left);
            if (hit == 0) {
                ColumnRange newRange = currentColRange.removeColumn(left);
                if (newRange == null) {
                    // zap a list item
                    if (previousColRange != null) {
                        previousColRange.setNext(currentColRange.getNext());
                    }
                    if (first == currentColRange) {
                        first = currentColRange.getNext();
                    }
                    if (last == currentColRange) {
                        last = previousColRange;
                    }
                    currentColRange = currentColRange.getNext();
                } else {
                    if (last == currentColRange) {
                        last = newRange;
                    }
                    currentColRange = newRange;
                }
                return;
            } else if (hit == -1) {
                return;
            } else if (hit == 1) {
                previousColRange = currentColRange;
                currentColRange = currentColRange.getNext();                                
            }
        }
    }
1355306
private void mergeCols(ExcelRows excelRowsAnn, Cell templateCell, int itemSize) {
        val tmplRowIndexRef = templateCell.getRowIndex() + 1;
        for (val mergeColAnn : excelRowsAnn.mergeCols()) {
            val from = PoiUtil.findCell(sheet, mergeColAnn.fromColRef() + tmplRowIndexRef);
            val to = PoiUtil.findCell(sheet, mergeColAnn.toColRef() + tmplRowIndexRef);

            val fromRow = from.getRowIndex();
            val fromCol = from.getColumnIndex();
            val toCol = to.getColumnIndex();

            for (int i = fromRow; i < fromRow + itemSize; ++i) {
                sheet.addMergedRegion(new CellRangeAddress(i, i, fromCol, toCol));
            }
        }
    }
912077
def apply
      first_cell, last_cell = range.split(':')
      start_point = Axlsx::name_to_indices(first_cell)
      end_point = Axlsx::name_to_indices(last_cell)
      # The +1 is so we skip the header row with the filter drop downs
      rows = worksheet.rows[(start_point.last+1)..end_point.last] || []

      column_offset = start_point.first
      columns.each do |column|
        rows.each do |row|
          next if row.hidden
          column.apply(row, column_offset)
        end
      end
    end
1019022
def merge(self, query):
        
        self.columns += query.columns
        self.joins += query.joins
        self.wheres += query.wheres
        self.groups += query.groups
        self.havings += query.havings
        self.orders += query.orders
        self.distinct_ = query.distinct_

        if self.columns:
            self.columns = Collection(self.columns).unique().all()

        if query.limit_:
            self.limit_ = query.limit_

        if query.offset_:
            self.offset_ = None

        self.unions += query.unions

        if query.union_limit:
            self.union_limit = query.union_limit

        if query.union_offset:
            self.union_offset = query.union_offset

        self.union_orders += query.union_orders

        self.merge_bindings(query)