@univerjs/sheets-table 0.7.0 → 0.8.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +1 -1
- package/lib/es/facade.js +113 -32
- package/lib/facade.js +113 -32
- package/lib/types/facade/f-enum.d.ts +23 -0
- package/lib/types/facade/f-workbook.d.ts +120 -36
- package/lib/types/facade/f-worksheet.d.ts +291 -5
- package/lib/types/facade/index.d.ts +1 -0
- package/lib/umd/facade.js +1 -1
- package/package.json +5 -5
package/lib/cjs/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const a=require("@univerjs/sheets-table"),d=require("@univerjs/sheets/facade"),c=require("@univerjs/core"),h=require("@univerjs/sheets"),T=require("@univerjs/core/facade");class g extends d.FWorkbook{getTableInfo(e){const t=this.getId();return this._injector.get(a.SheetTableService).getTableInfo(t,e)}getTableList(){const e=this.getId();return this._injector.get(a.SheetTableService).getTableList(e)}async addTable(e,t,n,i,o){var b;const s=this._injector.get(a.SheetTableService),r={unitId:this.getId(),name:t,subUnitId:e,range:n,options:o,id:i};if(await this._commandService.executeCommand(a.AddSheetTableCommand.id,r))return(b=s.getTableList(this.getId()).find(u=>u.name===t))==null?void 0:b.id}async removeTable(e){var i;const t=(i=this.getTableInfo(e))==null?void 0:i.subUnitId;if(!t)return!1;const n={unitId:this.getId(),subUnitId:t,tableId:e};return this._commandService.executeCommand(a.DeleteSheetTableCommand.id,n)}getTableInfoByName(e){return this.getTableList().find(n=>n.name===e)}setTableFilter(e,t,n){const i={unitId:this.getId(),tableId:e,column:t,tableFilter:n};return this._commandService.executeCommand(a.SetSheetTableFilterCommand.id,i)}}d.FWorkbook.extend(g);class S extends d.FWorksheet{addTable(e,t,n,i){const o=this.getSheetId(),r={unitId:this.getWorkbook().getUnitId(),subUnitId:o,name:e,range:t,id:n,options:i};return this._commandService.executeCommand(a.AddSheetTableCommand.id,r)}setTableFilter(e,t,n){const i={unitId:this.getWorkbook().getUnitId(),tableId:e,column:t,tableFilter:n};return this._commandService.executeCommand(a.SetSheetTableFilterCommand.id,i)}removeTable(e){const t={unitId:this._fWorkbook.getId(),subUnitId:this.getSheetId(),tableId:e};return this._commandService.executeCommand(a.DeleteSheetTableCommand.id,t)}setTableRange(e,t){const n={unitId:this.getWorkbook().getUnitId(),tableId:e,updateRange:{newRange:t}};return this._commandService.executeCommand(a.SetSheetTableCommand.id,n)}setTableName(e,t){const n={unitId:this.getWorkbook().getUnitId(),tableId:e,name:t};return this._commandService.executeCommand(a.SetSheetTableCommand.id,n)}getSubTableInfos(){const e=this._fWorkbook.getId();return this._injector.get(a.SheetTableService).getTableList(e).filter(n=>n.subUnitId===this.getSheetId())}resetFilter(e,t){const n={unitId:this._fWorkbook.getId(),tableId:e,column:t,tableFilter:void 0};return this._commandService.executeCommand(a.SetSheetTableFilterCommand.id,n)}getTableByCell(e,t){const n=this._fWorkbook.getId(),o=this._injector.get(a.SheetTableService).getTableList(n).filter(r=>r.subUnitId===this.getSheetId()),s=c.cellToRange(e,t);return o.find(r=>{const m=r.range;return c.Rectangle.intersects(m,s)})}addTableTheme(e,t){const n=new h.RangeThemeStyle("table-style");return n.fromJson(t),this._commandService.executeCommand(a.AddTableThemeCommand.id,{unitId:this._fWorkbook.getId(),tableId:e,themeStyle:n})}}d.FWorksheet.extend(S);class I extends T.FEnum{get TableColumnFilterTypeEnum(){return a.TableColumnFilterTypeEnum}get TableConditionTypeEnum(){return a.TableConditionTypeEnum}get TableNumberCompareTypeEnum(){return a.TableNumberCompareTypeEnum}get TableStringCompareTypeEnum(){return a.TableStringCompareTypeEnum}get TableDateCompareTypeEnum(){return a.TableDateCompareTypeEnum}}T.FEnum.extend(I);
|
package/lib/es/facade.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { SheetTableService as o, AddSheetTableCommand as
|
|
2
|
-
import { FWorkbook as
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { SheetTableService as o, AddSheetTableCommand as u, DeleteSheetTableCommand as T, SetSheetTableFilterCommand as d, SetSheetTableCommand as c, AddTableThemeCommand as C, TableColumnFilterTypeEnum as f, TableConditionTypeEnum as v, TableNumberCompareTypeEnum as k, TableStringCompareTypeEnum as p, TableDateCompareTypeEnum as _ } from "@univerjs/sheets-table";
|
|
2
|
+
import { FWorkbook as h, FWorksheet as g } from "@univerjs/sheets/facade";
|
|
3
|
+
import { cellToRange as x, Rectangle as y } from "@univerjs/core";
|
|
4
|
+
import { RangeThemeStyle as F } from "@univerjs/sheets";
|
|
5
|
+
import { FEnum as I } from "@univerjs/core/facade";
|
|
6
|
+
class W extends h {
|
|
5
7
|
getTableInfo(e) {
|
|
6
8
|
const t = this.getId();
|
|
7
9
|
return this._injector.get(o).getTableInfo(t, e);
|
|
@@ -10,58 +12,137 @@ class v extends m {
|
|
|
10
12
|
const e = this.getId();
|
|
11
13
|
return this._injector.get(o).getTableList(e);
|
|
12
14
|
}
|
|
13
|
-
async addTable(e, t,
|
|
14
|
-
var
|
|
15
|
-
const
|
|
15
|
+
async addTable(e, t, n, i, r) {
|
|
16
|
+
var b;
|
|
17
|
+
const s = this._injector.get(o), a = {
|
|
16
18
|
unitId: this.getId(),
|
|
17
19
|
name: t,
|
|
18
20
|
subUnitId: e,
|
|
19
|
-
range:
|
|
20
|
-
options:
|
|
21
|
-
|
|
21
|
+
range: n,
|
|
22
|
+
options: r,
|
|
23
|
+
id: i
|
|
22
24
|
};
|
|
23
|
-
if (await this._commandService.executeCommand(
|
|
24
|
-
return (
|
|
25
|
+
if (await this._commandService.executeCommand(u.id, a))
|
|
26
|
+
return (b = s.getTableList(this.getId()).find((S) => S.name === t)) == null ? void 0 : b.id;
|
|
25
27
|
}
|
|
26
28
|
async removeTable(e) {
|
|
27
|
-
var
|
|
28
|
-
const t = (
|
|
29
|
+
var i;
|
|
30
|
+
const t = (i = this.getTableInfo(e)) == null ? void 0 : i.subUnitId;
|
|
29
31
|
if (!t)
|
|
30
32
|
return !1;
|
|
31
|
-
const
|
|
33
|
+
const n = {
|
|
32
34
|
unitId: this.getId(),
|
|
33
35
|
subUnitId: t,
|
|
34
36
|
tableId: e
|
|
35
37
|
};
|
|
36
|
-
return this._commandService.executeCommand(
|
|
38
|
+
return this._commandService.executeCommand(T.id, n);
|
|
37
39
|
}
|
|
38
40
|
getTableInfoByName(e) {
|
|
39
|
-
return this.getTableList().find((
|
|
41
|
+
return this.getTableList().find((n) => n.name === e);
|
|
40
42
|
}
|
|
41
|
-
setTableFilter(e, t,
|
|
42
|
-
const
|
|
43
|
+
setTableFilter(e, t, n) {
|
|
44
|
+
const i = {
|
|
43
45
|
unitId: this.getId(),
|
|
44
46
|
tableId: e,
|
|
45
47
|
column: t,
|
|
46
|
-
tableFilter:
|
|
48
|
+
tableFilter: n
|
|
47
49
|
};
|
|
48
|
-
return this._commandService.executeCommand(
|
|
50
|
+
return this._commandService.executeCommand(d.id, i);
|
|
49
51
|
}
|
|
50
52
|
}
|
|
51
|
-
|
|
52
|
-
class
|
|
53
|
-
addTable(e, t,
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
h.extend(W);
|
|
54
|
+
class E extends g {
|
|
55
|
+
addTable(e, t, n, i) {
|
|
56
|
+
const r = this.getSheetId(), a = {
|
|
57
|
+
unitId: this.getWorkbook().getUnitId(),
|
|
58
|
+
subUnitId: r,
|
|
59
|
+
name: e,
|
|
60
|
+
range: t,
|
|
61
|
+
id: n,
|
|
62
|
+
options: i
|
|
63
|
+
};
|
|
64
|
+
return this._commandService.executeCommand(u.id, a);
|
|
65
|
+
}
|
|
66
|
+
setTableFilter(e, t, n) {
|
|
67
|
+
const i = {
|
|
59
68
|
unitId: this.getWorkbook().getUnitId(),
|
|
60
69
|
tableId: e,
|
|
61
70
|
column: t,
|
|
62
|
-
tableFilter:
|
|
71
|
+
tableFilter: n
|
|
72
|
+
};
|
|
73
|
+
return this._commandService.executeCommand(d.id, i);
|
|
74
|
+
}
|
|
75
|
+
removeTable(e) {
|
|
76
|
+
const t = {
|
|
77
|
+
unitId: this._fWorkbook.getId(),
|
|
78
|
+
subUnitId: this.getSheetId(),
|
|
79
|
+
tableId: e
|
|
80
|
+
};
|
|
81
|
+
return this._commandService.executeCommand(T.id, t);
|
|
82
|
+
}
|
|
83
|
+
setTableRange(e, t) {
|
|
84
|
+
const n = {
|
|
85
|
+
unitId: this.getWorkbook().getUnitId(),
|
|
86
|
+
tableId: e,
|
|
87
|
+
updateRange: {
|
|
88
|
+
newRange: t
|
|
89
|
+
}
|
|
63
90
|
};
|
|
64
|
-
return this._commandService.executeCommand(
|
|
91
|
+
return this._commandService.executeCommand(c.id, n);
|
|
92
|
+
}
|
|
93
|
+
setTableName(e, t) {
|
|
94
|
+
const n = {
|
|
95
|
+
unitId: this.getWorkbook().getUnitId(),
|
|
96
|
+
tableId: e,
|
|
97
|
+
name: t
|
|
98
|
+
};
|
|
99
|
+
return this._commandService.executeCommand(c.id, n);
|
|
100
|
+
}
|
|
101
|
+
getSubTableInfos() {
|
|
102
|
+
const e = this._fWorkbook.getId();
|
|
103
|
+
return this._injector.get(o).getTableList(e).filter((n) => n.subUnitId === this.getSheetId());
|
|
104
|
+
}
|
|
105
|
+
resetFilter(e, t) {
|
|
106
|
+
const n = {
|
|
107
|
+
unitId: this._fWorkbook.getId(),
|
|
108
|
+
tableId: e,
|
|
109
|
+
column: t,
|
|
110
|
+
tableFilter: void 0
|
|
111
|
+
};
|
|
112
|
+
return this._commandService.executeCommand(d.id, n);
|
|
113
|
+
}
|
|
114
|
+
getTableByCell(e, t) {
|
|
115
|
+
const n = this._fWorkbook.getId(), r = this._injector.get(o).getTableList(n).filter((a) => a.subUnitId === this.getSheetId()), s = x(e, t);
|
|
116
|
+
return r.find((a) => {
|
|
117
|
+
const l = a.range;
|
|
118
|
+
return y.intersects(l, s);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
addTableTheme(e, t) {
|
|
122
|
+
const n = new F("table-style");
|
|
123
|
+
return n.fromJson(t), this._commandService.executeCommand(C.id, {
|
|
124
|
+
unitId: this._fWorkbook.getId(),
|
|
125
|
+
tableId: e,
|
|
126
|
+
themeStyle: n
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
g.extend(E);
|
|
131
|
+
class U extends I {
|
|
132
|
+
get TableColumnFilterTypeEnum() {
|
|
133
|
+
return f;
|
|
134
|
+
}
|
|
135
|
+
get TableConditionTypeEnum() {
|
|
136
|
+
return v;
|
|
137
|
+
}
|
|
138
|
+
get TableNumberCompareTypeEnum() {
|
|
139
|
+
return k;
|
|
140
|
+
}
|
|
141
|
+
get TableStringCompareTypeEnum() {
|
|
142
|
+
return p;
|
|
143
|
+
}
|
|
144
|
+
get TableDateCompareTypeEnum() {
|
|
145
|
+
return _;
|
|
65
146
|
}
|
|
66
147
|
}
|
|
67
|
-
|
|
148
|
+
I.extend(U);
|
package/lib/facade.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { SheetTableService as o, AddSheetTableCommand as
|
|
2
|
-
import { FWorkbook as
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { SheetTableService as o, AddSheetTableCommand as u, DeleteSheetTableCommand as T, SetSheetTableFilterCommand as d, SetSheetTableCommand as c, AddTableThemeCommand as C, TableColumnFilterTypeEnum as f, TableConditionTypeEnum as v, TableNumberCompareTypeEnum as k, TableStringCompareTypeEnum as p, TableDateCompareTypeEnum as _ } from "@univerjs/sheets-table";
|
|
2
|
+
import { FWorkbook as h, FWorksheet as g } from "@univerjs/sheets/facade";
|
|
3
|
+
import { cellToRange as x, Rectangle as y } from "@univerjs/core";
|
|
4
|
+
import { RangeThemeStyle as F } from "@univerjs/sheets";
|
|
5
|
+
import { FEnum as I } from "@univerjs/core/facade";
|
|
6
|
+
class W extends h {
|
|
5
7
|
getTableInfo(e) {
|
|
6
8
|
const t = this.getId();
|
|
7
9
|
return this._injector.get(o).getTableInfo(t, e);
|
|
@@ -10,58 +12,137 @@ class v extends m {
|
|
|
10
12
|
const e = this.getId();
|
|
11
13
|
return this._injector.get(o).getTableList(e);
|
|
12
14
|
}
|
|
13
|
-
async addTable(e, t,
|
|
14
|
-
var
|
|
15
|
-
const
|
|
15
|
+
async addTable(e, t, n, i, r) {
|
|
16
|
+
var b;
|
|
17
|
+
const s = this._injector.get(o), a = {
|
|
16
18
|
unitId: this.getId(),
|
|
17
19
|
name: t,
|
|
18
20
|
subUnitId: e,
|
|
19
|
-
range:
|
|
20
|
-
options:
|
|
21
|
-
|
|
21
|
+
range: n,
|
|
22
|
+
options: r,
|
|
23
|
+
id: i
|
|
22
24
|
};
|
|
23
|
-
if (await this._commandService.executeCommand(
|
|
24
|
-
return (
|
|
25
|
+
if (await this._commandService.executeCommand(u.id, a))
|
|
26
|
+
return (b = s.getTableList(this.getId()).find((S) => S.name === t)) == null ? void 0 : b.id;
|
|
25
27
|
}
|
|
26
28
|
async removeTable(e) {
|
|
27
|
-
var
|
|
28
|
-
const t = (
|
|
29
|
+
var i;
|
|
30
|
+
const t = (i = this.getTableInfo(e)) == null ? void 0 : i.subUnitId;
|
|
29
31
|
if (!t)
|
|
30
32
|
return !1;
|
|
31
|
-
const
|
|
33
|
+
const n = {
|
|
32
34
|
unitId: this.getId(),
|
|
33
35
|
subUnitId: t,
|
|
34
36
|
tableId: e
|
|
35
37
|
};
|
|
36
|
-
return this._commandService.executeCommand(
|
|
38
|
+
return this._commandService.executeCommand(T.id, n);
|
|
37
39
|
}
|
|
38
40
|
getTableInfoByName(e) {
|
|
39
|
-
return this.getTableList().find((
|
|
41
|
+
return this.getTableList().find((n) => n.name === e);
|
|
40
42
|
}
|
|
41
|
-
setTableFilter(e, t,
|
|
42
|
-
const
|
|
43
|
+
setTableFilter(e, t, n) {
|
|
44
|
+
const i = {
|
|
43
45
|
unitId: this.getId(),
|
|
44
46
|
tableId: e,
|
|
45
47
|
column: t,
|
|
46
|
-
tableFilter:
|
|
48
|
+
tableFilter: n
|
|
47
49
|
};
|
|
48
|
-
return this._commandService.executeCommand(
|
|
50
|
+
return this._commandService.executeCommand(d.id, i);
|
|
49
51
|
}
|
|
50
52
|
}
|
|
51
|
-
|
|
52
|
-
class
|
|
53
|
-
addTable(e, t,
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
h.extend(W);
|
|
54
|
+
class E extends g {
|
|
55
|
+
addTable(e, t, n, i) {
|
|
56
|
+
const r = this.getSheetId(), a = {
|
|
57
|
+
unitId: this.getWorkbook().getUnitId(),
|
|
58
|
+
subUnitId: r,
|
|
59
|
+
name: e,
|
|
60
|
+
range: t,
|
|
61
|
+
id: n,
|
|
62
|
+
options: i
|
|
63
|
+
};
|
|
64
|
+
return this._commandService.executeCommand(u.id, a);
|
|
65
|
+
}
|
|
66
|
+
setTableFilter(e, t, n) {
|
|
67
|
+
const i = {
|
|
59
68
|
unitId: this.getWorkbook().getUnitId(),
|
|
60
69
|
tableId: e,
|
|
61
70
|
column: t,
|
|
62
|
-
tableFilter:
|
|
71
|
+
tableFilter: n
|
|
72
|
+
};
|
|
73
|
+
return this._commandService.executeCommand(d.id, i);
|
|
74
|
+
}
|
|
75
|
+
removeTable(e) {
|
|
76
|
+
const t = {
|
|
77
|
+
unitId: this._fWorkbook.getId(),
|
|
78
|
+
subUnitId: this.getSheetId(),
|
|
79
|
+
tableId: e
|
|
80
|
+
};
|
|
81
|
+
return this._commandService.executeCommand(T.id, t);
|
|
82
|
+
}
|
|
83
|
+
setTableRange(e, t) {
|
|
84
|
+
const n = {
|
|
85
|
+
unitId: this.getWorkbook().getUnitId(),
|
|
86
|
+
tableId: e,
|
|
87
|
+
updateRange: {
|
|
88
|
+
newRange: t
|
|
89
|
+
}
|
|
63
90
|
};
|
|
64
|
-
return this._commandService.executeCommand(
|
|
91
|
+
return this._commandService.executeCommand(c.id, n);
|
|
92
|
+
}
|
|
93
|
+
setTableName(e, t) {
|
|
94
|
+
const n = {
|
|
95
|
+
unitId: this.getWorkbook().getUnitId(),
|
|
96
|
+
tableId: e,
|
|
97
|
+
name: t
|
|
98
|
+
};
|
|
99
|
+
return this._commandService.executeCommand(c.id, n);
|
|
100
|
+
}
|
|
101
|
+
getSubTableInfos() {
|
|
102
|
+
const e = this._fWorkbook.getId();
|
|
103
|
+
return this._injector.get(o).getTableList(e).filter((n) => n.subUnitId === this.getSheetId());
|
|
104
|
+
}
|
|
105
|
+
resetFilter(e, t) {
|
|
106
|
+
const n = {
|
|
107
|
+
unitId: this._fWorkbook.getId(),
|
|
108
|
+
tableId: e,
|
|
109
|
+
column: t,
|
|
110
|
+
tableFilter: void 0
|
|
111
|
+
};
|
|
112
|
+
return this._commandService.executeCommand(d.id, n);
|
|
113
|
+
}
|
|
114
|
+
getTableByCell(e, t) {
|
|
115
|
+
const n = this._fWorkbook.getId(), r = this._injector.get(o).getTableList(n).filter((a) => a.subUnitId === this.getSheetId()), s = x(e, t);
|
|
116
|
+
return r.find((a) => {
|
|
117
|
+
const l = a.range;
|
|
118
|
+
return y.intersects(l, s);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
addTableTheme(e, t) {
|
|
122
|
+
const n = new F("table-style");
|
|
123
|
+
return n.fromJson(t), this._commandService.executeCommand(C.id, {
|
|
124
|
+
unitId: this._fWorkbook.getId(),
|
|
125
|
+
tableId: e,
|
|
126
|
+
themeStyle: n
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
g.extend(E);
|
|
131
|
+
class U extends I {
|
|
132
|
+
get TableColumnFilterTypeEnum() {
|
|
133
|
+
return f;
|
|
134
|
+
}
|
|
135
|
+
get TableConditionTypeEnum() {
|
|
136
|
+
return v;
|
|
137
|
+
}
|
|
138
|
+
get TableNumberCompareTypeEnum() {
|
|
139
|
+
return k;
|
|
140
|
+
}
|
|
141
|
+
get TableStringCompareTypeEnum() {
|
|
142
|
+
return p;
|
|
143
|
+
}
|
|
144
|
+
get TableDateCompareTypeEnum() {
|
|
145
|
+
return _;
|
|
65
146
|
}
|
|
66
147
|
}
|
|
67
|
-
|
|
148
|
+
I.extend(U);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FEnum } from '@univerjs/core/facade';
|
|
2
|
+
import { TableColumnFilterTypeEnum, TableConditionTypeEnum, TableDateCompareTypeEnum, TableNumberCompareTypeEnum, TableStringCompareTypeEnum } from '@univerjs/sheets-table';
|
|
3
|
+
/**
|
|
4
|
+
* @ignore
|
|
5
|
+
*/
|
|
6
|
+
export interface ITableEnumMixin {
|
|
7
|
+
TableColumnFilterTypeEnum: typeof TableColumnFilterTypeEnum;
|
|
8
|
+
TableConditionTypeEnum: typeof TableConditionTypeEnum;
|
|
9
|
+
TableNumberCompareTypeEnum: typeof TableNumberCompareTypeEnum;
|
|
10
|
+
TableStringCompareTypeEnum: typeof TableStringCompareTypeEnum;
|
|
11
|
+
TableDateCompareTypeEnum: typeof TableDateCompareTypeEnum;
|
|
12
|
+
}
|
|
13
|
+
export declare class TableEnum extends FEnum implements ITableEnumMixin {
|
|
14
|
+
get TableColumnFilterTypeEnum(): typeof TableColumnFilterTypeEnum;
|
|
15
|
+
get TableConditionTypeEnum(): typeof TableConditionTypeEnum;
|
|
16
|
+
get TableNumberCompareTypeEnum(): typeof TableNumberCompareTypeEnum;
|
|
17
|
+
get TableStringCompareTypeEnum(): typeof TableStringCompareTypeEnum;
|
|
18
|
+
get TableDateCompareTypeEnum(): typeof TableDateCompareTypeEnum;
|
|
19
|
+
}
|
|
20
|
+
declare module '@univerjs/core/facade' {
|
|
21
|
+
interface FEnum extends ITableEnumMixin {
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -11,21 +11,52 @@ export interface IFWorkbookSheetsTableMixin {
|
|
|
11
11
|
* @example
|
|
12
12
|
* ```typescript
|
|
13
13
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
14
|
-
* const
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
14
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
15
|
+
*
|
|
16
|
+
* // Insert a table in the range B2:F11
|
|
17
|
+
* const fRange = fWorksheet.getRange('B2:F11');
|
|
18
|
+
* const success = await fWorksheet.addTable(
|
|
19
|
+
* 'name-1',
|
|
20
|
+
* fRange.getRange(),
|
|
21
|
+
* 'id-1',
|
|
22
|
+
* {
|
|
23
|
+
* showHeader: true,
|
|
24
|
+
* }
|
|
25
|
+
* );
|
|
26
|
+
*
|
|
27
|
+
* if (success) {
|
|
28
|
+
* const tableInfo = fWorkbook.getTableInfo('id-1');
|
|
29
|
+
* console.log('debugger tableInfo', tableInfo);
|
|
30
|
+
* }
|
|
26
31
|
* ```
|
|
27
32
|
*/
|
|
28
33
|
getTableInfo(tableId: string): ITableInfoWithUnitId | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Get table information by name
|
|
36
|
+
* @param {string} tableName The table name
|
|
37
|
+
* @returns {ITableInfo} The table information
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
41
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
42
|
+
*
|
|
43
|
+
* // Insert a table in the range B2:F11
|
|
44
|
+
* const fRange = fWorksheet.getRange('B2:F11');
|
|
45
|
+
* const success = await fWorksheet.addTable(
|
|
46
|
+
* 'name-1',
|
|
47
|
+
* fRange.getRange(),
|
|
48
|
+
* 'id-1',
|
|
49
|
+
* {
|
|
50
|
+
* showHeader: true,
|
|
51
|
+
* }
|
|
52
|
+
* );
|
|
53
|
+
*
|
|
54
|
+
* if (success) {
|
|
55
|
+
* const tableInfo = fWorkbook.getTableInfoByName('name-1');
|
|
56
|
+
* console.log('debugger tableInfo', tableInfo);
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
29
60
|
getTableInfoByName(tableName: string): ITableInfoWithUnitId | undefined;
|
|
30
61
|
/**
|
|
31
62
|
* Get table list
|
|
@@ -33,45 +64,98 @@ export interface IFWorkbookSheetsTableMixin {
|
|
|
33
64
|
* @example
|
|
34
65
|
* ```typescript
|
|
35
66
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
36
|
-
* const
|
|
37
|
-
*
|
|
38
|
-
* unitId: fWorkbook.getId(),
|
|
39
|
-
* subUnitId:fSheet.getSheetId(),
|
|
40
|
-
* range: {
|
|
41
|
-
* startRow: 1,
|
|
42
|
-
* startColumn: 1,
|
|
43
|
-
* endRow: 10,
|
|
44
|
-
* endColumn: 5,
|
|
45
|
-
* },
|
|
46
|
-
* }, { showHeader: true });
|
|
47
|
-
* const tableList = fWorkbook.getTableList(fWorkbook.getId());
|
|
67
|
+
* const tables = fWorkbook.getTableList();
|
|
68
|
+
* console.log('debugger tables', tables);
|
|
48
69
|
* ```
|
|
49
70
|
*/
|
|
50
71
|
getTableList(): ITableInfo[];
|
|
51
72
|
/**
|
|
52
73
|
* Add table
|
|
74
|
+
* @param {string} subUnitId The sub unit id
|
|
53
75
|
* @param {string} tableName The table name
|
|
54
76
|
* @param {ITableRange} rangeInfo The table range information
|
|
55
|
-
* @param {
|
|
77
|
+
* @param {string} [tableId] The table id
|
|
78
|
+
* @param {ITableOptions} [options] The table options
|
|
56
79
|
* @returns {string} The table id
|
|
57
80
|
* @example
|
|
58
81
|
* ```typescript
|
|
59
82
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
60
|
-
* const
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
83
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
84
|
+
*
|
|
85
|
+
* // Insert a table in the range B2:F11
|
|
86
|
+
* const fRange = fWorksheet.getRange('B2:F11');
|
|
87
|
+
* const id = await fWorkbook.addTable(
|
|
88
|
+
* fWorksheet.getSheetId(),
|
|
89
|
+
* 'name-1',
|
|
90
|
+
* fRange.getRange(),
|
|
91
|
+
* 'id-1',
|
|
92
|
+
* {
|
|
93
|
+
* showHeader: true,
|
|
94
|
+
* }
|
|
95
|
+
* );
|
|
96
|
+
*
|
|
97
|
+
* if (id) {
|
|
98
|
+
* const tableInfo = fWorkbook.getTableInfo(id);
|
|
99
|
+
* console.log('debugger tableInfo', tableInfo);
|
|
100
|
+
* }
|
|
71
101
|
* ```
|
|
72
102
|
*/
|
|
73
103
|
addTable(subUnitId: string, tableName: string, rangeInfo: ITableRange, tableId?: string, options?: ITableOptions): Promise<string | undefined>;
|
|
104
|
+
/**
|
|
105
|
+
* set table filter
|
|
106
|
+
* @param {string} tableId The table id
|
|
107
|
+
* @param {number} column The column index, starting from 0.
|
|
108
|
+
* @param {ITableFilterItem} filter The filter item
|
|
109
|
+
* @returns {Promise<boolean>} The result of set table filter
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
113
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
114
|
+
*
|
|
115
|
+
* // Insert a table in the range B2:F11
|
|
116
|
+
* const fRange = fWorksheet.getRange('B2:F11');
|
|
117
|
+
* const success = await fWorksheet.addTable(
|
|
118
|
+
* 'name-1',
|
|
119
|
+
* fRange.getRange(),
|
|
120
|
+
* 'id-1',
|
|
121
|
+
* {
|
|
122
|
+
* showHeader: true,
|
|
123
|
+
* }
|
|
124
|
+
* );
|
|
125
|
+
*
|
|
126
|
+
* if (success) {
|
|
127
|
+
* // Set the filter for the second column
|
|
128
|
+
* await fWorkbook.setTableFilter('id-1', 1, {
|
|
129
|
+
* filterType: univerAPI.Enum.TableColumnFilterTypeEnum.condition,
|
|
130
|
+
* filterInfo: {
|
|
131
|
+
* conditionType: univerAPI.Enum.TableConditionTypeEnum.Number,
|
|
132
|
+
* compareType: univerAPI.Enum.TableNumberCompareTypeEnum.GreaterThan,
|
|
133
|
+
* expectedValue: 10,
|
|
134
|
+
* },
|
|
135
|
+
* });
|
|
136
|
+
*
|
|
137
|
+
* const tableInfo = fWorkbook.getTableInfo('id-1');
|
|
138
|
+
* console.log('debugger tableInfo', tableInfo);
|
|
139
|
+
* }
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
74
142
|
setTableFilter(tableId: string, column: number, filter: ITableFilterItem | undefined): void;
|
|
143
|
+
/**
|
|
144
|
+
* Remove table
|
|
145
|
+
* @param {string} tableId The table id
|
|
146
|
+
* @returns {boolean} The result of remove table
|
|
147
|
+
* @example
|
|
148
|
+
* ```typescript
|
|
149
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
150
|
+
* const tableInfo = fWorkbook.getTableInfo('id-1');
|
|
151
|
+
* console.log('debugger tableInfo', tableInfo);
|
|
152
|
+
*
|
|
153
|
+
* if (tableInfo) {
|
|
154
|
+
* // Remove the table with the specified id
|
|
155
|
+
* await fWorkbook.removeTable('id-1');
|
|
156
|
+
* }
|
|
157
|
+
* ```
|
|
158
|
+
*/
|
|
75
159
|
removeTable(tableId: string): Promise<boolean>;
|
|
76
160
|
}
|
|
77
161
|
export declare class FWorkbookSheetsTableMixin extends FWorkbook implements IFWorkbookSheetsTableMixin {
|
|
@@ -1,15 +1,301 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IRangeThemeStyleJSON } from '@univerjs/sheets';
|
|
2
|
+
import { ITableFilterItem, ITableInfoWithUnitId, ITableOptions, ITableRange } from '@univerjs/sheets-table';
|
|
2
3
|
import { FWorksheet } from '@univerjs/sheets/facade';
|
|
3
4
|
/**
|
|
4
5
|
* @ignore
|
|
5
6
|
*/
|
|
6
7
|
export interface IFWorkSheetTableMixin {
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Add a table to the worksheet
|
|
10
|
+
* @param {string} tableName The table name
|
|
11
|
+
* @param {ITableRange} rangeInfo The table range information
|
|
12
|
+
* @param {string} [tableId] The table id
|
|
13
|
+
* @param {ITableOptions} [options] The table options
|
|
14
|
+
* @returns {Promise<boolean>} Whether the table was added successfully
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
18
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
19
|
+
*
|
|
20
|
+
* // Insert a table in the range B2:F11
|
|
21
|
+
* const fRange = fWorksheet.getRange('B2:F11');
|
|
22
|
+
* const success = await fWorksheet.addTable(
|
|
23
|
+
* 'name-1',
|
|
24
|
+
* fRange.getRange(),
|
|
25
|
+
* 'id-1',
|
|
26
|
+
* {
|
|
27
|
+
* showHeader: true,
|
|
28
|
+
* }
|
|
29
|
+
* );
|
|
30
|
+
*
|
|
31
|
+
* if (success) {
|
|
32
|
+
* const tableInfo = fWorkbook.getTableInfo('id-1');
|
|
33
|
+
* console.log('debugger tableInfo', tableInfo);
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
addTable(tableName: string, rangeInfo: ITableRange, tableId?: string, options?: ITableOptions): Promise<boolean>;
|
|
38
|
+
/**
|
|
39
|
+
* Set the filter for a table column
|
|
40
|
+
* @param {string} tableId The table id
|
|
41
|
+
* @param {number} column The table column index, starting from 0. For example, the first column is 0, the second column is 1, and so on.
|
|
42
|
+
* @param {ITableFilterItem} filter The filter item
|
|
43
|
+
* @returns {Promise<boolean>} Whether the table filter was set successfully
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
47
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
48
|
+
*
|
|
49
|
+
* // Insert a table in the range B2:F11
|
|
50
|
+
* const fRange = fWorksheet.getRange('B2:F11');
|
|
51
|
+
* const success = await fWorksheet.addTable(
|
|
52
|
+
* 'name-1',
|
|
53
|
+
* fRange.getRange(),
|
|
54
|
+
* 'id-1',
|
|
55
|
+
* {
|
|
56
|
+
* showHeader: true,
|
|
57
|
+
* }
|
|
58
|
+
* );
|
|
59
|
+
*
|
|
60
|
+
* if (success) {
|
|
61
|
+
* // Set the filter for the second column
|
|
62
|
+
* await fWorksheet.setTableFilter('id-1', 1, {
|
|
63
|
+
* filterType: univerAPI.Enum.TableColumnFilterTypeEnum.condition,
|
|
64
|
+
* filterInfo: {
|
|
65
|
+
* conditionType: univerAPI.Enum.TableConditionTypeEnum.Number,
|
|
66
|
+
* compareType: univerAPI.Enum.TableNumberCompareTypeEnum.GreaterThan,
|
|
67
|
+
* expectedValue: 10,
|
|
68
|
+
* },
|
|
69
|
+
* });
|
|
70
|
+
*
|
|
71
|
+
* const tableInfo = fWorkbook.getTableInfo('id-1');
|
|
72
|
+
* console.log('debugger tableInfo', tableInfo);
|
|
73
|
+
* }
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
setTableFilter(tableId: string, column: number, filter: ITableFilterItem): Promise<boolean>;
|
|
77
|
+
/**
|
|
78
|
+
* Remove a table from the worksheet
|
|
79
|
+
* @param {string} tableId The table id
|
|
80
|
+
* @returns {Promise<boolean>} Whether the table was removed successfully
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
84
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
85
|
+
* const tableInfo = fWorkbook.getTableInfo('id-1');
|
|
86
|
+
* console.log('debugger tableInfo', tableInfo);
|
|
87
|
+
*
|
|
88
|
+
* if (tableInfo) {
|
|
89
|
+
* // Remove the table with the specified id
|
|
90
|
+
* await fWorksheet.removeTable('id-1');
|
|
91
|
+
* }
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
removeTable(tableId: string): Promise<boolean>;
|
|
95
|
+
/**
|
|
96
|
+
* Set the range of a table
|
|
97
|
+
* @param {string} tableId The table id
|
|
98
|
+
* @param {ITableRange} rangeInfo The new range information
|
|
99
|
+
* @returns {Promise<boolean>} Whether the table range was set successfully
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
103
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
104
|
+
*
|
|
105
|
+
* // Insert a table in the range B2:F11
|
|
106
|
+
* const fRange = fWorksheet.getRange('B2:F11');
|
|
107
|
+
* const success = await fWorksheet.addTable(
|
|
108
|
+
* 'name-1',
|
|
109
|
+
* fRange.getRange(),
|
|
110
|
+
* 'id-1',
|
|
111
|
+
* {
|
|
112
|
+
* showHeader: true,
|
|
113
|
+
* }
|
|
114
|
+
* );
|
|
115
|
+
*
|
|
116
|
+
* if (success) {
|
|
117
|
+
* // Update the table range to B2:F21 after 3 seconds
|
|
118
|
+
* setTimeout(async () => {
|
|
119
|
+
* const newRange = fWorksheet.getRange('B2:F21');
|
|
120
|
+
* await fWorksheet.setTableRange('id-1', newRange.getRange());
|
|
121
|
+
*
|
|
122
|
+
* const tableInfo = fWorkbook.getTableInfo('id-1');
|
|
123
|
+
* console.log('debugger tableInfo', tableInfo);
|
|
124
|
+
* }, 3000);
|
|
125
|
+
* }
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
setTableRange(tableId: string, rangeInfo: ITableRange): Promise<boolean>;
|
|
129
|
+
/**
|
|
130
|
+
* Set the name of a table
|
|
131
|
+
* @param {string} tableId The table id
|
|
132
|
+
* @param {string} tableName The new table name
|
|
133
|
+
* @returns {Promise<boolean>} Whether the table name was set successfully
|
|
134
|
+
* @example
|
|
135
|
+
* ```typescript
|
|
136
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
137
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
138
|
+
*
|
|
139
|
+
* // Insert a table in the range B2:F11
|
|
140
|
+
* const fRange = fWorksheet.getRange('B2:F11');
|
|
141
|
+
* const success = await fWorksheet.addTable(
|
|
142
|
+
* 'name-1',
|
|
143
|
+
* fRange.getRange(),
|
|
144
|
+
* 'id-1',
|
|
145
|
+
* {
|
|
146
|
+
* showHeader: true,
|
|
147
|
+
* }
|
|
148
|
+
* );
|
|
149
|
+
*
|
|
150
|
+
* if (success) {
|
|
151
|
+
* // Update the table name after 3 seconds
|
|
152
|
+
* setTimeout(async () => {
|
|
153
|
+
* await fWorksheet.setTableName('id-1', 'new-name');
|
|
154
|
+
*
|
|
155
|
+
* const tableInfo = fWorkbook.getTableInfo('id-1');
|
|
156
|
+
* console.log('debugger tableInfo', tableInfo);
|
|
157
|
+
* }, 3000);
|
|
158
|
+
* }
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
setTableName(tableId: string, tableName: string): Promise<boolean>;
|
|
162
|
+
/**
|
|
163
|
+
* Get the list of tables in the worksheet
|
|
164
|
+
* @returns {ITableInfoWithUnitId[]} The list of tables
|
|
165
|
+
* @example
|
|
166
|
+
* ```typescript
|
|
167
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
168
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
169
|
+
* const tables = fWorksheet.getSubTableInfos();
|
|
170
|
+
* console.log('debugger tables', tables);
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
173
|
+
getSubTableInfos(): ITableInfoWithUnitId[];
|
|
174
|
+
/**
|
|
175
|
+
* Reset the column filter of a table
|
|
176
|
+
* @param {string} tableId The table id
|
|
177
|
+
* @param {number} column The column index, starting from 0. For example, the first column is 0, the second column is 1, and so on.
|
|
178
|
+
* @returns {Promise<boolean>} Whether the table filter was reset successfully
|
|
179
|
+
* @example
|
|
180
|
+
* ```typescript
|
|
181
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
182
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
183
|
+
*
|
|
184
|
+
* // Insert a table in the range B2:F11
|
|
185
|
+
* const fRange = fWorksheet.getRange('B2:F11');
|
|
186
|
+
* const success = await fWorksheet.addTable(
|
|
187
|
+
* 'name-1',
|
|
188
|
+
* fRange.getRange(),
|
|
189
|
+
* 'id-1',
|
|
190
|
+
* {
|
|
191
|
+
* showHeader: true,
|
|
192
|
+
* }
|
|
193
|
+
* );
|
|
194
|
+
*
|
|
195
|
+
* if (success) {
|
|
196
|
+
* // Set the filter for the second column
|
|
197
|
+
* await fWorksheet.setTableFilter('id-1', 1, {
|
|
198
|
+
* filterType: univerAPI.Enum.TableColumnFilterTypeEnum.condition,
|
|
199
|
+
* filterInfo: {
|
|
200
|
+
* conditionType: univerAPI.Enum.TableConditionTypeEnum.Number,
|
|
201
|
+
* compareType: univerAPI.Enum.TableNumberCompareTypeEnum.GreaterThan,
|
|
202
|
+
* expectedValue: 10,
|
|
203
|
+
* },
|
|
204
|
+
* });
|
|
205
|
+
*
|
|
206
|
+
* // Reset the filter for the second column after 3 seconds
|
|
207
|
+
* setTimeout(async () => {
|
|
208
|
+
* await fWorksheet.resetFilter('id-1', 1);
|
|
209
|
+
* }, 3000);
|
|
210
|
+
*
|
|
211
|
+
* const tableInfo = fWorkbook.getTableInfo('id-1');
|
|
212
|
+
* console.log('debugger tableInfo', tableInfo);
|
|
213
|
+
* }
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
resetFilter(tableId: string, column: number): Promise<boolean>;
|
|
217
|
+
/**
|
|
218
|
+
* Get the table information by cell position
|
|
219
|
+
* @param {number} row The cell row index, starting from 0.
|
|
220
|
+
* @param {number} column The cell column index, starting from 0.
|
|
221
|
+
* @returns {ITableInfoWithUnitId | undefined} The table information or undefined if not found
|
|
222
|
+
* @example
|
|
223
|
+
* ```typescript
|
|
224
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
225
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
226
|
+
*
|
|
227
|
+
* const cellB2 = fWorksheet.getRange('B2');
|
|
228
|
+
* const row = cellB2.getRow();
|
|
229
|
+
* const column = cellB2.getColumn();
|
|
230
|
+
* console.log('debugger tableInfo', fWorksheet.getTableByCell(row, column));
|
|
231
|
+
*
|
|
232
|
+
* // Insert a table in the range B2:F11
|
|
233
|
+
* const fRange = fWorksheet.getRange('B2:F11');
|
|
234
|
+
* const success = await fWorksheet.addTable(
|
|
235
|
+
* 'name-1',
|
|
236
|
+
* fRange.getRange(),
|
|
237
|
+
* 'id-1',
|
|
238
|
+
* {
|
|
239
|
+
* showHeader: true,
|
|
240
|
+
* }
|
|
241
|
+
* );
|
|
242
|
+
* console.log('debugger tableInfo2', fWorksheet.getTableByCell(row, column));
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
getTableByCell(row: number, column: number): ITableInfoWithUnitId | undefined;
|
|
246
|
+
/**
|
|
247
|
+
* Add a theme to the table
|
|
248
|
+
* @param {string} tableId The table id
|
|
249
|
+
* @param {IRangeThemeStyleJSON} themeStyleJSON The theme style JSON
|
|
250
|
+
* @returns {Promise<boolean>} Whether the theme was added successfully
|
|
251
|
+
* @example
|
|
252
|
+
* ```typescript
|
|
253
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
254
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
255
|
+
*
|
|
256
|
+
* // Insert a table in the range B2:F11
|
|
257
|
+
* const fRange = fWorksheet.getRange('B2:F11');
|
|
258
|
+
* const success = await fWorksheet.addTable(
|
|
259
|
+
* 'name-1',
|
|
260
|
+
* fRange.getRange(),
|
|
261
|
+
* 'id-1',
|
|
262
|
+
* {
|
|
263
|
+
* showHeader: true,
|
|
264
|
+
* }
|
|
265
|
+
* );
|
|
266
|
+
*
|
|
267
|
+
* if (success) {
|
|
268
|
+
* await fWorksheet.addTableTheme('id-1', {
|
|
269
|
+
* name: 'table-custom-1',
|
|
270
|
+
* headerRowStyle: {
|
|
271
|
+
* bg: {
|
|
272
|
+
* rgb: '#145f82',
|
|
273
|
+
* },
|
|
274
|
+
* },
|
|
275
|
+
* firstRowStyle: {
|
|
276
|
+
* bg: {
|
|
277
|
+
* rgb: '#c0e4f5',
|
|
278
|
+
* },
|
|
279
|
+
* },
|
|
280
|
+
* });
|
|
281
|
+
*
|
|
282
|
+
* const tableInfo = fWorkbook.getTableInfo('id-1');
|
|
283
|
+
* console.log('debugger tableInfo', tableInfo);
|
|
284
|
+
* }
|
|
285
|
+
* ```
|
|
286
|
+
*/
|
|
287
|
+
addTableTheme(tableId: string, themeStyleJSON: IRangeThemeStyleJSON): Promise<boolean>;
|
|
9
288
|
}
|
|
10
289
|
export declare class FWorkSheetTableMixin extends FWorksheet implements IFWorkSheetTableMixin {
|
|
11
|
-
addTable(tableName: string, rangeInfo: ITableRange, tableId?: string, options?: ITableOptions):
|
|
12
|
-
|
|
290
|
+
addTable(tableName: string, rangeInfo: ITableRange, tableId?: string, options?: ITableOptions): Promise<boolean>;
|
|
291
|
+
setTableFilter(tableId: string, column: number, filter: ITableFilterItem): Promise<boolean>;
|
|
292
|
+
removeTable(tableId: string): Promise<boolean>;
|
|
293
|
+
setTableRange(tableId: string, rangeInfo: ITableRange): Promise<boolean>;
|
|
294
|
+
setTableName(tableId: string, tableName: string): Promise<boolean>;
|
|
295
|
+
getSubTableInfos(): ITableInfoWithUnitId[];
|
|
296
|
+
resetFilter(tableId: string, column: number): Promise<boolean>;
|
|
297
|
+
getTableByCell(row: number, column: number): ITableInfoWithUnitId | undefined;
|
|
298
|
+
addTableTheme(tableId: string, themeStyleJSON: IRangeThemeStyleJSON): Promise<boolean>;
|
|
13
299
|
}
|
|
14
300
|
declare module '@univerjs/sheets/facade' {
|
|
15
301
|
interface FWorksheet extends IFWorkSheetTableMixin {
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(t,a){typeof exports=="object"&&typeof module<"u"?a(require("@univerjs/sheets-table"),require("@univerjs/sheets/facade"),require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/core/facade")):typeof define=="function"&&define.amd?define(["@univerjs/sheets-table","@univerjs/sheets/facade","@univerjs/core","@univerjs/sheets","@univerjs/core/facade"],a):(t=typeof globalThis<"u"?globalThis:t||self,a(t.UniverSheetsTable,t.UniverSheetsFacade,t.UniverCore,t.UniverSheets,t.UniverCoreFacade))})(this,function(t,a,m,h,u){"use strict";class T extends a.FWorkbook{getTableInfo(e){const n=this.getId();return this._injector.get(t.SheetTableService).getTableInfo(n,e)}getTableList(){const e=this.getId();return this._injector.get(t.SheetTableService).getTableList(e)}async addTable(e,n,i,r,d){var b;const s=this._injector.get(t.SheetTableService),o={unitId:this.getId(),name:n,subUnitId:e,range:i,options:d,id:r};if(await this._commandService.executeCommand(t.AddSheetTableCommand.id,o))return(b=s.getTableList(this.getId()).find(v=>v.name===n))==null?void 0:b.id}async removeTable(e){var r;const n=(r=this.getTableInfo(e))==null?void 0:r.subUnitId;if(!n)return!1;const i={unitId:this.getId(),subUnitId:n,tableId:e};return this._commandService.executeCommand(t.DeleteSheetTableCommand.id,i)}getTableInfoByName(e){return this.getTableList().find(i=>i.name===e)}setTableFilter(e,n,i){const r={unitId:this.getId(),tableId:e,column:n,tableFilter:i};return this._commandService.executeCommand(t.SetSheetTableFilterCommand.id,r)}}a.FWorkbook.extend(T);class S extends a.FWorksheet{addTable(e,n,i,r){const d=this.getSheetId(),o={unitId:this.getWorkbook().getUnitId(),subUnitId:d,name:e,range:n,id:i,options:r};return this._commandService.executeCommand(t.AddSheetTableCommand.id,o)}setTableFilter(e,n,i){const r={unitId:this.getWorkbook().getUnitId(),tableId:e,column:n,tableFilter:i};return this._commandService.executeCommand(t.SetSheetTableFilterCommand.id,r)}removeTable(e){const n={unitId:this._fWorkbook.getId(),subUnitId:this.getSheetId(),tableId:e};return this._commandService.executeCommand(t.DeleteSheetTableCommand.id,n)}setTableRange(e,n){const i={unitId:this.getWorkbook().getUnitId(),tableId:e,updateRange:{newRange:n}};return this._commandService.executeCommand(t.SetSheetTableCommand.id,i)}setTableName(e,n){const i={unitId:this.getWorkbook().getUnitId(),tableId:e,name:n};return this._commandService.executeCommand(t.SetSheetTableCommand.id,i)}getSubTableInfos(){const e=this._fWorkbook.getId();return this._injector.get(t.SheetTableService).getTableList(e).filter(i=>i.subUnitId===this.getSheetId())}resetFilter(e,n){const i={unitId:this._fWorkbook.getId(),tableId:e,column:n,tableFilter:void 0};return this._commandService.executeCommand(t.SetSheetTableFilterCommand.id,i)}getTableByCell(e,n){const i=this._fWorkbook.getId(),d=this._injector.get(t.SheetTableService).getTableList(i).filter(o=>o.subUnitId===this.getSheetId()),s=m.cellToRange(e,n);return d.find(o=>{const l=o.range;return m.Rectangle.intersects(l,s)})}addTableTheme(e,n){const i=new h.RangeThemeStyle("table-style");return i.fromJson(n),this._commandService.executeCommand(t.AddTableThemeCommand.id,{unitId:this._fWorkbook.getId(),tableId:e,themeStyle:i})}}a.FWorksheet.extend(S);class g extends u.FEnum{get TableColumnFilterTypeEnum(){return t.TableColumnFilterTypeEnum}get TableConditionTypeEnum(){return t.TableConditionTypeEnum}get TableNumberCompareTypeEnum(){return t.TableNumberCompareTypeEnum}get TableStringCompareTypeEnum(){return t.TableStringCompareTypeEnum}get TableDateCompareTypeEnum(){return t.TableDateCompareTypeEnum}}u.FEnum.extend(g)});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-table",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0-beta.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A library for connect and bind data from other sources to Univer Sheets",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -60,15 +60,15 @@
|
|
|
60
60
|
"rxjs": ">=7.0.0"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@univerjs/sheets": "0.
|
|
64
|
-
"@univerjs/core": "0.
|
|
63
|
+
"@univerjs/sheets": "0.8.0-beta.0",
|
|
64
|
+
"@univerjs/core": "0.8.0-beta.0"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"rxjs": "^7.8.2",
|
|
68
68
|
"typescript": "^5.8.3",
|
|
69
69
|
"vite": "^6.3.5",
|
|
70
|
-
"vitest": "^3.1.
|
|
71
|
-
"@univerjs-infra/shared": "0.
|
|
70
|
+
"vitest": "^3.1.4",
|
|
71
|
+
"@univerjs-infra/shared": "0.8.0-beta.0"
|
|
72
72
|
},
|
|
73
73
|
"scripts": {
|
|
74
74
|
"test": "vitest run",
|