Convert Figma logo to code with AI

nick-keller logoreact-datasheet-grid

An Airtable-like / Excel-like component to create beautiful spreadsheets.

1,831
173
1,831
59

Top Related Projects

JavaScript data grid with a spreadsheet look & feel. Works with React, Angular, and Vue. Supported by the Handsontable team ⚡

13,037

The best JavaScript Data Table for building Enterprise Applications. Supports React / Angular / Vue / Plain JavaScript.

Feature-rich and customizable data grid React component

Excel-like data grid (table) component for React

A lightning fast JavaScript grid/spreadsheet

Quick Overview

React Datasheet Grid is a lightweight and customizable React component for creating spreadsheet-like data grids. It offers a simple and intuitive interface for users to interact with tabular data, supporting features like inline editing, keyboard navigation, and custom cell renderers.

Pros

  • Lightweight and performant, with minimal dependencies
  • Highly customizable, allowing for custom cell renderers and editors
  • Supports keyboard navigation and shortcuts for a spreadsheet-like experience
  • Easy to integrate with existing React projects

Cons

  • Limited built-in features compared to more comprehensive data grid libraries
  • Documentation could be more extensive, especially for advanced use cases
  • Lacks some advanced features like filtering, sorting, and grouping out of the box
  • May require additional work to implement complex data manipulation scenarios

Code Examples

  1. Basic usage with default columns:
import { DataSheetGrid, textColumn } from 'react-datasheet-grid'

function MyComponent() {
  const [data, setData] = useState([
    { name: 'John', age: 30 },
    { name: 'Jane', age: 28 },
  ])

  return (
    <DataSheetGrid
      value={data}
      onChange={setData}
      columns={[
        { ...textColumn, key: 'name', title: 'Name' },
        { ...textColumn, key: 'age', title: 'Age' },
      ]}
    />
  )
}
  1. Using a custom cell renderer:
import { DataSheetGrid, textColumn } from 'react-datasheet-grid'

const customAgeColumn = {
  ...textColumn,
  component: ({ value }) => (
    <div style={{ color: value < 30 ? 'green' : 'red' }}>
      {value}
    </div>
  ),
}

function MyComponent() {
  // ... state and other code

  return (
    <DataSheetGrid
      value={data}
      onChange={setData}
      columns={[
        { ...textColumn, key: 'name', title: 'Name' },
        { ...customAgeColumn, key: 'age', title: 'Age' },
      ]}
    />
  )
}
  1. Adding a new row button:
import { DataSheetGrid, textColumn, keyColumn } from 'react-datasheet-grid'

function MyComponent() {
  const [data, setData] = useState([
    { id: 1, name: 'John', age: 30 },
    { id: 2, name: 'Jane', age: 28 },
  ])

  const addRow = () => {
    setData([...data, { id: Date.now(), name: '', age: '' }])
  }

  return (
    <>
      <DataSheetGrid
        value={data}
        onChange={setData}
        columns={[
          { ...keyColumn, key: 'id' },
          { ...textColumn, key: 'name', title: 'Name' },
          { ...textColumn, key: 'age', title: 'Age' },
        ]}
      />
      <button onClick={addRow}>Add Row</button>
    </>
  )
}

Getting Started

  1. Install the package:

    npm install react-datasheet-grid
    
  2. Import and use the component in your React application:

    import { DataSheetGrid, textColumn } from 'react-datasheet-grid'
    import 'react-datasheet-grid/dist/style.css'
    
    function App() {
      const [data, setData] = useState([{ name: '', age: '' }])
    
      return (
        <DataSheetGrid
          value={data}
          onChange={setData}
          columns={[
            { ...textColumn, key: 'name', title: 'Name' },
            { ...textColumn, key: 'age', title: 'Age' },
          ]}
        />
      )
    }
    
  3. Customize columns and add features as needed for your

Competitor Comparisons

JavaScript data grid with a spreadsheet look & feel. Works with React, Angular, and Vue. Supported by the Handsontable team ⚡

Pros of Handsontable

  • More feature-rich with advanced functionalities like filtering, sorting, and validation
  • Supports multiple frameworks (React, Angular, Vue) and vanilla JavaScript
  • Extensive documentation and community support

Cons of Handsontable

  • Larger bundle size due to its comprehensive feature set
  • Steeper learning curve for basic implementations
  • Commercial license required for some use cases

Code Comparison

React-datasheet-grid:

<DataSheetGrid
  value={data}
  onChange={setData}
  columns={columns}
/>

Handsontable:

<HotTable
  data={data}
  colHeaders={true}
  rowHeaders={true}
  height="auto"
  licenseKey="non-commercial-and-evaluation"
/>

React-datasheet-grid offers a simpler API for basic spreadsheet functionality, while Handsontable provides more configuration options out of the box. Handsontable requires a license key, even for non-commercial use, whereas React-datasheet-grid is open-source without such requirements.

Both libraries serve different needs: React-datasheet-grid is lightweight and focused on React integration, while Handsontable is a more comprehensive solution for complex spreadsheet-like interfaces across multiple frameworks.

13,037

The best JavaScript Data Table for building Enterprise Applications. Supports React / Angular / Vue / Plain JavaScript.

Pros of ag-grid

  • More feature-rich with advanced functionalities like filtering, sorting, and grouping
  • Supports multiple frameworks (React, Angular, Vue) and vanilla JavaScript
  • Extensive documentation and community support

Cons of ag-grid

  • Steeper learning curve due to its complexity
  • Larger bundle size, which may impact performance for smaller projects
  • Commercial license required for some advanced features

Code Comparison

react-datasheet-grid:

<DataSheetGrid
  value={data}
  onChange={setData}
  columns={[
    { title: 'Name', ...textColumn },
    { title: 'Age', ...numberColumn },
  ]}
