Configuration

You can adjust the desired settings of dhtmlxSpreadSheet to meet your needs. The available configuration options allow you to limit the number of rows and columns, change the toolbar appearance and control the visibility of the menu and the editing bar. You can also initialize SpreadSheet in the readonly mode, if needed.

Toolbar

The toolbar of the SpreadSheet consists of several blocks of controls that can be changed according to your needs. By default, there are the following blocks of controls in the toolbar: "undo","colors","decoration","align", "help":

Basic toolbar

You can add more blocks from the list: "lock", "clear", "rows", "columns".

Extra buttons

The structure of toolbar can be adjusted via the toolbarBlocks configuration option of the component, which is an array with strings presenting the names of controls.

var spreadsheet = new dhx.Spreadsheet(document.body, {
    // full toolbar
    toolbarBlocks: [
        "undo","colors","decoration","align","help",
        "lock", "clear", "rows", "columns"
    ]
});

Related sample:  Full toolbar

You can also specify your own structure of the toolbar by enumerating necessary elements in the toolbarBlocks array in the desired order, for example:

var spreadsheet = new dhx.Spreadsheet("cont", {
    toolbarBlocks: ["help","colors", "align", "decoration", "lock", "clear"]
});

Custom toolbar

Toolbar is highly customizable. You can add new controls, change the icons of controls and apply the desired icon pack.

Editing bar

Since the structure of SpreadSheet is flexible, you can switch on/off the editing bar to get the desired look and feel of the component. Use the editLine configuration option to hide/show the editing bar:

var spreadsheet = new dhx.Spreadsheet(document.body, {
    editLine: true
});

Related sample:  Disabled edit line

Number of rows and columns

When SpreadSheet is initialized, it has the initial configuration of grid which consists of 1000 columns and 25 rows. However, when this limit runs out, additional rows and columns are rendered automatically, so you don't need to add them. Nevertheless, you can specify the exact number of rows and columns in the grid, if you want to limit them. Use the colsCount and rowsCount options for this purpose:

var spreadsheet = new dhx.Spreadsheet(document.body, {          
    colsCount: 10,
    rowsCount: 10
});

Related sample:  Custom cells count

Menu

The menu of the SpreadSheet is hidden by default. You can switch it on/off via the corresponding configuration option menu:

var spreadsheet = new dhx.Spreadsheet(document.body, {
    menu: false
});

Related sample:  Spreadsheet with menu

Readonly mode

It is also possible to enable the readonly mode to prevent editing of SpreadSheet cells via the readonly configuration option:

var spreadsheet = new dhx.Spreadsheet("cont", {
    readonly: true
});

Related sample:  Readonly mode

Back to top