unMerge method
unMerge the merged cells.
var sheet = 'DesiredSheet';
List<String> spannedCells = excel.getMergedCells(sheet);
var cellToUnMerge = "A1:A2";
excel.unMerge(sheet, cellToUnMerge);
Implementation
unMerge(String unmergeCells) {
if (_spannedItems.isNotEmpty &&
_spanList.isNotEmpty &&
_spannedItems.contains(unmergeCells)) {
List<String> lis = unmergeCells.split(RegExp(r":"));
if (lis.length == 2) {
bool remove = false;
List<int> start, end;
start =
_cellCoordsFromCellId(lis[0]); // [x,y] => [startRow, startColumn]
end = _cellCoordsFromCellId(lis[1]); // [x,y] => [endRow, endColumn]
for (int i = 0; i < _spanList.length; i++) {
_Span? spanObject = _spanList[i];
if (spanObject == null) {
continue;
}
if (spanObject.columnSpanStart == start[1] &&
spanObject.rowSpanStart == start[0] &&
spanObject.columnSpanEnd == end[1] &&
spanObject.rowSpanEnd == end[0]) {
_spanList[i] = null;
remove = true;
}
}
if (remove) {
_cleanUpSpanMap();
}
}
_spannedItems.remove(unmergeCells);
_excel._mergeChangeLookup = sheetName;
}
}