@univerjs/sheets-formula 0.10.5-nightly.202508290716 → 0.10.6-experimental.20250903-f52e3bf
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 +93 -47
- package/lib/facade.js +93 -47
- package/lib/types/facade/f-range.d.ts +30 -0
- package/lib/types/facade/f-workbook.d.ts +25 -0
- package/lib/types/facade/index.d.ts +2 -0
- package/lib/umd/facade.js +1 -1
- package/package.json +8 -7
package/lib/cjs/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const d=require("@univerjs/core"),x=require("@univerjs/core/facade"),F=require("@univerjs/engine-formula"),i=require("@univerjs/sheets-formula"),y=require("@univerjs/engine-formula/facade"),C=require("@univerjs/sheets/facade");class R extends x.FUniver{_initialize(){this._debouncedFormulaCalculation=d.debounce(()=>{this._commandService.executeCommand(F.SetFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{onlyLocal:!0})},10)}registerFunction(t){let n=this._injector.get(i.IRegisterFunctionService);n||(this._injector.add([i.IRegisterFunctionService,{useClass:i.RegisterFunctionService}]),n=this._injector.get(i.IRegisterFunctionService));const e=n.registerFunctions(t);return this._debouncedFormulaCalculation(),e}}x.FUniver.extend(R);class j extends y.FFormula{_initialize(){this._debouncedFormulaCalculation=d.debounce(()=>{this._commandService.executeCommand(F.SetFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{onlyLocal:!0})},10)}setInitialFormulaComputing(t){const e=this._injector.get(d.LifecycleService).stage,o=this._injector.get(d.ILogService),c=this._injector.get(d.IConfigService);e>d.LifecycleStages.Starting&&o.warn("[FFormula]","CalculationMode is called after the Starting lifecycle and will take effect the next time the Univer Sheet is constructed. If you want it to take effect when the Univer Sheet is initialized this time, consider calling it before the Ready lifecycle or using configuration.");const r=c.getConfig(i.PLUGIN_CONFIG_KEY_BASE);if(!r){c.setConfig(i.PLUGIN_CONFIG_KEY_BASE,{initialFormulaComputing:t});return}r.initialFormulaComputing=t}registerFunction(t,n,e){var s;let o=this._injector.get(i.IRegisterFunctionService);o||(this._injector.add([i.IRegisterFunctionService,{useClass:i.RegisterFunctionService}]),o=this._injector.get(i.IRegisterFunctionService));const c={name:t,func:n,description:typeof e=="string"?e:(s=e==null?void 0:e.description)!=null?s:"",locales:typeof e=="object"?e.locales:void 0},r=o.registerFunction(c);return this._debouncedFormulaCalculation(),r}registerAsyncFunction(t,n,e){var s;let o=this._injector.get(i.IRegisterFunctionService);o||(this._injector.add([i.IRegisterFunctionService,{useClass:i.RegisterFunctionService}]),o=this._injector.get(i.IRegisterFunctionService));const c={name:t,func:n,description:typeof e=="string"?e:(s=e==null?void 0:e.description)!=null?s:"",locales:typeof e=="object"?e.locales:void 0},r=o.registerAsyncFunction(c);return this._debouncedFormulaCalculation(),r}}y.FFormula.extend(j);class M{get CalculationMode(){return i.CalculationMode}}x.FEnum.extend(M);class E extends C.FWorkbook{getAllFormulaError(){const t=[],n=this._workbook,e=n.getUnitId(),o=n.getSheets(),c=this._injector.get(F.FormulaDataModel).getArrayFormulaCellData();return o.forEach(r=>{var S;const s=r.getName(),v=r.getSheetId(),I=r.getCellMatrix(),m=((S=c==null?void 0:c[e])==null?void 0:S[v])||{};I.forValue((_,h,u)=>{var g;if(!u)return;const l=(g=m==null?void 0:m[_])==null?void 0:g[h],a=F.extractFormulaError(u,!!l);a&&t.push({sheetName:s,row:_,column:h,formula:u.f||"",errorType:a})})}),t}}C.FWorkbook.extend(E);class w extends C.FRange{getFormulaError(){var h,u;const t=[],n=this._workbook.getUnitId(),e=this._worksheet.getSheetId(),o=this._worksheet.getName(),c=this._workbook.getSheetBySheetId(e);if(!c)return t;const r=this._injector.get(F.FormulaDataModel).getArrayFormulaCellData(),s=((h=r==null?void 0:r[n])==null?void 0:h[e])||{},v=c.getCellMatrix(),{startRow:I,endRow:m,startColumn:S,endColumn:_}=this._range;for(let l=I;l<=m;l++)for(let a=S;a<=_;a++){const g=v.getValue(l,a);if(!g)continue;const k=(u=s==null?void 0:s[l])==null?void 0:u[a],b=F.extractFormulaError(g,!!k);b&&t.push({sheetName:o,row:l,column:a,formula:g.f||"",errorType:b})}return t}}C.FRange.extend(w);
|
package/lib/es/facade.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { debounce as
|
|
2
|
-
import { FUniver as
|
|
3
|
-
import { SetFormulaCalculationStartMutation as
|
|
4
|
-
import { IRegisterFunctionService as
|
|
5
|
-
import { FFormula as
|
|
6
|
-
|
|
1
|
+
import { debounce as y, LifecycleService as D, ILogService as R, IConfigService as U, LifecycleStages as A } from "@univerjs/core";
|
|
2
|
+
import { FUniver as b, FEnum as L } from "@univerjs/core/facade";
|
|
3
|
+
import { SetFormulaCalculationStartMutation as j, FormulaDataModel as k, extractFormulaError as I } from "@univerjs/engine-formula";
|
|
4
|
+
import { IRegisterFunctionService as s, RegisterFunctionService as S, PLUGIN_CONFIG_KEY_BASE as v, CalculationMode as N } from "@univerjs/sheets-formula";
|
|
5
|
+
import { FFormula as w } from "@univerjs/engine-formula/facade";
|
|
6
|
+
import { FWorkbook as M, FRange as p } from "@univerjs/sheets/facade";
|
|
7
|
+
class z extends b {
|
|
7
8
|
/**
|
|
8
9
|
* Initialize the FUniver instance.
|
|
9
10
|
* @ignore
|
|
10
11
|
*/
|
|
11
12
|
_initialize() {
|
|
12
|
-
this._debouncedFormulaCalculation =
|
|
13
|
+
this._debouncedFormulaCalculation = y(() => {
|
|
13
14
|
this._commandService.executeCommand(
|
|
14
|
-
|
|
15
|
+
j.id,
|
|
15
16
|
{
|
|
16
17
|
commands: [],
|
|
17
18
|
forceCalculation: !0
|
|
@@ -22,23 +23,23 @@ class y extends d {
|
|
|
22
23
|
);
|
|
23
24
|
}, 10);
|
|
24
25
|
}
|
|
25
|
-
registerFunction(
|
|
26
|
-
let
|
|
27
|
-
|
|
28
|
-
const e =
|
|
26
|
+
registerFunction(t) {
|
|
27
|
+
let r = this._injector.get(s);
|
|
28
|
+
r || (this._injector.add([s, { useClass: S }]), r = this._injector.get(s));
|
|
29
|
+
const e = r.registerFunctions(t);
|
|
29
30
|
return this._debouncedFormulaCalculation(), e;
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
-
class
|
|
33
|
+
b.extend(z);
|
|
34
|
+
class B extends w {
|
|
34
35
|
/**
|
|
35
36
|
* Initialize the FUniver instance.
|
|
36
37
|
* @ignore
|
|
37
38
|
*/
|
|
38
39
|
_initialize() {
|
|
39
|
-
this._debouncedFormulaCalculation =
|
|
40
|
+
this._debouncedFormulaCalculation = y(() => {
|
|
40
41
|
this._commandService.executeCommand(
|
|
41
|
-
|
|
42
|
+
j.id,
|
|
42
43
|
{
|
|
43
44
|
commands: [],
|
|
44
45
|
forceCalculation: !0
|
|
@@ -49,45 +50,90 @@ class j extends f {
|
|
|
49
50
|
);
|
|
50
51
|
}, 10);
|
|
51
52
|
}
|
|
52
|
-
setInitialFormulaComputing(
|
|
53
|
-
const e = this._injector.get(
|
|
54
|
-
e >
|
|
55
|
-
const
|
|
56
|
-
if (!
|
|
57
|
-
|
|
53
|
+
setInitialFormulaComputing(t) {
|
|
54
|
+
const e = this._injector.get(D).stage, o = this._injector.get(R), n = this._injector.get(U);
|
|
55
|
+
e > A.Starting && o.warn("[FFormula]", "CalculationMode is called after the Starting lifecycle and will take effect the next time the Univer Sheet is constructed. If you want it to take effect when the Univer Sheet is initialized this time, consider calling it before the Ready lifecycle or using configuration.");
|
|
56
|
+
const i = n.getConfig(v);
|
|
57
|
+
if (!i) {
|
|
58
|
+
n.setConfig(v, { initialFormulaComputing: t });
|
|
58
59
|
return;
|
|
59
60
|
}
|
|
60
|
-
|
|
61
|
+
i.initialFormulaComputing = t;
|
|
61
62
|
}
|
|
62
|
-
registerFunction(
|
|
63
|
-
var
|
|
64
|
-
let
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
name:
|
|
68
|
-
func:
|
|
69
|
-
description: typeof e == "string" ? e : (
|
|
63
|
+
registerFunction(t, r, e) {
|
|
64
|
+
var c;
|
|
65
|
+
let o = this._injector.get(s);
|
|
66
|
+
o || (this._injector.add([s, { useClass: S }]), o = this._injector.get(s));
|
|
67
|
+
const n = {
|
|
68
|
+
name: t,
|
|
69
|
+
func: r,
|
|
70
|
+
description: typeof e == "string" ? e : (c = e == null ? void 0 : e.description) != null ? c : "",
|
|
70
71
|
locales: typeof e == "object" ? e.locales : void 0
|
|
71
|
-
},
|
|
72
|
-
return this._debouncedFormulaCalculation(),
|
|
72
|
+
}, i = o.registerFunction(n);
|
|
73
|
+
return this._debouncedFormulaCalculation(), i;
|
|
73
74
|
}
|
|
74
|
-
registerAsyncFunction(
|
|
75
|
-
var
|
|
76
|
-
let
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
name:
|
|
80
|
-
func:
|
|
81
|
-
description: typeof e == "string" ? e : (
|
|
75
|
+
registerAsyncFunction(t, r, e) {
|
|
76
|
+
var c;
|
|
77
|
+
let o = this._injector.get(s);
|
|
78
|
+
o || (this._injector.add([s, { useClass: S }]), o = this._injector.get(s));
|
|
79
|
+
const n = {
|
|
80
|
+
name: t,
|
|
81
|
+
func: r,
|
|
82
|
+
description: typeof e == "string" ? e : (c = e == null ? void 0 : e.description) != null ? c : "",
|
|
82
83
|
locales: typeof e == "object" ? e.locales : void 0
|
|
83
|
-
},
|
|
84
|
-
return this._debouncedFormulaCalculation(),
|
|
84
|
+
}, i = o.registerAsyncFunction(n);
|
|
85
|
+
return this._debouncedFormulaCalculation(), i;
|
|
85
86
|
}
|
|
86
87
|
}
|
|
87
|
-
|
|
88
|
-
class
|
|
88
|
+
w.extend(B);
|
|
89
|
+
class G {
|
|
89
90
|
get CalculationMode() {
|
|
90
|
-
return
|
|
91
|
+
return N;
|
|
91
92
|
}
|
|
92
93
|
}
|
|
93
|
-
|
|
94
|
+
L.extend(G);
|
|
95
|
+
class T extends M {
|
|
96
|
+
getAllFormulaError() {
|
|
97
|
+
const t = [], r = this._workbook, e = r.getUnitId(), o = r.getSheets(), n = this._injector.get(k).getArrayFormulaCellData();
|
|
98
|
+
return o.forEach((i) => {
|
|
99
|
+
var h;
|
|
100
|
+
const c = i.getName(), _ = i.getSheetId(), C = i.getCellMatrix(), m = ((h = n == null ? void 0 : n[e]) == null ? void 0 : h[_]) || {};
|
|
101
|
+
C.forValue((F, d, u) => {
|
|
102
|
+
var g;
|
|
103
|
+
if (!u) return;
|
|
104
|
+
const l = (g = m == null ? void 0 : m[F]) == null ? void 0 : g[d], a = I(u, !!l);
|
|
105
|
+
a && t.push({
|
|
106
|
+
sheetName: c,
|
|
107
|
+
row: F,
|
|
108
|
+
column: d,
|
|
109
|
+
formula: u.f || "",
|
|
110
|
+
errorType: a
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
}), t;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
M.extend(T);
|
|
117
|
+
class V extends p {
|
|
118
|
+
getFormulaError() {
|
|
119
|
+
var d, u;
|
|
120
|
+
const t = [], r = this._workbook.getUnitId(), e = this._worksheet.getSheetId(), o = this._worksheet.getName(), n = this._workbook.getSheetBySheetId(e);
|
|
121
|
+
if (!n) return t;
|
|
122
|
+
const i = this._injector.get(k).getArrayFormulaCellData(), c = ((d = i == null ? void 0 : i[r]) == null ? void 0 : d[e]) || {}, _ = n.getCellMatrix(), { startRow: C, endRow: m, startColumn: h, endColumn: F } = this._range;
|
|
123
|
+
for (let l = C; l <= m; l++)
|
|
124
|
+
for (let a = h; a <= F; a++) {
|
|
125
|
+
const g = _.getValue(l, a);
|
|
126
|
+
if (!g) continue;
|
|
127
|
+
const E = (u = c == null ? void 0 : c[l]) == null ? void 0 : u[a], x = I(g, !!E);
|
|
128
|
+
x && t.push({
|
|
129
|
+
sheetName: o,
|
|
130
|
+
row: l,
|
|
131
|
+
column: a,
|
|
132
|
+
formula: g.f || "",
|
|
133
|
+
errorType: x
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return t;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
p.extend(V);
|
package/lib/facade.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { debounce as
|
|
2
|
-
import { FUniver as
|
|
3
|
-
import { SetFormulaCalculationStartMutation as
|
|
4
|
-
import { IRegisterFunctionService as
|
|
5
|
-
import { FFormula as
|
|
6
|
-
|
|
1
|
+
import { debounce as y, LifecycleService as D, ILogService as R, IConfigService as U, LifecycleStages as A } from "@univerjs/core";
|
|
2
|
+
import { FUniver as b, FEnum as L } from "@univerjs/core/facade";
|
|
3
|
+
import { SetFormulaCalculationStartMutation as j, FormulaDataModel as k, extractFormulaError as I } from "@univerjs/engine-formula";
|
|
4
|
+
import { IRegisterFunctionService as s, RegisterFunctionService as S, PLUGIN_CONFIG_KEY_BASE as v, CalculationMode as N } from "@univerjs/sheets-formula";
|
|
5
|
+
import { FFormula as w } from "@univerjs/engine-formula/facade";
|
|
6
|
+
import { FWorkbook as M, FRange as p } from "@univerjs/sheets/facade";
|
|
7
|
+
class z extends b {
|
|
7
8
|
/**
|
|
8
9
|
* Initialize the FUniver instance.
|
|
9
10
|
* @ignore
|
|
10
11
|
*/
|
|
11
12
|
_initialize() {
|
|
12
|
-
this._debouncedFormulaCalculation =
|
|
13
|
+
this._debouncedFormulaCalculation = y(() => {
|
|
13
14
|
this._commandService.executeCommand(
|
|
14
|
-
|
|
15
|
+
j.id,
|
|
15
16
|
{
|
|
16
17
|
commands: [],
|
|
17
18
|
forceCalculation: !0
|
|
@@ -22,23 +23,23 @@ class y extends d {
|
|
|
22
23
|
);
|
|
23
24
|
}, 10);
|
|
24
25
|
}
|
|
25
|
-
registerFunction(
|
|
26
|
-
let
|
|
27
|
-
|
|
28
|
-
const e =
|
|
26
|
+
registerFunction(t) {
|
|
27
|
+
let r = this._injector.get(s);
|
|
28
|
+
r || (this._injector.add([s, { useClass: S }]), r = this._injector.get(s));
|
|
29
|
+
const e = r.registerFunctions(t);
|
|
29
30
|
return this._debouncedFormulaCalculation(), e;
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
-
class
|
|
33
|
+
b.extend(z);
|
|
34
|
+
class B extends w {
|
|
34
35
|
/**
|
|
35
36
|
* Initialize the FUniver instance.
|
|
36
37
|
* @ignore
|
|
37
38
|
*/
|
|
38
39
|
_initialize() {
|
|
39
|
-
this._debouncedFormulaCalculation =
|
|
40
|
+
this._debouncedFormulaCalculation = y(() => {
|
|
40
41
|
this._commandService.executeCommand(
|
|
41
|
-
|
|
42
|
+
j.id,
|
|
42
43
|
{
|
|
43
44
|
commands: [],
|
|
44
45
|
forceCalculation: !0
|
|
@@ -49,45 +50,90 @@ class j extends f {
|
|
|
49
50
|
);
|
|
50
51
|
}, 10);
|
|
51
52
|
}
|
|
52
|
-
setInitialFormulaComputing(
|
|
53
|
-
const e = this._injector.get(
|
|
54
|
-
e >
|
|
55
|
-
const
|
|
56
|
-
if (!
|
|
57
|
-
|
|
53
|
+
setInitialFormulaComputing(t) {
|
|
54
|
+
const e = this._injector.get(D).stage, o = this._injector.get(R), n = this._injector.get(U);
|
|
55
|
+
e > A.Starting && o.warn("[FFormula]", "CalculationMode is called after the Starting lifecycle and will take effect the next time the Univer Sheet is constructed. If you want it to take effect when the Univer Sheet is initialized this time, consider calling it before the Ready lifecycle or using configuration.");
|
|
56
|
+
const i = n.getConfig(v);
|
|
57
|
+
if (!i) {
|
|
58
|
+
n.setConfig(v, { initialFormulaComputing: t });
|
|
58
59
|
return;
|
|
59
60
|
}
|
|
60
|
-
|
|
61
|
+
i.initialFormulaComputing = t;
|
|
61
62
|
}
|
|
62
|
-
registerFunction(
|
|
63
|
-
var
|
|
64
|
-
let
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
name:
|
|
68
|
-
func:
|
|
69
|
-
description: typeof e == "string" ? e : (
|
|
63
|
+
registerFunction(t, r, e) {
|
|
64
|
+
var c;
|
|
65
|
+
let o = this._injector.get(s);
|
|
66
|
+
o || (this._injector.add([s, { useClass: S }]), o = this._injector.get(s));
|
|
67
|
+
const n = {
|
|
68
|
+
name: t,
|
|
69
|
+
func: r,
|
|
70
|
+
description: typeof e == "string" ? e : (c = e == null ? void 0 : e.description) != null ? c : "",
|
|
70
71
|
locales: typeof e == "object" ? e.locales : void 0
|
|
71
|
-
},
|
|
72
|
-
return this._debouncedFormulaCalculation(),
|
|
72
|
+
}, i = o.registerFunction(n);
|
|
73
|
+
return this._debouncedFormulaCalculation(), i;
|
|
73
74
|
}
|
|
74
|
-
registerAsyncFunction(
|
|
75
|
-
var
|
|
76
|
-
let
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
name:
|
|
80
|
-
func:
|
|
81
|
-
description: typeof e == "string" ? e : (
|
|
75
|
+
registerAsyncFunction(t, r, e) {
|
|
76
|
+
var c;
|
|
77
|
+
let o = this._injector.get(s);
|
|
78
|
+
o || (this._injector.add([s, { useClass: S }]), o = this._injector.get(s));
|
|
79
|
+
const n = {
|
|
80
|
+
name: t,
|
|
81
|
+
func: r,
|
|
82
|
+
description: typeof e == "string" ? e : (c = e == null ? void 0 : e.description) != null ? c : "",
|
|
82
83
|
locales: typeof e == "object" ? e.locales : void 0
|
|
83
|
-
},
|
|
84
|
-
return this._debouncedFormulaCalculation(),
|
|
84
|
+
}, i = o.registerAsyncFunction(n);
|
|
85
|
+
return this._debouncedFormulaCalculation(), i;
|
|
85
86
|
}
|
|
86
87
|
}
|
|
87
|
-
|
|
88
|
-
class
|
|
88
|
+
w.extend(B);
|
|
89
|
+
class G {
|
|
89
90
|
get CalculationMode() {
|
|
90
|
-
return
|
|
91
|
+
return N;
|
|
91
92
|
}
|
|
92
93
|
}
|
|
93
|
-
|
|
94
|
+
L.extend(G);
|
|
95
|
+
class T extends M {
|
|
96
|
+
getAllFormulaError() {
|
|
97
|
+
const t = [], r = this._workbook, e = r.getUnitId(), o = r.getSheets(), n = this._injector.get(k).getArrayFormulaCellData();
|
|
98
|
+
return o.forEach((i) => {
|
|
99
|
+
var h;
|
|
100
|
+
const c = i.getName(), _ = i.getSheetId(), C = i.getCellMatrix(), m = ((h = n == null ? void 0 : n[e]) == null ? void 0 : h[_]) || {};
|
|
101
|
+
C.forValue((F, d, u) => {
|
|
102
|
+
var g;
|
|
103
|
+
if (!u) return;
|
|
104
|
+
const l = (g = m == null ? void 0 : m[F]) == null ? void 0 : g[d], a = I(u, !!l);
|
|
105
|
+
a && t.push({
|
|
106
|
+
sheetName: c,
|
|
107
|
+
row: F,
|
|
108
|
+
column: d,
|
|
109
|
+
formula: u.f || "",
|
|
110
|
+
errorType: a
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
}), t;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
M.extend(T);
|
|
117
|
+
class V extends p {
|
|
118
|
+
getFormulaError() {
|
|
119
|
+
var d, u;
|
|
120
|
+
const t = [], r = this._workbook.getUnitId(), e = this._worksheet.getSheetId(), o = this._worksheet.getName(), n = this._workbook.getSheetBySheetId(e);
|
|
121
|
+
if (!n) return t;
|
|
122
|
+
const i = this._injector.get(k).getArrayFormulaCellData(), c = ((d = i == null ? void 0 : i[r]) == null ? void 0 : d[e]) || {}, _ = n.getCellMatrix(), { startRow: C, endRow: m, startColumn: h, endColumn: F } = this._range;
|
|
123
|
+
for (let l = C; l <= m; l++)
|
|
124
|
+
for (let a = h; a <= F; a++) {
|
|
125
|
+
const g = _.getValue(l, a);
|
|
126
|
+
if (!g) continue;
|
|
127
|
+
const E = (u = c == null ? void 0 : c[l]) == null ? void 0 : u[a], x = I(g, !!E);
|
|
128
|
+
x && t.push({
|
|
129
|
+
sheetName: o,
|
|
130
|
+
row: l,
|
|
131
|
+
column: a,
|
|
132
|
+
formula: g.f || "",
|
|
133
|
+
errorType: x
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return t;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
p.extend(V);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ISheetFormulaError } from '@univerjs/engine-formula';
|
|
2
|
+
import { FRange } from '@univerjs/sheets/facade';
|
|
3
|
+
/**
|
|
4
|
+
* @ignore
|
|
5
|
+
*/
|
|
6
|
+
export interface IFRangeEngineFormulaMixin {
|
|
7
|
+
/**
|
|
8
|
+
* Get formula errors in the current range
|
|
9
|
+
* @returns {ISheetFormulaError[]} Array of formula errors in the range
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const range = univerAPI.getActiveWorkbook()
|
|
13
|
+
* .getActiveSheet()
|
|
14
|
+
* .getRange('A1:B10');
|
|
15
|
+
* const errors = range.getFormulaError();
|
|
16
|
+
* console.log('Formula errors in range:', errors);
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
getFormulaError(): ISheetFormulaError[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @ignore
|
|
23
|
+
*/
|
|
24
|
+
export declare class FRangeEngineFormulaMixin extends FRange implements IFRangeEngineFormulaMixin {
|
|
25
|
+
getFormulaError(): ISheetFormulaError[];
|
|
26
|
+
}
|
|
27
|
+
declare module '@univerjs/sheets/facade' {
|
|
28
|
+
interface FRange extends IFRangeEngineFormulaMixin {
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ISheetFormulaError } from '@univerjs/engine-formula';
|
|
2
|
+
import { FWorkbook } from '@univerjs/sheets/facade';
|
|
3
|
+
/**
|
|
4
|
+
* @ignore
|
|
5
|
+
*/
|
|
6
|
+
export interface IFWorkbookEngineFormulaMixin {
|
|
7
|
+
/**
|
|
8
|
+
* Get all formula errors in the workbook
|
|
9
|
+
* @returns {ISheetFormulaError[]} Array of formula errors
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
13
|
+
* const errors = fWorkbook.getAllFormulaError();
|
|
14
|
+
* console.log('Formula errors:', errors);
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
getAllFormulaError(): ISheetFormulaError[];
|
|
18
|
+
}
|
|
19
|
+
export declare class FWorkbookEngineFormulaMixin extends FWorkbook implements IFWorkbookEngineFormulaMixin {
|
|
20
|
+
getAllFormulaError(): ISheetFormulaError[];
|
|
21
|
+
}
|
|
22
|
+
declare module '@univerjs/sheets/facade' {
|
|
23
|
+
interface FWorkbook extends IFWorkbookEngineFormulaMixin {
|
|
24
|
+
}
|
|
25
|
+
}
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(t,
|
|
1
|
+
(function(t,l){typeof exports=="object"&&typeof module<"u"?l(require("@univerjs/core"),require("@univerjs/core/facade"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula"),require("@univerjs/engine-formula/facade"),require("@univerjs/sheets/facade")):typeof define=="function"&&define.amd?define(["@univerjs/core","@univerjs/core/facade","@univerjs/engine-formula","@univerjs/sheets-formula","@univerjs/engine-formula/facade","@univerjs/sheets/facade"],l):(t=typeof globalThis<"u"?globalThis:t||self,l(t.UniverCore,t.UniverCoreFacade,t.UniverEngineFormula,t.UniverSheetsFormula,t.UniverEngineFormulaFacade,t.UniverSheetsFacade))})(this,(function(t,l,g,i,x,m){"use strict";class k extends l.FUniver{_initialize(){this._debouncedFormulaCalculation=t.debounce(()=>{this._commandService.executeCommand(g.SetFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{onlyLocal:!0})},10)}registerFunction(n){let c=this._injector.get(i.IRegisterFunctionService);c||(this._injector.add([i.IRegisterFunctionService,{useClass:i.RegisterFunctionService}]),c=this._injector.get(i.IRegisterFunctionService));const e=c.registerFunctions(n);return this._debouncedFormulaCalculation(),e}}l.FUniver.extend(k);class R extends x.FFormula{_initialize(){this._debouncedFormulaCalculation=t.debounce(()=>{this._commandService.executeCommand(g.SetFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{onlyLocal:!0})},10)}setInitialFormulaComputing(n){const e=this._injector.get(t.LifecycleService).stage,o=this._injector.get(t.ILogService),s=this._injector.get(t.IConfigService);e>t.LifecycleStages.Starting&&o.warn("[FFormula]","CalculationMode is called after the Starting lifecycle and will take effect the next time the Univer Sheet is constructed. If you want it to take effect when the Univer Sheet is initialized this time, consider calling it before the Ready lifecycle or using configuration.");const r=s.getConfig(i.PLUGIN_CONFIG_KEY_BASE);if(!r){s.setConfig(i.PLUGIN_CONFIG_KEY_BASE,{initialFormulaComputing:n});return}r.initialFormulaComputing=n}registerFunction(n,c,e){var a;let o=this._injector.get(i.IRegisterFunctionService);o||(this._injector.add([i.IRegisterFunctionService,{useClass:i.RegisterFunctionService}]),o=this._injector.get(i.IRegisterFunctionService));const s={name:n,func:c,description:typeof e=="string"?e:(a=e==null?void 0:e.description)!=null?a:"",locales:typeof e=="object"?e.locales:void 0},r=o.registerFunction(s);return this._debouncedFormulaCalculation(),r}registerAsyncFunction(n,c,e){var a;let o=this._injector.get(i.IRegisterFunctionService);o||(this._injector.add([i.IRegisterFunctionService,{useClass:i.RegisterFunctionService}]),o=this._injector.get(i.IRegisterFunctionService));const s={name:n,func:c,description:typeof e=="string"?e:(a=e==null?void 0:e.description)!=null?a:"",locales:typeof e=="object"?e.locales:void 0},r=o.registerAsyncFunction(s);return this._debouncedFormulaCalculation(),r}}x.FFormula.extend(R);class b{get CalculationMode(){return i.CalculationMode}}l.FEnum.extend(b);class E extends m.FWorkbook{getAllFormulaError(){const n=[],c=this._workbook,e=c.getUnitId(),o=c.getSheets(),s=this._injector.get(g.FormulaDataModel).getArrayFormulaCellData();return o.forEach(r=>{var C;const a=r.getName(),j=r.getSheetId(),I=r.getCellMatrix(),F=((C=s==null?void 0:s[e])==null?void 0:C[j])||{};I.forValue((_,h,f)=>{var v;if(!f)return;const d=(v=F==null?void 0:F[_])==null?void 0:v[h],u=g.extractFormulaError(f,!!d);u&&n.push({sheetName:a,row:_,column:h,formula:f.f||"",errorType:u})})}),n}}m.FWorkbook.extend(E);class U extends m.FRange{getFormulaError(){var h,f;const n=[],c=this._workbook.getUnitId(),e=this._worksheet.getSheetId(),o=this._worksheet.getName(),s=this._workbook.getSheetBySheetId(e);if(!s)return n;const r=this._injector.get(g.FormulaDataModel).getArrayFormulaCellData(),a=((h=r==null?void 0:r[c])==null?void 0:h[e])||{},j=s.getCellMatrix(),{startRow:I,endRow:F,startColumn:C,endColumn:_}=this._range;for(let d=I;d<=F;d++)for(let u=C;u<=_;u++){const v=j.getValue(d,u);if(!v)continue;const M=(f=a==null?void 0:a[d])==null?void 0:f[u],y=g.extractFormulaError(v,!!M);y&&n.push({sheetName:o,row:d,column:u,formula:v.f||"",errorType:y})}return n}}m.FRange.extend(U)}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-formula",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.6-experimental.20250903-f52e3bf",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "DreamNum <developer@univer.ai>",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -62,18 +62,19 @@
|
|
|
62
62
|
"rxjs": ">=7.0.0"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@univerjs/core": "0.10.
|
|
66
|
-
"@univerjs/
|
|
67
|
-
"@univerjs/
|
|
68
|
-
"@univerjs/sheets": "0.10.
|
|
65
|
+
"@univerjs/core": "0.10.6-experimental.20250903-f52e3bf",
|
|
66
|
+
"@univerjs/rpc": "0.10.6-experimental.20250903-f52e3bf",
|
|
67
|
+
"@univerjs/engine-formula": "0.10.6-experimental.20250903-f52e3bf",
|
|
68
|
+
"@univerjs/sheets": "0.10.6-experimental.20250903-f52e3bf"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"rxjs": "^7.8.2",
|
|
72
72
|
"typescript": "^5.9.2",
|
|
73
73
|
"vite": "^7.1.3",
|
|
74
74
|
"vitest": "^3.2.4",
|
|
75
|
-
"@univerjs-infra/shared": "0.10.
|
|
76
|
-
"@univerjs/docs": "0.10.
|
|
75
|
+
"@univerjs-infra/shared": "0.10.6",
|
|
76
|
+
"@univerjs/docs": "0.10.6-experimental.20250903-f52e3bf",
|
|
77
|
+
"@univerjs/engine-render": "0.10.6-experimental.20250903-f52e3bf"
|
|
77
78
|
},
|
|
78
79
|
"scripts": {
|
|
79
80
|
"test": "vitest run",
|