Git Product home page Git Product logo

x-spreadsheet's Introduction

x-spreadsheet

npm package NPM downloads NPM downloads Build passing codecov GitHub GitHub code size in bytes Join the chat at https://gitter.im/x-datav/spreadsheet

A web-based JavaScript spreadsheet

Document

CDN

<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/xspreadsheet.css">
<script src="https://unpkg.com/[email protected]/dist/xspreadsheet.js"></script>

<script>
   x_spreadsheet('#xspreadsheet');
</script>

NPM

npm install x-data-spreadsheet
<div id="x-spreadsheet-demo"></div>
import Spreadsheet from "x-data-spreadsheet";
// If you need to override the default options, you can set the override
// const options = {};
// new Spreadsheet('#x-spreadsheet-demo', options);
const s = new Spreadsheet("#x-spreadsheet-demo")
  .loadData({}) // load data
  .change(data => {
    // save data to db
  });

// data validation
s.validate()
// default options
{
  mode: 'edit', // edit | read
  showToolbar: true,
  showGrid: true,
  showContextmenu: true,
  view: {
    height: () => document.documentElement.clientHeight,
    width: () => document.documentElement.clientWidth,
  },
  row: {
    len: 100,
    height: 25,
  },
  col: {
    len: 26,
    width: 100,
    indexWidth: 60,
    minWidth: 60,
  },
  style: {
    bgcolor: '#ffffff',
    align: 'left',
    valign: 'middle',
    textwrap: false,
    strike: false,
    underline: false,
    color: '#0a0a0a',
    font: {
      name: 'Helvetica',
      size: 10,
      bold: false,
      italic: false,
    },
  },
}

import | export xlsx

https://github.com/SheetJS/sheetjs/tree/master/demos/xspreadsheet#saving-data

thanks https://github.com/SheetJS/sheetjs

Bind events

const s = new Spreadsheet("#x-spreadsheet-demo")
// event of click on cell
s.on('cell-selected', (cell, ri, ci) => {});
s.on('cells-selected', (cell, { sri, sci, eri, eci }) => {});
// edited on cell
s.on('cell-edited', (text, ri, ci) => {});

update cell-text

const s = new Spreadsheet("#x-spreadsheet-demo")
// cellText(ri, ci, text, sheetIndex = 0)
s.cellText(5, 5, 'xxxx').cellText(6, 5, 'yyy').reRender();

get cell and cell-style

const s = new Spreadsheet("#x-spreadsheet-demo")
// cell(ri, ci, sheetIndex = 0)
s.cell(ri, ci);
// cellStyle(ri, ci, sheetIndex = 0)
s.cellStyle(ri, ci);

Internationalization

// npm 
import Spreadsheet from 'x-data-spreadsheet';
import zhCN from 'x-data-spreadsheet/dist/locale/zh-cn';

Spreadsheet.locale('zh-cn', zhCN);
new Spreadsheet(document.getElementById('xss-demo'));
<!-- Import via CDN -->
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/xspreadsheet.css">
<script src="https://unpkg.com/[email protected]/dist/xspreadsheet.js"></script>
<script src="https://unpkg.com/[email protected]/dist/locale/zh-cn.js"></script>

<script>
  x_spreadsheet.locale('zh-cn');
</script>

Features

  • Undo & Redo
  • Paint format
  • Clear format
  • Format
  • Font
  • Font size
  • Font bold
  • Font italic
  • Underline
  • Strike
  • Text color
  • Fill color
  • Borders
  • Merge cells
  • Align
  • Text wrapping
  • Freeze cell
  • Functions
  • Resize row-height, col-width
  • Copy, Cut, Paste
  • Autofill
  • Insert row, column
  • Delete row, column
  • hide row, column
  • multiple sheets
  • print
  • Data validations

Development

git clone https://github.com/myliang/x-spreadsheet.git
cd x-spreadsheet
npm install
npm run dev

Open your browser and visit http://127.0.0.1:8080.

Browser Support

Modern browsers(chrome, firefox, Safari).

LICENSE

MIT

x-spreadsheet's People

Contributors

13516016 avatar anandksalien avatar andreykyz avatar apnerve avatar benjaminwols avatar customizing-a-z avatar dahuachan avatar devgeni avatar div5yesh avatar fxhdhr avatar grandrew avatar hondrytravis avatar iwauo avatar jonham avatar kausthubramrajesh avatar leoxoocanada avatar mohapakram avatar monkeywithacupcake avatar myliang avatar ourai avatar reviewher avatar ronkok avatar sain2424 avatar styfle avatar superman32432432 avatar ulysseguyon avatar welkinwong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

x-spreadsheet's Issues

Get response json on add character in cell

Hi,
I want updated json on add character in cell, currently i am getting only first character of cell in update json, For getting whole updated json i have to change or focus on another cell. So, It is possible to get updated json on change of any single character in cell.

Here i attach screen shot of tables with enter data "at" and in json only get single character "a" .

cell

Please help me to resolve this.

shortcut

It's neat and fast. I do think that you should consider implementing a few more common excel shortcuts, to make it really seamless to an advanced excel user. For instance:

  • CTRL ARROWS: to move on the grid to the next populated cell

  • F2: edit the first cell of the selected range

  • CTR ENTER: applies the content of the first cell of the selected range to the whole range (after you pressed F2 to edit it)

  • when edit mode, pressing down arrow should leave edit mode and move to the cell below

  • CTR *: select area

  • SHIFT SPACE / CTR SPACE: to select a row / column

