Imperative Spreadsheet API
As an escape hatch, we bundle an imperative API for the Spreadsheet to control spreadsheet states
Imperative API is helpful when you want to trigger state changes without having to modify spreadsheet state manually. These APIs can do multiple actions in one function call
How to use
Wrap your Spreadsheet in
SpreadsheetProvider
Make sure you have handlers for callbacks such as
onChange
Batch updating Spreadsheet values
For batch update of values, we recommend using setValues
API, so only 1 undo/redo history will be added
Spreadsheet
getSheet(sheetId: number)
setActiveSheet(sheetId: number)
getActiveSheet()
insertSheet()
Sheet
setActiveCell(cell: CellInterface)
setSelections(selections: GridRange)
setRowHeight(rowIndex: number, dimension: number)
setColumnWidth(columnIndex: number, dimension: number)
getActiveCell()
getSelections()
getSheetId()
getRange(range: GridRange | CellInterface)
hideRow(rowIndexes: number[])
hideColumn(columnIndexes: number[])
showRow(rowIndexes: number[])
showColumn(columnIndexes: number[])
deleteRow(rowIndexes: number[])
deleteColumn(columnIndexes: number[])
insertRow(rowIndex: number, numRows = 1)
insertColumn(columnIndex: number, numColumns = 1)
moveRows(rowIndexes: number[], destinationRow: number)
moveColumns(columnIndexes: number[], destinationColumn: number)
onRequestSearch()
sortRange( selections: SelectionArea[], sortOrder: SortOrder )
sortColumn(columnIndex: number, sortOrder: SortOrder)
CellRange
setValue(text: string)
setValues(values: string[][])
clearFormatting()
setFormat(type: T, value: FormattingValue)
delete()
Last updated