@canvas-components/xlsx-table 0.1.8 → 0.1.10

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.
@@ -1,5 +1,101 @@
1
1
  import { CellObject, WorkBook } from 'xlsx';
2
2
 
3
+ /**
4
+ * 矩形选区,内部 0 基索引。
5
+ */
6
+ interface XlsxCellRange {
7
+ startRowIndex: number;
8
+ startColumnIndex: number;
9
+ endRowIndex: number;
10
+ endColumnIndex: number;
11
+ }
12
+
13
+ /** 从源 XML 读取的差异样式,只含显式声明的样式属性。 */
14
+ interface XlsxConditionalDifferentialStyle {
15
+ font?: Record<string, unknown>;
16
+ fill?: Record<string, unknown>;
17
+ border?: Record<string, unknown>;
18
+ numFmt?: {
19
+ numFmtId: number;
20
+ formatCode?: string;
21
+ };
22
+ }
23
+ declare const nativeConditionalRuleTypes: readonly ["cellIs", "expression", "containsText", "notContainsText", "beginsWith", "endsWith", "containsBlanks", "notContainsBlanks", "duplicateValues", "uniqueValues", "aboveAverage", "top10", "colorScale", "dataBar", "iconSet", "timePeriod", "containsErrors", "notContainsErrors"];
24
+ interface XlsxConditionalThreshold {
25
+ type: "min" | "max" | "num" | "percent" | "percentile" | "formula";
26
+ val?: string;
27
+ gte?: boolean;
28
+ }
29
+ interface XlsxConditionalColorScale {
30
+ thresholds: XlsxConditionalThreshold[];
31
+ colors: Record<string, unknown>[];
32
+ }
33
+ interface XlsxConditionalDataBar {
34
+ thresholds: XlsxConditionalThreshold[];
35
+ color: Record<string, unknown>;
36
+ showValue?: boolean;
37
+ minLength?: number;
38
+ maxLength?: number;
39
+ /** 已从关联 x14 节点验证的轴位置。 */
40
+ axisPosition?: "none";
41
+ }
42
+ interface XlsxConditionalIconSet {
43
+ thresholds: XlsxConditionalThreshold[];
44
+ iconSet: string;
45
+ showValue?: boolean;
46
+ reverse?: boolean;
47
+ percent?: boolean;
48
+ }
49
+ /** 条件规则投影保留原文;无效的优先级不分配替代值。 */
50
+ interface XlsxConditionalFormattingRule {
51
+ type: (typeof nativeConditionalRuleTypes)[number] | "unknown";
52
+ rawXml: string;
53
+ editRestriction?: string;
54
+ linkedExtension?: {
55
+ id: string;
56
+ rawXml: string;
57
+ };
58
+ priority?: number;
59
+ stopIfTrue?: boolean;
60
+ dxfId?: number;
61
+ aboveAverage?: boolean;
62
+ equalAverage?: boolean;
63
+ stdDev?: number;
64
+ rank?: number;
65
+ percent?: boolean;
66
+ bottom?: boolean;
67
+ timePeriod?: string;
68
+ colorScale?: XlsxConditionalColorScale;
69
+ dataBar?: XlsxConditionalDataBar;
70
+ iconSet?: XlsxConditionalIconSet;
71
+ operator?: string;
72
+ text?: string;
73
+ formula: string[];
74
+ unknownAttributes: string[];
75
+ restrictions: string[];
76
+ }
77
+ /** 规则编辑参数;省略 priority 时沿用原优先级或追加在末尾。 */
78
+ interface XlsxConditionalRuleDraft extends Partial<Pick<XlsxConditionalFormattingRule, "operator" | "text" | "formula" | "priority" | "stopIfTrue" | "dxfId" | "aboveAverage" | "equalAverage" | "stdDev" | "rank" | "percent" | "bottom" | "timePeriod" | "colorScale" | "dataBar" | "iconSet">> {
79
+ type: Exclude<XlsxConditionalFormattingRule["type"], "unknown">;
80
+ range: XlsxCellRange[];
81
+ style?: XlsxConditionalDifferentialStyle;
82
+ }
83
+ /** ruleId 使用当前投影的区块序号/规则序号,与 stamp 一起定位。 */
84
+ type XlsxConditionalFormatPatch = {
85
+ kind: "insert";
86
+ draft: XlsxConditionalRuleDraft;
87
+ } | {
88
+ kind: "update";
89
+ ruleId: string;
90
+ draft: XlsxConditionalRuleDraft;
91
+ } | {
92
+ kind: "delete";
93
+ ruleId: string;
94
+ } | {
95
+ kind: "reorder";
96
+ ruleIds: string[];
97
+ };
98
+
3
99
  /** 文件解析/写出的能力诊断,不是单元格业务模型。 */
4
100
  interface XlsxCompatibilityIssue {
5
101
  code: string;
@@ -27,6 +123,7 @@ interface XlsxNativeCellChange {
27
123
  }
28
124
  /** 原生多表单元格事务。 */
29
125
  interface XlsxNativeCellTransaction {
126
+ acceptValidationWarnings?: boolean;
30
127
  stamp: XlsxDocumentStamp;
31
128
  changes: XlsxNativeCellChange[];
32
129
  }
@@ -39,6 +136,10 @@ interface XlsxNativePartChange {
39
136
  }
40
137
  interface XlsxNativeTransaction extends XlsxNativeCellTransaction {
41
138
  parts: XlsxNativePartChange[];
139
+ conditionalFormatting?: {
140
+ sheetName: string;
141
+ patch: XlsxConditionalFormatPatch;
142
+ };
42
143
  }
43
144
 
44
145
  type XlsxNativePartsPreflight = {