Class: Sheet

Core.SpreadsheetEditor. Sheet

Represents a Sheet in the spreadsheet editor that encapsulates the functionalities of a single sheet within a workbook. The creation of sheets follows a factory pattern so you must use Workbook.createSheet rather than constructing directly.

new Sheet()

Properties:
Name Type Description
rowsCount number Gets the number rows in a sheet.
name string Gets the sheet name.
mergedCellRanges Core.SpreadsheetEditor.MergedCellRanges Gets the merged cell ranges in a sheet.
columnsCount number Gets the number of columns in a sheet.
defaultColumnWidth number Gets the default column width in pixels.
defaultRowHeight number Gets the default row height in pixels.

Methods


createColumns(columnIndex, count)

Creates new columns and inserts them at the specified index within the sheet.
Parameters:
Name Type Description
columnIndex Number A zero-based index at which to start inserting the created columns.
count Number The number of columns to create.
Returns:
Type
void

createRows(rowIndex, count)

Creates new rows with the start point at the specified index, and the count of rows to create.
Parameters:
Name Type Description
rowIndex number A zero-based index at which the new rows will be inserted.
count number The number of rows to create.
Returns:
An array of rows created.
Type
Array.<Core.SpreadsheetEditor.Row>

getCellAt(rowIndex, columnIndex)

Retrieves the cell at the specified row and column index within the sheet. If the cell does not exist, it will be created.
Parameters:
Name Type Description
rowIndex A zero-based index of the row.
columnIndex A zero-based index of the column.
Returns:
The cell at the specified row and column index.
Type
Core.SpreadsheetEditor.Cell

getColumnWidthInPixel(columnIndex)

Retrieves the width of a specified column within the sheet.
Parameters:
Name Type Description
columnIndex Number A zero-based index of the column whose width is to be retrieved.
Returns:
The width of the specified column in pixels.
Type
Number

getRowAt(rowIndex)

Retrieves the row at the specified index within the sheet.
Parameters:
Name Type Description
rowIndex A zero-based index of the row to retrieve from the sheet.
Returns:
The row at the specified index.
Type
Core.SpreadsheetEditor.Row

getRowHeightInPixel(rowIndex)

Retrieves the height of a specified row within the sheet.
Parameters:
Name Type Description
rowIndex Number A zero-based index of the row whose height is to be retrieved.
Returns:
The height of the specified row in pixels.
Type
Number

removeColumns(columnIndex, count)

Removes a specific number of columns from a sheet, starting from a given index.
Parameters:
Name Type Description
columnIndex Number A zero-based index to start removing columns at.
count Number The number of columns to remove.
Returns:
Type
void

removeRows(rowIndex, count)

Removes a specific number of rows from a sheet, starting from a given index.
Parameters:
Name Type Description
rowIndex Number A zero-based index to start removing rows at.
count Number The number of rows to remove.
Returns:
Type
void

setCellRangeBorder(range, border)

Sets the border style for a specified border of the cell range.
Parameters:
Name Type Description
range Core.SpreadsheetEditor.CellRange The CellRange to update.
border Core.SpreadsheetEditor.Types.BorderOptions
Returns:
Type
void
Example
const { Core } = window.getInstance();
const CellRange = Core.SpreadsheetEditor.CellRange;
const workbook = Core.documentViewer.getDocument().getSpreadsheetEditorDocument().getWorkbook();
const sheet = workbook.getSheet('Invoice');
const cellBorder = {
  type: 'Top',
  style: 'Medium',
  color: 'Red'
};
const range = new CellRange({ firstRow: 3, lastRow: 4, firstColumn: 5, lastColumn: 7 });
sheet.setCellRangeBorder(range, cellBorder);

setCellRangeStyle(range, style)

Applies a cell style to a specified range of cells within the sheet.
Parameters:
Name Type Description
range Core.SpreadsheetEditor.CellRange A CellRange object that defines the range of cells to which the cell style will be applied.
style Core.SpreadsheetEditor.CellStyle A CellStyle object with the style to be applied to a cell range in its properties.
Example
const { Core } = window.getInstance();
const CellRange = Core.SpreadsheetEditor.CellRange;
const workbook = Core.documentViewer.getDocument().getSpreadsheetEditorDocument().getWorkbook();
const sheet = workbook.getSheet('Invoice');
const cellStyle = workbook.createCellStyle({
  backgroundColor: 'red',
  verticalAlignment: 1,
  horizontalAlignment: 1,
  wrapText: 2,
});
const range = new CellRange({ firstRow: 3, lastRow: 4, firstColumn: 5, lastColumn: 7 });
sheet.setCellRangeStyle(range, cellStyle);

setColumnWidthInPixel(columnIndex, width)

Adjusts the width of a specified column within the sheet, measured in pixels.
Parameters:
Name Type Description
columnIndex Number A zero-based index of the column.
width Number The new width, in pixels.

setRowHeightInPixel(rowIndex, height)

Adjusts the height of a specified row within the sheet, measured in pixels.
Parameters:
Name Type Description
rowIndex Number A zero-based index of the row.
height Number The new height, in pixels.
Returns:
Type
void