@univerjs/sheets-numfmt 0.6.1 → 0.6.2
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 +35 -12
- package/lib/types/facade/f-range.d.ts +48 -1
- package/lib/umd/facade.js +1 -1
- package/package.json +8 -8
package/lib/cjs/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const m=require("@univerjs/sheets-numfmt"),r=require("@univerjs/sheets/facade");class i extends r.FRange{setNumberFormat(s){const t=[];return this.forEach((e,n)=>t.push({row:e,col:n,pattern:s})),this._commandService.syncExecuteCommand(m.SetNumfmtCommand.id,{unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),values:t}),this}setNumberFormats(s){const t=[];return this.forEach((e,n)=>{var a;const o=(a=s[e])==null?void 0:a[n];t.push({row:e,col:n,pattern:o})}),this._commandService.syncExecuteCommand(m.SetNumfmtCommand.id,{unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),values:t}),this}getNumberFormat(){var t,e;const s=this.getCellStyle();return(e=(t=s==null?void 0:s.numberFormat)==null?void 0:t.pattern)!=null?e:""}getNumberFormats(){return this.getCellStyles().map(t=>t.map(e=>{var n,o;return(o=(n=e==null?void 0:e.numberFormat)==null?void 0:n.pattern)!=null?o:""}))}}r.FRange.extend(i);class h extends r.FWorkbook{setNumfmtLocal(s){return this._injector.get(m.SheetsNumfmtCellContentController).setNumfmtLocal(s),this}}r.FWorkbook.extend(h);
|
package/lib/es/facade.js
CHANGED
|
@@ -1,19 +1,42 @@
|
|
|
1
|
-
import { SetNumfmtCommand as
|
|
2
|
-
import { FRange as
|
|
3
|
-
class
|
|
4
|
-
setNumberFormat(
|
|
5
|
-
const
|
|
6
|
-
return this.forEach((
|
|
1
|
+
import { SetNumfmtCommand as m, SheetsNumfmtCellContentController as h } from "@univerjs/sheets-numfmt";
|
|
2
|
+
import { FRange as a, FWorkbook as i } from "@univerjs/sheets/facade";
|
|
3
|
+
class d extends a {
|
|
4
|
+
setNumberFormat(s) {
|
|
5
|
+
const t = [];
|
|
6
|
+
return this.forEach((e, o) => t.push({ row: e, col: o, pattern: s })), this._commandService.syncExecuteCommand(m.id, {
|
|
7
7
|
unitId: this._workbook.getUnitId(),
|
|
8
8
|
subUnitId: this._worksheet.getSheetId(),
|
|
9
|
-
values:
|
|
9
|
+
values: t
|
|
10
10
|
}), this;
|
|
11
11
|
}
|
|
12
|
+
setNumberFormats(s) {
|
|
13
|
+
const t = [];
|
|
14
|
+
return this.forEach((e, o) => {
|
|
15
|
+
var r;
|
|
16
|
+
const n = (r = s[e]) == null ? void 0 : r[o];
|
|
17
|
+
t.push({ row: e, col: o, pattern: n });
|
|
18
|
+
}), this._commandService.syncExecuteCommand(m.id, {
|
|
19
|
+
unitId: this._workbook.getUnitId(),
|
|
20
|
+
subUnitId: this._worksheet.getSheetId(),
|
|
21
|
+
values: t
|
|
22
|
+
}), this;
|
|
23
|
+
}
|
|
24
|
+
getNumberFormat() {
|
|
25
|
+
var t, e;
|
|
26
|
+
const s = this.getCellStyle();
|
|
27
|
+
return (e = (t = s == null ? void 0 : s.numberFormat) == null ? void 0 : t.pattern) != null ? e : "";
|
|
28
|
+
}
|
|
29
|
+
getNumberFormats() {
|
|
30
|
+
return this.getCellStyles().map((t) => t.map((e) => {
|
|
31
|
+
var o, n;
|
|
32
|
+
return (n = (o = e == null ? void 0 : e.numberFormat) == null ? void 0 : o.pattern) != null ? n : "";
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
12
35
|
}
|
|
13
|
-
|
|
14
|
-
class c extends
|
|
15
|
-
setNumfmtLocal(
|
|
16
|
-
return this._injector.get(
|
|
36
|
+
a.extend(d);
|
|
37
|
+
class c extends i {
|
|
38
|
+
setNumfmtLocal(s) {
|
|
39
|
+
return this._injector.get(h).setNumfmtLocal(s), this;
|
|
17
40
|
}
|
|
18
41
|
}
|
|
19
|
-
|
|
42
|
+
i.extend(c);
|
|
@@ -13,13 +13,60 @@ export interface IFRangeSheetsNumfmtMixin {
|
|
|
13
13
|
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
14
14
|
* const fRange = fWorksheet.getRange('A1');
|
|
15
15
|
* fRange.setValue(1234.567).setNumberFormat('#,##0.00');
|
|
16
|
-
* console.log(fRange.
|
|
16
|
+
* console.log(fRange.getDisplayValue()); // 1,234.57
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
19
|
setNumberFormat(pattern: string): FRange;
|
|
20
|
+
/**
|
|
21
|
+
* Sets a rectangular grid of number formats (must match dimensions of this range).
|
|
22
|
+
* @param {string[][]} patterns - A two-dimensional array of number formats.
|
|
23
|
+
* @returns {FRange} The FRange instance for chaining.
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
27
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
28
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
29
|
+
* fRange.setValues([
|
|
30
|
+
* [1234.567, 0.1234],
|
|
31
|
+
* [45658, 0.9876]
|
|
32
|
+
* ]).setNumberFormats([
|
|
33
|
+
* ['#,##0.00', '0.00%'],
|
|
34
|
+
* ['yyyy-MM-DD', '']
|
|
35
|
+
* ]);
|
|
36
|
+
* console.log(fRange.getDisplayValues()); // [['1,234.57', '12.34%'], ['2025-01-01', 0.9876]]
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
setNumberFormats(patterns: string[][]): FRange;
|
|
40
|
+
/**
|
|
41
|
+
* Get the number formatting of the top-left cell of the given range. Empty cells return an empty string.
|
|
42
|
+
* @returns {string} The number format of the top-left cell of the range.
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
46
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
47
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
48
|
+
* console.log(fRange.getNumberFormat());
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
getNumberFormat(): string;
|
|
52
|
+
/**
|
|
53
|
+
* Returns the number formats for the cells in the range.
|
|
54
|
+
* @returns {string[][]} A two-dimensional array of number formats.
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
58
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
59
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
60
|
+
* console.log(fRange.getNumberFormats());
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
getNumberFormats(): string[][];
|
|
20
64
|
}
|
|
21
65
|
export declare class FRangeLegacy extends FRange implements IFRangeSheetsNumfmtMixin {
|
|
22
66
|
setNumberFormat(pattern: string): FRange;
|
|
67
|
+
setNumberFormats(patterns: string[][]): FRange;
|
|
68
|
+
getNumberFormat(): string;
|
|
69
|
+
getNumberFormats(): string[][];
|
|
23
70
|
}
|
|
24
71
|
declare module '@univerjs/sheets/facade' {
|
|
25
72
|
interface FRange extends IFRangeSheetsNumfmtMixin {
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(s,o){typeof exports=="object"&&typeof module<"u"?o(require("@univerjs/sheets-numfmt"),require("@univerjs/sheets/facade")):typeof define=="function"&&define.amd?define(["@univerjs/sheets-numfmt","@univerjs/sheets/facade"],o):(s=typeof globalThis<"u"?globalThis:s||self,o(s.UniverSheetsNumfmt,s.UniverSheetsFacade))})(this,function(s,o){"use strict";class u extends o.FRange{setNumberFormat(n){const e=[];return this.forEach((t,r)=>e.push({row:t,col:r,pattern:n})),this._commandService.syncExecuteCommand(s.SetNumfmtCommand.id,{unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),values:e}),this}setNumberFormats(n){const e=[];return this.forEach((t,r)=>{var m;const i=(m=n[t])==null?void 0:m[r];e.push({row:t,col:r,pattern:i})}),this._commandService.syncExecuteCommand(s.SetNumfmtCommand.id,{unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),values:e}),this}getNumberFormat(){var e,t;const n=this.getCellStyle();return(t=(e=n==null?void 0:n.numberFormat)==null?void 0:e.pattern)!=null?t:""}getNumberFormats(){return this.getCellStyles().map(e=>e.map(t=>{var r,i;return(i=(r=t==null?void 0:t.numberFormat)==null?void 0:r.pattern)!=null?i:""}))}}o.FRange.extend(u);class h extends o.FWorkbook{setNumfmtLocal(n){return this._injector.get(s.SheetsNumfmtCellContentController).setNumfmtLocal(n),this}}o.FWorkbook.extend(h)});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-numfmt",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "UniverSheet numfmt plugin",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -53,17 +53,17 @@
|
|
|
53
53
|
"rxjs": ">=7.0.0"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@univerjs/core": "0.6.
|
|
57
|
-
"@univerjs/engine-
|
|
58
|
-
"@univerjs/engine-
|
|
59
|
-
"@univerjs/sheets": "0.6.
|
|
56
|
+
"@univerjs/core": "0.6.2",
|
|
57
|
+
"@univerjs/engine-formula": "0.6.2",
|
|
58
|
+
"@univerjs/engine-numfmt": "0.6.2",
|
|
59
|
+
"@univerjs/sheets": "0.6.2"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"rxjs": "^7.8.1",
|
|
63
63
|
"typescript": "^5.7.3",
|
|
64
|
-
"vite": "^6.
|
|
65
|
-
"vitest": "^3.0.
|
|
66
|
-
"@univerjs-infra/shared": "0.6.
|
|
64
|
+
"vite": "^6.2.0",
|
|
65
|
+
"vitest": "^3.0.7",
|
|
66
|
+
"@univerjs-infra/shared": "0.6.2"
|
|
67
67
|
},
|
|
68
68
|
"scripts": {
|
|
69
69
|
"test": "vitest run",
|