Code Monkey home page Code Monkey logo

react-spreadsheet's Introduction

React Spreadsheet

React spreadsheet built upon react-virtualized
Demo - source code can be found in src/demo/

Prop Types

Property Type          Required? Description
cellData Array or Function Data to display in the sheet. Defined as a sparse rows x columns array or provided as a function function({rowIndex: number, columnIndex: number}): string
columnsFormat Array or Function Defines the widths of the columns. Either defined as numbers in a sparse array or provided as a function function(columnIndex: number): number
defaultColumnWidth Number Default column width. Defaults to 64px.
defaultRowHeight Number Default row height. Defaults to 20px.
onCellChange Function Callback invoked whenever the value of a cell changes. Has the signature function({ value: string, rowIndex: number, columnIndex: number }): void where value is the new content of the specified cell.
onColumnResize Function Callback invoked on a column resize action. Has the signature function({ columnIndex: number, size: number }): void where size is the new size of the specified column.
onRowResize Function Callback invoked on a row resize action. Has the signature function({ rowIndex: number, size: number }): void where size is the new size of the specified row.
onSelect Function Callback invoked on selection. Has the signature function({ startSelection, endSelection }): void where startSelection specifies the cell the selection originates from and endSelection specifies the last cell in the selection process. startSelection and endSelection follows the type { row:number, column: number }
rowsFormat Array or Function Defines the heights of the rows. Either defined as numbers in a sparse array or provided as a function function(columnIndex: number): number

Basic react-spreadsheet example

import React from 'react';
import ReactDOM from 'react-dom';
import Spreadsheet from 'react-spreadsheet';

// Data to display in the sheet
cellData: [
  ['January', 'February', 'Mars'], // row
  ['1', '2', '3', , , 4, 5] // row
]

// Render the spreadsheet
ReactDOM.render(
  <Spreadsheet
    cellData={cellData}
  ></Spreadsheet>,
  document.getElementById('root')
);

Check src/demo/ for a more extensive example.

Noteworthy Features

  • Row and column resizing
  • Drag and select + scroll
  • ...under development

To be done

  • Rewrite with Redux

Under the hood

Built upon react-virtualized

react-spreadsheet's People

Contributors

simonfc avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.