Skip to main content

API overview


var spreadsheet = new dhx.Spreadsheet("spreadsheet_container", {    rowsCount:20,    colsCount:20});


  • an HTML container (or the ID of an HTML container)
  • a hash of config options (check below)

Spreadsheet methods#

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
getActiveSheet()returns the sheet that is currently active
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)
isLocked()checks whether a cell(s) is(are) locked
load()loads data from an external file
lock()locks the specified cell
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
setActiveSheet()sets the active sheet by its id
setFormat()sets a specified format to the value of a cell
setStyle()sets style to a cell(s)
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#

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
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 change

Spreadsheet properties#

colsCountsets the number of columns a spreadsheet will have on initialization
dateFormatdefines the format of dates in the spreadsheet
editLineshows/hides the editing bar
exportModulePathsets the path to the export module
formatsdefines the list of number formats
importModulePathsets the path to the import module
leftSplitsets the number of columns fixed to the left side of the spreadsheet
menushows/hides the menu
multiSheetsenables/disables the ability to work with multiple sheets in the spreadsheet
readonlyenables/disables the readonly mode
rowsCountsets the number of rows a spreadsheet will have on initialization
toolbarBlocksspecifies blocks of buttons that will be shown in the toolbar of spreadsheet

Selection methods#

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#

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#

xlsx()exports data from a spreadsheet into an Excel (.xlsx) file