Right-click contextual menu

This is a suggestion of improvement of the UX.
Right-click is not working on the headers but is already working on the cells, offering, among other things, to delete row or column.

Ideally a right-click on the column/row header should offer the possibility to delete the right-clicked row/column.

Missing float operations

I've tried to multiply a cell by "2.5" (=A1 * 2.5) and it doesn't work, although it works with integer factors. I've also tried "2,5" instead of "2.5" and the result was the same.

Underline text

This is a suggestion of improvement of the UX.
We can see Bold, Italic, Strikethrough options but not underline in the demo.
Is underline already implemented but not shown in the demo?

a bug

当文字的长度超过了单元的宽度,点击文本对齐的居中,或者居右,会出现文字溢出到左边单元格的情况,这个怎么解决?

Requirement Download button

I hope you have used inbuilt converter from js to xlsx format.

I am getting a feeling of using Google sheets without too much waiting for loading or login required.

Its like a necessary condition of Download button.

您好,想问下表格上的数据怎样传到后台

您好,我看到您这个excel表格是用canvas标签画的,我有个疑惑,为什么我F12看控制台,发现好多table标签,但是没有一个table标签里面存储我写的数据,并且我Ctrl+F搜索我填的数据,发现在控制台里面找不到,不知道您是把数据存在哪?请问我要怎样把excel上面的数据全部提交到后台去呢

row limit

I was wondering what the row limit was?

Is this build using react?

Scroll event bubbles out of canvas (at least in demo)

Hello!

First of all, loving the project-- this looks awesome.

Next, the issue I noticed. Not sure if this is by design or not, but I thought I'd share that I found it a little weird. The scroll event seems to leave the canvas and so as the spreadsheet scrolls the whole thing moves up and down.

I imagine this could be fixed by disabling scroll in the container element(s). CSS is probably enough. Pointing it out not only because it's present in the example, but also because it's worth thinking if this should be the default behaviour or not.

Below is a screen recording of what I mean-- notice how as the cells scrolls the whole interface bounces around (as things do by default on macOS).

scroll image

FYI, I'm using Chrome 71.0.3578.98 on macOS 10.14.2 (18C54).

No text focus on Chrome/Android

Even clicking repeatedly on a single cell did not result in the keyboard popping up and being able to modify content.

Tedted on chrome on Android, might apply to other mobile browsers and platforms as well

Support retina screens

Right now the spreadsheet seems blurry on Macbook retina screens that have 2x resolution. Could you enable support for these?

Ignoring leading zeros

Sometimes leading zeros are needed in order to better represent some unit of measure, e.g.:

image

In fact this is an issue with the "cell pulling" feature, as you can notice that it does not consider what type of data is inserted, since the cells with dates are having the year incremented instead of the day. But if we go step-by-step, fixing the leading zeros would be a good start to improve the "cell pulling" feature.

firefox bug

The speed of the rendering is amazing compared especially to e.g. google sheets. I just informally timed both and gsheets was rendered and editable in 4 seconds whereas this took 0.2 seconds.
However nearly every native UI interaction seems kinda broken. Even entering a value on Firefox doesn't work well. The first letter typed is entered into the cell but then every subsequent letter triggers firefox's fine-in-page (which also doesn't work as others have pointed out). Similarly copy/paste doesn't work, and the context menu (right-click) closes immediately. Maybe it works better in Chrome.

I wonder if there's a case to be made for a hybrid rendering/ui approach here. Rendering could be handled by canvas but native elements swapped in when actual text-editing is invoked?

Cool little demo in any case. I liked some of the simple but effective spreadsheet evaluation code.

by ryanianian

New method to get the data of the spreadsheet

What would you recommend to get the all the data of the spreadsheet as one object without a change event?

I see two methods in the Spreadsheet class: loadData and change.
Could we use a new method "getData" or there's already a way to do that?

Add build

Hello,

First of all, thank you for sharing this project which looks very nice.
Is it planned to include a build directly in the repository?

Basic keybindings SHIFT+TAB and SHIFT+ENTER

TAB and ENTER already works as expected.

However the opposite directions do not seem to be implemented:
SHIFT+TAB: move one cell to the left of the current selection
SHIFT+ENTER: move one cell to the top of the current selection

Concatenation performed instead of addition

  1. Write 7 into cell A6.
  2. Write 3 into cell B6.
  3. Write =A6+B6 into cell C6

Cell C6 returns "37" instead of 10.

Suggested solution in cell.js, line 135:

if (srcStack[i] === '+') {
  const top = stack.pop();
  const bottom = stack.pop();
  // Add if numeric. Concatenate otherwise.
  if (!isNaN(top) && !isNaN(bottom)) {
    stack.push(Number(top) + Number(bottom));
  } else {
    stack.push(bottom + top);
  }
}

I'll work up a PR.

typed "=sum(a5:a8)" in position a9, hit enter, and the demo crashed

This is amazing and fast. I'm complaining about it actually being easily broken only because I really wished this worked well, so I could build on it. It crashed for me on literally the very first thing I tried. I opened up the demo page, typed in 4 numbers in a column (in positions a5,a6,a7,a8), then typed "=sum(a5:a8)" in position a9, hit enter, and the demo crashed (with canvas all messed up). There's a traceback in the console log that starts "Uncaught TypeError: Cannot read property 'render' of undefined at cell.js:146". I'm using Chrome 71. I refreshed and tried the same test and it crashed again.

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.