FortuneSheet

A drop-in javascript spreadsheet library that provides rich features like E...

README

FortuneSheet

FortuneSheet is a drop-in javascript spreadsheet library that provides rich features like Excel and Google Sheets

CircleCI Status Known Vulnerabilities Build with father xiemala



English | 简体中文

Purpose


The goal of FortuneSheet is to make a feature-rich, easy-to-configure online spreadsheet that you can use out-of-the-box.

This project is originated from Luckysheet and has inherited many code from it. Lots of efforts have done to translate the whole project to typescript (still in progress), and solved problems in the design of the original project.

We aim to make FortuneSheet powerful yet easy to maintain.

Live demo


Take a look at the live demo at fortune-sheet-demo


Attention

Before stable release of 1.0, input data structure and APIs may change during development. If you encounter errors after upgrading a version, check Changelog and Migration Guide.

Improvements to Luckysheet


- Written fully in typescript.
- You can now use import / require to use the library.
  1. ``` js
  2.   import { Workbook } from '@fortune-sheet/react'
  3. ```
- Multiple instance on the same page is supported.
- Dropped jQuery dependency, uses native React / Vue + immer to manage the dom and state.
- Changed to a forked handsontable/formula-parser to handle formula calculations.
- Optimized the dom structure.
- Replaced icons from iconfont with SVGs, as iconfont icons are inconvenient to update for other maintainers.
- No visible elements is created outside container.
- Never stores data in the window object.

Features


- Data structure is mostly compatible with Luckysheet (see Migration Guide).
- Formatting: style, text alignment and rotation, text truncation, overflow, automatic line wrapping, multiple data types, cell segmentation style
- Cells: multiple selection, merge cells
- Row & column: insert, delete rows or columns
- Operation: copy, paste, cut, hot key
- Formulas & Functions: Built-in formulas

Roadmap

- ✅ Support cooperative editing with backend storage.
- ✅ Support undo/redo.
- ✅ Mobile adaption.
- ✅ Expose APIs.
- ✅ Add tests.
- More basic features:
  - ✅ fill handle
  - fonts
  - ✅ format painter
  - ✅ comments
  - ✅ insert images
  - ✅ more toolbar buttons
- Excel import and export.
- Support Vue.
- More features:
  - ✅ sort
  - ✅ filter
  - ✅ hooks
  - conditional formatting
  - ✅ drag and drop
  - ✅ find and replace
  - location
  - data verification
  - ✅ freeze
  - hide, and split text
- More advanced features:
  - pivot tables
  - charts
  - ✅ screenshots

Documentation


See detailed documentation at fortune-sheet-doc

Get started (react)


Download and install the library

  1. ``` sh
  2. yarn add @fortune-sheet/react
  3. ```
or using npm:
  1. ``` sh
  2. npm install @fortune-sheet/react
  3. ```

Create an HTML placeholder

  1. ``` html
  2. <style>
  3.   html, body, #root {
  4.     width: 100%;
  5.     height: 100%;
  6.   }
  7. </style>
  8. <div id="root"></div>
  9. ```

NOTE: width and height doesn't have to be 100%, but should at least have a value. If set to auto, table area may not show.

Render the sheet


  1. ``` js
  2. import React from 'react';
  3. import ReactDOM from 'react-dom';
  4. import { Workbook } from "@fortune-sheet/react";
  5. import "@fortune-sheet/react/dist/index.css"

  6. ReactDOM.render(
  7.   <Workbook data={[{ name: "Sheet1" }]} />,
  8.   document.getElementById('root')
  9. );
  10. ```

Backend storage and collabration


Each time a user operates on the sheet, an array of Op will be emiited through onOp callback. An op describes how to modify the current data to reach the new data after the user's operation. For example, here is an op when user sets the cell font to be bold on cell A2.

  1. ``` json
  2. [
  3.     {
  4.         "op": "replace",
  5.         "index": "0",
  6.         "path": ["data", 1, 0, "bl"],
  7.         "value": 1
  8.     }
  9. ]
  10. ```

The op is useful for database modification and syncing state in online collabration.

A working example with Express (backend server) and MongoDB (data persistence) is avaiable in backend-demo folder.

Run it with node index.js and visit Collabration example (initialize data by visiting http://localhost:8081/init)

For detailed doc about Op, refer to fortune-sheet-doc

Migrating data from Luckysheet

The overall data structure of FortuneSheet is the same as Luckysheet, with some naming differences:

1. sheet.index -> sheet.id
2. sheet.calcChain[].id -> sheet.calcChain[].id

Contributing

Expected workflow is: Fork -> Patch -> Push -> Pull Request

Please make sure to read the Contributing Guide before making a pull request.


Development

Installation

  1. ``` sh
  2. yarn
  3. ```

Development

  1. ``` sh
  2. yarn dev
  3. ```

Packaging

  1. ``` sh
  2. yarn build
  3. ```

License

This project is licensed under the MIT License. See MIT for the full license text.