API overview
Constructor
const spreadsheet = new dhx.Spreadsheet("spreadsheet_container", {
rowsCount: 20,
colsCount: 20
});
Parameters:
- an HTML container (or the ID of an HTML container)
- a hash of config options (check below)
Spreadsheet methods
Name | Description |
---|---|
addColumn() | Adds a new column into the spreadsheet |
addRow() | Adds a new row into the spreadsheet |
addSheet() | Adds a new sheet into the spreadsheet |
clear() | Clears a spreadsheet |
clearSheet() | Clears a sheet |
deleteColumn() | Removes a column from the spreadsheet |
deleteRow() | Removes a row from the spreadsheet |
eachCell() | Iterates cells in the spreadsheet |
endEdit() | Finishes editing in the selected cell, closes editor and saves the entered value |
fitColumn() | adjusts the width of the column to match the longest value in the column |
getActiveSheet() | Returns the sheet that is currently active |
getFilter() | Returns an object with criteria specified for data filtering |
getFormat() | Returns the number format applied to the value of a cell |
getFormula() | Returns the formula of a cell |
getSheets() | Gets all sheets of the spreadsheet |
getStyle() | Returns styles applied to a cell(s) |
getValue() | Returns the value(s) of a cell(s) |
hideSearch() | hides the search bar |
insertLink() | inserts/removes a hyperlink in a cell |
isLocked() | Checks whether a cell(s) is(are) locked |
load() | Loads data from an external file |
lock() | Locks the specified cell |
mergeCells() | merges a range of cells into one or splits merged cells |
parse() | Loads data into spreadsheet from a local data source |
redo() | Applies the reverted action once again |
removeSheet() | Removes a sheet from the spreadsheet by its id |
serialize() | Serializes data of spreadsheet into a JSON object |
search() | searches for cells by the specified parameters |
setActiveSheet() | Sets the active sheet by its id |
setFilter() | Filters data in the spreadsheet by the specified criteria |
setFormat() | Sets a specified format to the value of a cell |
setStyle() | Sets style to a cell(s) |
setValidation() | Sets validation for cells via adding drop-down lists into the cells |
setValue() | Sets a value for a cell |
startEdit() | Starts editing in the selected cell |
undo() | Reverts the latest action |
unlock() | Unlocks a locked cell(s) |
Spreadsheet events
Name | Description |
---|---|
afterAction | Fires after an action is executed |
afterClear | Fires after a spreadsheet is cleared |
afterColumnAdd | Fires after a new column is added |
afterColumnDelete | Fires after a column is deleted |
afterEditEnd | Fires after editing of a cell is finished |
afterEditStart | Fires after editing of a cell has started |
afterFocusSet | Fires after focus is set on a cell |
afterFormatChange | Fires after the format of a cell is changed |
afterRowAdd | Fires after a new row is added |
afterRowDelete | Fires after a row is deleted |
afterSelectionSet | Fires after cells are selected |
afterSheetAdd | Fires after a new sheet is added |
afterSheetChange | Fires after the currently active sheet is changed |
afterSheetClear | Fires after a sheet of the spreadsheet is cleared |
afterSheetRemove | Fires after a sheet is removed |
afterSheetRename | Fires after a sheet is renamed |
afterStyleChange | Fires after the style of a cell is changed |
afterValueChange | Fires after the value of a cell changes |
beforeAction | Fires before an action is executed |
beforeClear | Fires before a spreadsheet is cleared |
beforeColumnAdd | Fires before a new column is added |
beforeColumnDelete | Fires before a column is deleted |
beforeEditEnd | Fires before editing of a cell is finished |
beforeEditStart | Fires before editing of a cell has started |
beforeFocusSet | Fires before focus is set on a cell |
beforeFormatChange | Fires before the format of a cell is changed |
beforeRowAdd | Fires before a new row is added |
beforeRowDelete | Fires before a row is deleted |
beforeSelectionSet | Fires before cells are selected |
beforeSheetAdd | Fires before a new sheet is added |
beforeSheetChange | Fires before changing the currently active sheet |
beforeSheetClear | Fires before a sheet of the spreadsheet is cleared |
beforeSheetRemove | Fires before a sheet is removed |
beforeSheetRename | Fires before a sheet is renamed |
beforeStyleChange | Fires before the style of cells is changed |
beforeValueChange | Fires before the values of cells are changed |
Spreadsheet properties
Name | Description |
---|---|
colsCount | Optional. Sets the number of columns a spreadsheet will have on initialization |
dateFormat | Optional. Defines the format of dates in the spreadsheet |
editLine | Optional. Shows/hides the editing bar |
exportModulePath | Optional. Sets the path to the export module |
formats | Optional. Defines the list of number formats |
importModulePath | Optional. Sets the path to the import module |
leftSplit | Optional. Sets the number of columns fixed to the left side of the spreadsheet |
localization | Optional. Defines the format of numbers, dates, time and currency |
menu | Optional. Shows/hides the menu |
multiSheets | Optional. Enables/disables an ability to work with multiple sheets in the spreadsheet |
readonly | Optional. Enables/disables the readonly mode |
rowsCount | Optional. Sets the number of rows a spreadsheet will have on initialization |
timeFormat | Optional. Defines the format of time in the spreadsheet |
toolbarBlocks | Optional. Specifies blocks of buttons that will be shown in the toolbar of spreadsheet |
topSplit | Optional. Sets the number of rows fixed to the top of the spreadsheet |
Selection methods
Name | Description |
---|---|
getFocusedCell() | Returns the id of a focused cell |
getSelectedCell() | Returns the id(s) of selected cell(s) |
removeSelectedCell() | Removes selection from the specified cell(s) |
setFocusedCell() | Sets focus on the specified cell |
setSelectedCell() | Selects the specified cell(s) |
Events Bus methods
Name | Description |
---|---|
detach() | Detaches a handler from an event (which was attached before by the on() method) |
fire() | Triggers an inner event |
on() | Attaches a handler to an inner event of Spreadsheet |
Export methods
Name | Description |
---|---|
json() | Exports data from a spreadsheet into a JSON file |
xlsx() | Exports data from a spreadsheet into an Excel (.xlsx) file |