Skip to main content

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

NameDescription
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

NameDescription
afterActionFires after an action is executed
afterClearFires after a spreadsheet is cleared
afterColumnAddFires after a new column is added
afterColumnDeleteFires after a column is deleted
afterEditEndFires after editing of a cell is finished
afterEditStartFires after editing of a cell has started
afterFocusSetFires after focus is set on a cell
afterFormatChangeFires after the format of a cell is changed
afterRowAddFires after a new row is added
afterRowDeleteFires after a row is deleted
afterSelectionSetFires after cells are selected
afterSheetAddFires after a new sheet is added
afterSheetChangeFires after the currently active sheet is changed
afterSheetClearFires after a sheet of the spreadsheet is cleared
afterSheetRemoveFires after a sheet is removed
afterSheetRenameFires after a sheet is renamed
afterStyleChangeFires after the style of a cell is changed
afterValueChangeFires after the value of a cell changes
beforeActionFires before an action is executed
beforeClearFires before a spreadsheet is cleared
beforeColumnAddFires before a new column is added
beforeColumnDeleteFires before a column is deleted
beforeEditEndFires before editing of a cell is finished
beforeEditStartFires before editing of a cell has started
beforeFocusSetFires before focus is set on a cell
beforeFormatChangeFires before the format of a cell is changed
beforeRowAddFires before a new row is added
beforeRowDeleteFires before a row is deleted
beforeSelectionSetFires before cells are selected
beforeSheetAddFires before a new sheet is added
beforeSheetChangeFires before changing the currently active sheet
beforeSheetClearFires before a sheet of the spreadsheet is cleared
beforeSheetRemoveFires before a sheet is removed
beforeSheetRenameFires before a sheet is renamed
beforeStyleChangeFires before the style of cells is changed
beforeValueChangeFires before the values of cells are changed

Spreadsheet properties

NameDescription
colsCountOptional. Sets the number of columns a spreadsheet will have on initialization
dateFormatOptional. Defines the format of dates in the spreadsheet
editLineOptional. Shows/hides the editing bar
exportModulePathOptional. Sets the path to the export module
formatsOptional. Defines the list of number formats
importModulePathOptional. Sets the path to the import module
leftSplitOptional. Sets the number of columns fixed to the left side of the spreadsheet
localizationOptional. Defines the format of numbers, dates, time and currency
menuOptional. Shows/hides the menu
multiSheetsOptional. Enables/disables an ability to work with multiple sheets in the spreadsheet
readonlyOptional. Enables/disables the readonly mode
rowsCountOptional. Sets the number of rows a spreadsheet will have on initialization
timeFormatOptional. Defines the format of time in the spreadsheet
toolbarBlocksOptional. Specifies blocks of buttons that will be shown in the toolbar of spreadsheet
topSplitOptional. Sets the number of rows fixed to the top of the spreadsheet

Selection methods

NameDescription
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

NameDescription
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

NameDescription
json()Exports data from a spreadsheet into a JSON file
xlsx()Exports data from a spreadsheet into an Excel (.xlsx) file