Class: MergedCellRanges

Core.SpreadsheetEditor. MergedCellRanges

Encapsulates functionality for managing merged cell regions within an Spreadsheet Editor. It provides methods to add, remove, and retrieve merged cell regions.

new MergedCellRanges()

Members


count

Gets the index of the first non-empty cell within the row. This property allows for the identification of the starting point of data or formatting within a specific row of an Excel sheet, facilitating operations that depend on the row's content range.

Methods


getIntersectingMergedRanges(cellRange)

Retrieves all merged cell regions that intersect with the specified cell range.
Parameters:
Name Type Description
cellRange Core.SpreadsheetEditor.CellRange The cell range to check for intersections with merged regions.
Returns:
An array of CellRange objects representing merged regions that intersect with the specified range.
Type
Array.<Core.SpreadsheetEditor.CellRange>
Example
const { Core } = window.getInstance();
const workbook = Core.documentViewer.getDocument().getSpreadsheetEditorDocument().getWorkbook();
const sheet = workbook.getSheet('Invoice');
const mergedCellRanges = sheet.mergedCellRanges;
const cellRange = new (Core.SpreadsheetEditor).CellRange(
  {
    firstRow: 0,
    lastRow: 3,
    firstColumn: 1,
    lastColumn: 4
  }
);
const intersectingRanges = mergedCellRanges.getIntersectingMergedRanges(cellRange);

isRangeMerged(cellRange)

Determines if the specified cell range is already merged as a single region.
Parameters:
Name Type Description
cellRange Core.SpreadsheetEditor.CellRange The cell range to check if it is completely merged.
Returns:
Returns true if the cell range exactly matches an existing merged region, false otherwise.
Type
boolean
Example
const { Core } = window.getInstance();
const workbook = Core.documentViewer.getDocument().getSpreadsheetEditorDocument().getWorkbook();
const sheet = workbook.getSheet('Invoice');
const mergedCellRanges = sheet.mergedCellRanges;
const cellRange = new (Core.SpreadsheetEditor).CellRange(
  {
    firstRow: 0,
    lastRow: 3,
    firstColumn: 1,
    lastColumn: 4
  }
);
const isMerged = mergedCellRanges.isRangeMerged(cellRange);

mergeRange(cellRange)

Merges the specified cell range and any intersecting merged regions into a single merged region. If the specified range intersects with existing merged regions, those regions are removed and a new merged region encompassing all affected cells is created.
Parameters:
Name Type Description
cellRange Core.SpreadsheetEditor.CellRange The cell range to merge, along with any intersecting regions.
Returns:
This method does not return a value. It modifies the state of the merged cell regions.
Type
void
Example
const { Core } = window.getInstance();
const workbook = Core.documentViewer.getDocument().getSpreadsheetEditorDocument().getWorkbook();
const sheet = workbook.getSheet('Invoice');
const mergedCellRanges = sheet.mergedCellRanges;
const cellRange = new (Core.SpreadsheetEditor).CellRange(
  {
    firstRow: 0,
    lastRow: 3,
    firstColumn: 1,
    lastColumn: 4
  }
);
mergedCellRanges.mergeRange(cellRange);

unmergeRange(cellRange)

Removes the merge from the specified cell range if it exactly matches an existing merged region.
Parameters:
Name Type Description
cellRange Core.SpreadsheetEditor.CellRange The cell range to unmerge.
Returns:
This method does not return a value. It modifies the state of the merged cell regions.
Type
void
Example
const { Core } = window.getInstance();
const workbook = Core.documentViewer.getDocument().getSpreadsheetEditorDocument().getWorkbook();
const sheet = workbook.getSheet('Invoice');
const mergedCellRanges = sheet.mergedCellRanges;
const cellRange = new (Core.SpreadsheetEditor).CellRange(
  {
    firstRow: 0,
    lastRow: 3,
    firstColumn: 1,
    lastColumn: 4
  }
);
mergedCellRanges.unmergeRange(cellRange);