merge method

void merge()

Set Merge Combines the contents of the selected cells in a new larger cell.

 Workbook workbook = new Workbook();
 Worksheet sheet = workbook.worksheets[0];
 Range range1 = sheet.getRangeByName('A1:D4');
 //Merging cells
 range1.merge();
 List<int> bytes = workbook.saveAsStream();
 File('Merge.xlsx').writeAsBytes(bytes);
 workbook.dispose();

Implementation

void merge() {
  if (isSingleRange) {
    return;
  } else {
    int countRow = 0;
    int countCol = 0;
    // ignore: prefer_final_locals
    for (int iRow = row, iLastRow = lastRow; iRow <= iLastRow; iRow++) {
      countRow = countRow + 1;
    }
    // ignore: prefer_final_locals
    for (int iCol = column, iLastCol = lastColumn; iCol <= iLastCol; iCol++) {
      countCol = countCol + 1;
    }
    final Range range = worksheet.getRangeByIndex(row, column);
    range.rowSpan = countRow;
    range.columnSpan = countCol;
  }
}