@univerjs/sheets-numfmt 0.20.1 → 0.21.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 +64 -1
- package/lib/cjs/index.js +951 -1
- package/lib/es/facade.js +65 -1
- package/lib/es/index.js +913 -1
- package/lib/facade.js +65 -1
- package/lib/index.js +913 -1
- package/lib/umd/index.js +1 -1
- package/package.json +6 -6
package/lib/es/facade.js
CHANGED
|
@@ -1 +1,65 @@
|
|
|
1
|
-
import{SetNumfmtCommand
|
|
1
|
+
import { SetNumfmtCommand, SheetsNumfmtCellContentController } from "@univerjs/sheets-numfmt";
|
|
2
|
+
import { FRange, FWorkbook } from "@univerjs/sheets/facade";
|
|
3
|
+
|
|
4
|
+
//#region src/facade/f-range.ts
|
|
5
|
+
var FRangeSheetsNumfmtMixin = class extends FRange {
|
|
6
|
+
setNumberFormat(pattern) {
|
|
7
|
+
const values = [];
|
|
8
|
+
const { startColumn, startRow, endColumn, endRow } = this._range;
|
|
9
|
+
for (let row = startRow; row <= endRow; row++) for (let col = startColumn; col <= endColumn; col++) values.push({
|
|
10
|
+
row,
|
|
11
|
+
col,
|
|
12
|
+
pattern
|
|
13
|
+
});
|
|
14
|
+
this._commandService.syncExecuteCommand(SetNumfmtCommand.id, {
|
|
15
|
+
unitId: this._workbook.getUnitId(),
|
|
16
|
+
subUnitId: this._worksheet.getSheetId(),
|
|
17
|
+
values
|
|
18
|
+
});
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
setNumberFormats(patterns) {
|
|
22
|
+
const values = [];
|
|
23
|
+
const { startColumn, startRow, endColumn, endRow } = this._range;
|
|
24
|
+
for (let row = startRow; row <= endRow; row++) for (let col = startColumn; col <= endColumn; col++) {
|
|
25
|
+
var _patterns;
|
|
26
|
+
const pattern = (_patterns = patterns[row - startRow]) === null || _patterns === void 0 ? void 0 : _patterns[col - startColumn];
|
|
27
|
+
values.push({
|
|
28
|
+
row,
|
|
29
|
+
col,
|
|
30
|
+
pattern
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
this._commandService.syncExecuteCommand(SetNumfmtCommand.id, {
|
|
34
|
+
unitId: this._workbook.getUnitId(),
|
|
35
|
+
subUnitId: this._worksheet.getSheetId(),
|
|
36
|
+
values
|
|
37
|
+
});
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
getNumberFormat() {
|
|
41
|
+
var _style$numberFormat$p, _style$numberFormat;
|
|
42
|
+
const style = this.getCellStyle();
|
|
43
|
+
return (_style$numberFormat$p = style === null || style === void 0 || (_style$numberFormat = style.numberFormat) === null || _style$numberFormat === void 0 ? void 0 : _style$numberFormat.pattern) !== null && _style$numberFormat$p !== void 0 ? _style$numberFormat$p : "";
|
|
44
|
+
}
|
|
45
|
+
getNumberFormats() {
|
|
46
|
+
return this.getCellStyles().map((row) => row.map((cellStyle) => {
|
|
47
|
+
var _cellStyle$numberForm, _cellStyle$numberForm2;
|
|
48
|
+
return (_cellStyle$numberForm = cellStyle === null || cellStyle === void 0 || (_cellStyle$numberForm2 = cellStyle.numberFormat) === null || _cellStyle$numberForm2 === void 0 ? void 0 : _cellStyle$numberForm2.pattern) !== null && _cellStyle$numberForm !== void 0 ? _cellStyle$numberForm : "";
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
FRange.extend(FRangeSheetsNumfmtMixin);
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/facade/f-workbook.ts
|
|
56
|
+
var FWorkbookSheetsNumfmtMixin = class extends FWorkbook {
|
|
57
|
+
setNumfmtLocal(locale) {
|
|
58
|
+
this._injector.get(SheetsNumfmtCellContentController).setNumfmtLocal(locale);
|
|
59
|
+
return this;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
FWorkbook.extend(FWorkbookSheetsNumfmtMixin);
|
|
63
|
+
|
|
64
|
+
//#endregion
|
|
65
|
+
export { };
|