Calling Methods

var grid = new DataGridXL("grid", ...);

grid.insertCols(2);
grid.setCellValues({x:0,y:0}, "New Value");
grid.downloadDataAsCSV();

Actions: Cell

_clearCellColors() experimental

Clear given cell (range) colors (set all colors to null).

_setCellColors(,) experimental

Set given cell (range) colors. If colors is a single color value, it will apply to all cells.

clearCellValues()

Clear given cell (range) values (set all values to null).

setCellValues(,)

Set given cell (range) values. If values is a single cell value, it will apply to all cells.

Actions: Clipboard

copy()

Copy user cell selection values to clipboard.

cut()

Cut user cell selection values to clipboard.

paste()

Paste contents of clipboard (at cell cursor position).

Actions: Column

deleteCols()

Delete Columns. Requires cols to be set; either a range of columns (colRange) or a single column (colCoord).

insertCols(,)

Insert Columns. No required parameters. Default column amount is 1. If index parameter is left out, column(s) will be inserted at the end of the document.

moveCols(,)

Move Columns. Requires both parameters to be set. For cols, supply a single column (colCoord) or a range of columns (colRange). For index, supply a column coordinate (colCoord).

resizeCols(,)

Resize Columns. Either a single column (colCoord) or a range of columns (colRange). Size is in pixels (int).

resizeColsToFit()

Resize Columns to tightly fit contents. Either a single column (colCoord) or a range of columns (colRange).

Actions: Row

deleteRows()

Delete Rows. Requires rows to be set; either a range of rows (rowRange) or a single row (rowCoord).

insertRows(,)

Insert Rows. No required parameters. Default row amount is 1. If index parameter is left out, row(s) will be inserted at the end of the document.

moveRows(,)

Move Rows. Requires both parameters to be set. For rows, supply a single row (rowCoord) or a range of rows (rowRange). For index, supply a row coordinate (rowCoord).

Activation

activate()

Activate grid. Other DataGridXL instances on the same page will be deactivated. Sets cell cursor position at {x:0,y:0}, unless grid is already active.

deactivate()

Deactivate grid. Any selection (cell/row/column) will be cleared and keyboard listeners will be removed, until the grid is re-activated. Similar to deselectAll().

Data

downloadDataAsCSV()

Export grid values to CSV file.

downloadDataAsJSON()

Export grid values to JSON file.

getCellRangeData()

Returns a 2D array of cell values inside given cell range. To request a single cell value, use getCellValues instead.

getCellRangeText()

Returns a (Tab Seperated Values) string of cell values inside given cell range. (TSV-strings are compatible with Spreadsheet apps.)

getCellValues()

Returns value(s) of given cell(s). Returns a 2D array of cell values if 'cells' is of type cellRange. Returns a single cell value if 'cells' is of type cellCoords (single cell).

getData()

Returns grid data (in same format as it was given).

setData(,)

Clears grid and sets new data. Note that any undo-history is cleared when this method is used.

Editor

closeEditor()

Close value editor without saving.

closeEditorAndSave()

Close value editor and save its value.

openEditor()

Open value editor at cell cursor position. Mode is either 'inline' or 'opened' (default).

Selection: Any

deselectAll()

Deselects any selection.

Selection: Cell Cursor

getCellCursorPosition()

Returns cell cursor position in cell coords {x,y}.

setCellCursorPosition()

Set cell cursor position in cell coords {x,y}. Same as selectCells({x,y})

Selection: Cells

getCellSelection()

Get original cell selection.

getNormalizedCellSelection()

Get normalized cell selection (sorted top-left to bottom-right).

selectAll()

Select all cells.

selectCells()

Set cell selection. To select a single cell, you can use setCellCursorPosition as well.

Selection: Columns

getColSelection()

Get original column selection.

getNormalizedColSelection()

Get normalized column selection (sorted left to right).

selectCols()

Set column selection.

Selection: Rows

getNormalizedRowSelection()

Get normalized row selection (sorted top to bottom).

getRowSelection()

Get original row selection.

selectRows()

Set row selection.

Store

getCellFromStore(,)

Get cell from store by row id, col id

getColFromStore()

Get column from store by column id

getRowFromStore()

Get row from store by row id

Theme

setTheme()

set theme

Undo & Redo

redo()

Redo last undone user action

undo()

Undo last user action

Viewport

getViewportPosition()

get current viewport position in cell coordinates

setViewportPosition()

set viewport position in cell coordinates