Skip to main content

Configuration

You can adjust the desired settings of DHTMLX Spreadsheet 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 read-only 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", "font", "decoration", "align", "cell", "format", "actions". You can add more blocks from the list: "lock", "clear", "rows", "columns", "file", "help".

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

You can also specify your own structure of the toolbar by enumerating necessary elements in the toolbarBlocks array in the desired order, for example: "colors", "align", "cell", "decoration", "lock", "clear".

const spreadsheet = new dhx.Spreadsheet("spreadsheet_container", {
toolbarBlocks: ["colors", "align", "cell", "decoration", "lock", "clear"]
});

The 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.

Number of rows and columns

When Spreadsheet is initialized, it starts with a grid of 26 columns and 1000 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.

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

Read-only mode

You can also enable read-only mode to prevent editing of Spreadsheet cells via the readonly configuration option.

You can also customize the read-only behavior of Spreadsheet.

Custom number formats for cells

You can apply 7 default formats to cell values: "Common", "Number", "Percent", "Currency", "Date", "Time", "Text".

You can redefine configuration of default formats or specify your own number format via the formats config option. Check the details in the Number Formatting article.

Path to export/import modules

DHTMLX Spreadsheet can import and export data in Excel format. The component uses WebAssembly-based libraries: Excel2Json and JSON2Excel for import/export of data.

After installing the necessary library, you need to set the path to the worker.js file (either local or at CDN) via the corresponding configuration option: importModulePath or exportModulePath.

All the details are given in the Data Loading and Export article.