/>

ag-grid:

<AgGridReact
  columnDefs={[
    { field: 'name' },
    { field: 'age', type: 'numberColumn' },
  ]}
  rowData={rowData}
/>

Both libraries offer a declarative approach to defining grid structures, but ag-grid provides more built-in column types and configuration options. react-datasheet-grid focuses on simplicity and ease of use for basic spreadsheet-like functionality, while ag-grid offers a more comprehensive set of features for complex data grids. The choice between the two depends on the specific requirements of your project, considering factors such as feature needs, performance constraints, and development complexity.

Feature-rich and customizable data grid React component

Pros of react-data-grid

  • More mature and feature-rich, with a larger community and longer development history
  • Offers advanced features like cell editing, sorting, and filtering out of the box
  • Better documentation and examples, making it easier for developers to get started

Cons of react-data-grid

  • Heavier and more complex, which may impact performance for larger datasets
  • Less flexible for customization, as it comes with many pre-built features
  • Steeper learning curve due to its extensive API and configuration options

Code Comparison

react-datasheet-grid:

<DataSheetGrid
  value={data}
  onChange={setData}
  columns={columns}
/>

react-data-grid:

<ReactDataGrid
  columns={columns}
  rowGetter={i => data[i]}
  rowsCount={data.length}
  onGridRowsUpdated={handleGridRowsUpdated}
/>

The code comparison shows that react-datasheet-grid has a simpler API for basic usage, while react-data-grid requires more configuration for similar functionality. react-data-grid's approach allows for more granular control but may be more verbose for simple use cases.

Both libraries have their strengths, and the choice between them depends on the specific requirements of your project, such as the need for advanced features, performance considerations, and the desired level of customization.

Excel-like data grid (table) component for React

Pros of react-datasheet

  • More mature project with a longer history and larger community
  • Supports copy-paste functionality out of the box
  • Offers built-in formula support for Excel-like calculations

Cons of react-datasheet

  • Less flexible styling options compared to react-datasheet-grid
  • Limited customization for cell rendering and editing
  • Lacks some advanced features like row grouping and custom cell types

Code Comparison

react-datasheet:

<ReactDataSheet
  data={[
    [{ value: 1 }, { value: 2 }, { value: 3 }],
    [{ value: 4 }, { value: 5 }, { value: 6 }]
  ]}
  valueRenderer={(cell) => cell.value}
  onCellsChanged={(changes) => {
    // Handle changes
  }}
/>

react-datasheet-grid:

<DataSheetGrid
  value={[
    { id: 1, name: 'John', age: 30 },
    { id: 2, name: 'Jane', age: 28 }
  ]}
  onChange={(newValue) => {
    // Handle changes
  }}
  columns={[
    { key: 'name', title: 'Name' },
    { key: 'age', title: 'Age' }
  ]}
/>

The code comparison shows that react-datasheet-grid offers a more structured approach with defined columns and row objects, while react-datasheet uses a simpler 2D array structure. react-datasheet-grid provides more flexibility in defining custom columns and cell types, making it easier to work with complex data structures.

A lightning fast JavaScript grid/spreadsheet

Pros of SlickGrid

  • More mature and battle-tested, with a longer history of development and use in production environments
  • Supports a wider range of features out-of-the-box, including advanced sorting, filtering, and grouping
  • Better performance for handling large datasets, with virtual scrolling and efficient rendering

Cons of SlickGrid

  • Steeper learning curve due to its extensive API and configuration options
  • Less modern development experience, as it's not built specifically for React
  • Requires more setup and boilerplate code to get started

Code Comparison

SlickGrid:

var grid = new Slick.Grid("#myGrid", data, columns, options);
grid.onCellChange.subscribe(function (e, args) {
  // Handle cell change
});

React-datasheet-grid:

<DataSheetGrid
  value={data}
  onChange={setData}
  columns={columns}
/>

SlickGrid offers more granular control but requires more setup, while React-datasheet-grid provides a simpler, more React-friendly API. SlickGrid's event-based approach contrasts with React-datasheet-grid's declarative style, reflecting their different design philosophies and target ecosystems.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

react-datasheet-grid

GitHub Workflow Status Coveralls npm GitHub last commit npm bundle size JavaScript Style Guide

View demo and documentation

An Airtable-like / Excel-like component to create beautiful spreadsheets.

Preview

Feature rich:

  • Dead simple to set up and to use
  • Supports copy / pasting to and from Excel, Google-sheet...
  • Keyboard navigation and shortcuts fully-supported
  • Supports right-clicking and custom context menu
  • Supports dragging corner to expand selection
  • Easy to extend and implement custom widgets
  • Blazing fast, optimized for speed, minimal renders count
  • Smooth animations
  • Virtualized rows and columns, supports hundreds of thousands of rows
  • Extensively customizable, controllable behaviors
  • Built with Typescript

Install

npm i react-datasheet-grid

Usage

import {
  DataSheetGrid,
  checkboxColumn,
  textColumn,
  keyColumn,
} from 'react-datasheet-grid'

// Import the style only once in your app!
import 'react-datasheet-grid/dist/style.css'

const Example = () => {
  const [ data, setData ] = useState([
    { active: true, firstName: 'Elon', lastName: 'Musk' },
    { active: false, firstName: 'Jeff', lastName: 'Bezos' },
  ])

  const columns = [
    {
      ...keyColumn('active', checkboxColumn),
      title: 'Active',
    },
    {
      ...keyColumn('firstName', textColumn),
      title: 'First name',
    },
    {
      ...keyColumn('lastName', textColumn),
      title: 'Last name',
    },
  ]

  return (
    <DataSheetGrid
      value={data}
      onChange={setData}
      columns={columns}
    />
  )
}

NPM DownloadsLast 30 Days