Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问本项目和 X-Spreadsheet 项目是什么关系? #5

Open
zwdgit opened this issue Jun 24, 2023 · 3 comments
Open

请问本项目和 X-Spreadsheet 项目是什么关系? #5

zwdgit opened this issue Jun 24, 2023 · 3 comments

Comments

@zwdgit
Copy link

zwdgit commented Jun 24, 2023

X-Spreadsheet 项目简介说已经迁移到本项目了,但是发现本项目目前还只有一些基础功能,没有发现像工具栏、右键菜单、Sheet页等功能

@myliang
Copy link
Contributor

myliang commented Jun 30, 2023

这些功能可以通过api自己去实现

@parkb83
Copy link

parkb83 commented Mar 4, 2024

Hello, would it be possible to provide an example of how to implement these functions through the API, perhaps the right click menu would be a good example to provide.
Thanks

@myliang
Copy link
Contributor

myliang commented Mar 6, 2024

Hello, would it be possible to provide an example of how to implement these functions through the API, perhaps the right click menu would be a good example to provide. Thanks

import WolfTable, { h } from './src';

const t = WolfTable.create(
  '#table',
  () => 1400,
  () => 600,
  {
    scrollable: true,
    resizable: true,
    selectable: true,
    editable: true,
    copyable: true,
  }
)
  .freeze('D5')
  .merge('F10:G11')
  .merge('I10:K11')
  .addBorder('E8:L12', 'all', 'medium', '#21ba45')
  .formulaParser((v) => `${v}-formula`)
  .data({
    styles: [
      {
        bold: true,
        strikethrough: true,
        color: '#21ba45',
        italic: true,
        align: 'center',
        fontSize: 12,
      },
    ],
    cells: [
      [0, 0, 'abc'],
      [1, 1, 100],
      [2, 6, { value: 'formua', style: 0 }],
      [9, 5, { value: '', formula: '=sum(A1:A10)' }],
    ],
  })
  .onClick((cell, evt) => {
    // console.log('cell:', cell, evt);
  })
  .onContextmenu((cell, evt) => {
    console.log('contetmenu:', cell);
    const { x, y, width, height } = cell;
    const content = h('div')
      .css({ background: '#ddd', padding: '10px', 'z-index': '100' })
      .css({
        left: x,
        top: y,
        width,
        height,
        position: 'absolute',
      });
    content.html('---abc--');
    t.container().append(content);
  })
  .render();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants