Skip to content

DHTMLX/react-spreadsheet-examples

Repository files navigation

DHTMLX React Spreadsheet — Examples

dhtmlx.com

Getting started | Features | Samples overview | Useful links

A sample React application demonstrating DHTMLX React Spreadsheet — a declarative React wrapper for the DHTMLX Spreadsheet library.

dhtmlx-spreadsheet-data-filtering

How to use

import ReactSpreadsheet from "@dhtmlx/trial-react-spreadsheet";
import "@dhtmlx/trial-react-spreadsheet/spreadsheet.react.css";
import type { SheetData } from "@dhtmlx/trial-react-spreadsheet";

const sheets: SheetData[] = [
	{
		id: "sheet1",
		name: "Sales",
		cells: {
			A1: { value: "Product" },
			B1: { value: "Revenue", format: "currency" },
			A2: { value: "Widget A" },
			B2: { value: 1500, format: "currency" },
		},
	},
];

export default function App() {
	return (
		<div style={{ width: "100%", height: "500px" }}>
			<ReactSpreadsheet
				sheets={sheets}
				onAfterEditEnd={(cell, value) => {
					console.log(`Cell ${cell} updated to: ${value}`);
				}}
			/>
		</div>
	);
}

Features

DHTMLX React Spreadsheet brings Excel-like functionality into React apps:

  • Datasheets, styles, activeSheet, search, loadUrl
  • Configurationmenu, editLine, toolbarBlocks, multiSheets, formats, readonly, rowsCount, colsCount, localization, importModulePath, exportModulePath
  • Appearancetheme (light, dark, contrast-light, contrast-dark), className, style
  • Events — 21 callbacks covering actions, selection, editing, sheets, and data lifecycle (e.g. onBeforeAction, onAfterEditEnd, onAfterSheetChange, onStateChange)
  • Ref API — access the underlying DHTMLX instance via SpreadsheetRef for imperative operations (serialize, undo/redo, programmatic selection)
  • TypeScript — full type exports: SheetData, CellData, SearchConfig, Actions enum, and all event handler types

Getting started

Prerequisites

  • Node.js 20+
  • React 18+
  • Yarn (or npm)

Install dependencies

yarn install

Build the app

yarn build

Run the dev server

yarn start

Then open http://localhost:3000 in your browser.

Samples overview

Samples are in src/pages/ organized by category:

Properties (properties/)

  • Initialization — multi-sheet setup with cell data
  • Custom Formats — custom number format definitions
  • Formulas Cheat Sheet — formula reference and usage
  • Full Toolbar — complete toolbar configuration
  • Readonly — read-only mode toggle
  • Config Options — menu, edit line, toolbar blocks, multi-sheets
  • Themes — built-in light/dark/contrast themes
  • Custom Themes — user-defined theme variables
  • Localization — UI and formula name translations

Data (data/)

  • Redux Integration — Redux Toolkit state management
  • Search — controlled search with result tracking
  • Sheet — sheet CRUD operations
  • Row — row management (add, delete, resize, hide)
  • Column — column management (add, delete, resize, hide)
  • Freezing — row and column freeze panes
  • Filtering — column filter configuration
  • Sorting — column sorting
  • Locking — cell protection
  • Merging — cell merge ranges
  • Data Loading — loading data via the sheets prop
  • Data Load (via Ref) — loading data through the imperative ref API
  • Undo/Redo — history state tracking via onStateChange

Cell (cell/)

  • Cell Value — get/set cell values
  • Cell Style — cell styling
  • Cell Format — number and date formatting
  • Cell Validation — cell validation rules
  • Cell Iteration — iterating over cells

Events (events/)

  • Before Events — cancellable action, edit, selection, and sheet events
  • After Events — notification events for completed operations
  • Input Events — cell and edit line input tracking

Notes

  • The application source code in this repo is published as an example project.
  • @dhtmlx/trial-react-spreadsheet is a commercial trial package. Use it under a valid evaluation or commercial agreement.

Useful links

Follow us