基于Web的JavaScript电子表格插件

插件特效
2026-07-26 04:18 3 次浏览 • 0 次下载 27.5KB
基于Web的JavaScript电子表格插件

快速使用

html

1
<div id="x-spreadsheet-demo"></div>

js

1
2
3
4
5
6
7
8
9
import Spreadsheet from "x-data-spreadsheet";
// 如果需要覆盖默认选项,可以设置覆盖
// const options = {};
// new Spreadsheet('#x-spreadsheet-demo', options);
new Spreadsheet("#x-spreadsheet-demo")
.loadData({}) // load data
.change(data => {
// 将数据保存到db
});

默认选项

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{
showToolbar: true,
showGrid: 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,
},
},
}