@rowsncolumns/toolkit 24.4.4 → 24.5.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/dist/cjs/autofilter-condition.d.ts +45 -1
- package/dist/cjs/autofilter-condition.d.ts.map +1 -1
- package/dist/cjs/autofilter-condition.js +135 -12
- package/dist/cjs/excel-parser/helpers.d.ts +15 -1
- package/dist/cjs/excel-parser/helpers.d.ts.map +1 -1
- package/dist/cjs/excel-parser/helpers.js +119 -5
- package/dist/cjs/excel-parser/interface.d.ts +3 -1
- package/dist/cjs/excel-parser/interface.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/ods/index.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/ods/index.js +186 -97
- package/dist/cjs/excel-parser/plugins/ods/styles.d.ts +15 -0
- package/dist/cjs/excel-parser/plugins/ods/styles.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/ods/styles.js +80 -6
- package/dist/cjs/excel-parser/plugins/xlsb/index.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsb/index.js +107 -103
- package/dist/cjs/excel-parser/plugins/xlsx/charts.d.ts +77 -1
- package/dist/cjs/excel-parser/plugins/xlsx/charts.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/charts.js +920 -122
- package/dist/cjs/excel-parser/plugins/xlsx/drawing.d.ts +7 -1
- package/dist/cjs/excel-parser/plugins/xlsx/drawing.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/drawing.js +24 -9
- package/dist/cjs/excel-parser/plugins/xlsx/form-controls.d.ts +24 -3
- package/dist/cjs/excel-parser/plugins/xlsx/form-controls.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/form-controls.js +25 -3
- package/dist/cjs/excel-parser/plugins/xlsx/index.d.ts +24 -1
- package/dist/cjs/excel-parser/plugins/xlsx/index.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/index.js +561 -394
- package/dist/cjs/excel-parser/plugins/xlsx/pivots.d.ts +8 -2
- package/dist/cjs/excel-parser/plugins/xlsx/pivots.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/pivots.js +312 -21
- package/dist/cjs/excel-parser/plugins/xlsx/relationships.d.ts +6 -0
- package/dist/cjs/excel-parser/plugins/xlsx/relationships.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/relationships.js +9 -0
- package/dist/cjs/excel-parser/plugins/xlsx/theme.d.ts +1 -1
- package/dist/cjs/excel-parser/types.d.ts +9 -1
- package/dist/cjs/excel-parser/types.d.ts.map +1 -1
- package/dist/cjs/excel-parser/workbook.d.ts +1 -0
- package/dist/cjs/excel-parser/workbook.d.ts.map +1 -1
- package/dist/cjs/excel-parser/workbook.js +5 -0
- package/dist/cjs/excel-parser/worker.js +2 -0
- package/dist/cjs/exporter/ods/ods-export.d.ts.map +1 -1
- package/dist/cjs/exporter/ods/ods-export.js +255 -80
- package/dist/cjs/exporter/xlsx/chart-builder.d.ts +7 -1
- package/dist/cjs/exporter/xlsx/chart-builder.d.ts.map +1 -1
- package/dist/cjs/exporter/xlsx/chart-builder.js +902 -119
- package/dist/cjs/exporter/xlsx/form-controls-builder.d.ts +16 -3
- package/dist/cjs/exporter/xlsx/form-controls-builder.d.ts.map +1 -1
- package/dist/cjs/exporter/xlsx/form-controls-builder.js +30 -8
- package/dist/cjs/exporter/xlsx/pivot-builder.d.ts.map +1 -1
- package/dist/cjs/exporter/xlsx/pivot-builder.js +206 -162
- package/dist/cjs/exporter/xlsx/style-builder.d.ts +8 -2
- package/dist/cjs/exporter/xlsx/style-builder.d.ts.map +1 -1
- package/dist/cjs/exporter/xlsx/style-builder.js +25 -0
- package/dist/cjs/exporter/xlsx/xlsx-export.d.ts +2 -2
- package/dist/cjs/exporter/xlsx/xlsx-export.d.ts.map +1 -1
- package/dist/cjs/exporter/xlsx/xlsx-export.js +728 -452
- package/dist/esm/autofilter-condition.d.ts +45 -1
- package/dist/esm/autofilter-condition.d.ts.map +1 -1
- package/dist/esm/autofilter-condition.js +131 -11
- package/dist/esm/excel-parser/helpers.d.ts +15 -1
- package/dist/esm/excel-parser/helpers.d.ts.map +1 -1
- package/dist/esm/excel-parser/helpers.js +94 -4
- package/dist/esm/excel-parser/interface.d.ts +3 -1
- package/dist/esm/excel-parser/interface.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/ods/index.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/ods/index.js +105 -22
- package/dist/esm/excel-parser/plugins/ods/styles.d.ts +15 -0
- package/dist/esm/excel-parser/plugins/ods/styles.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/ods/styles.js +79 -5
- package/dist/esm/excel-parser/plugins/xlsb/index.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsb/index.js +15 -7
- package/dist/esm/excel-parser/plugins/xlsx/charts.d.ts +77 -1
- package/dist/esm/excel-parser/plugins/xlsx/charts.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/charts.js +708 -16
- package/dist/esm/excel-parser/plugins/xlsx/drawing.d.ts +7 -1
- package/dist/esm/excel-parser/plugins/xlsx/drawing.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/drawing.js +23 -0
- package/dist/esm/excel-parser/plugins/xlsx/form-controls.d.ts +24 -3
- package/dist/esm/excel-parser/plugins/xlsx/form-controls.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/form-controls.js +21 -3
- package/dist/esm/excel-parser/plugins/xlsx/index.d.ts +24 -1
- package/dist/esm/excel-parser/plugins/xlsx/index.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/index.js +192 -54
- package/dist/esm/excel-parser/plugins/xlsx/pivots.d.ts +8 -2
- package/dist/esm/excel-parser/plugins/xlsx/pivots.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/pivots.js +220 -4
- package/dist/esm/excel-parser/plugins/xlsx/relationships.d.ts +6 -0
- package/dist/esm/excel-parser/plugins/xlsx/relationships.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/relationships.js +9 -0
- package/dist/esm/excel-parser/plugins/xlsx/theme.d.ts +1 -1
- package/dist/esm/excel-parser/types.d.ts +9 -1
- package/dist/esm/excel-parser/types.d.ts.map +1 -1
- package/dist/esm/excel-parser/workbook.d.ts +1 -0
- package/dist/esm/excel-parser/workbook.d.ts.map +1 -1
- package/dist/esm/excel-parser/workbook.js +4 -0
- package/dist/esm/excel-parser/worker.js +2 -0
- package/dist/esm/exporter/ods/ods-export.d.ts.map +1 -1
- package/dist/esm/exporter/ods/ods-export.js +238 -72
- package/dist/esm/exporter/xlsx/chart-builder.d.ts +7 -1
- package/dist/esm/exporter/xlsx/chart-builder.d.ts.map +1 -1
- package/dist/esm/exporter/xlsx/chart-builder.js +674 -58
- package/dist/esm/exporter/xlsx/form-controls-builder.d.ts +16 -3
- package/dist/esm/exporter/xlsx/form-controls-builder.d.ts.map +1 -1
- package/dist/esm/exporter/xlsx/form-controls-builder.js +29 -8
- package/dist/esm/exporter/xlsx/pivot-builder.d.ts.map +1 -1
- package/dist/esm/exporter/xlsx/pivot-builder.js +187 -139
- package/dist/esm/exporter/xlsx/style-builder.d.ts +8 -2
- package/dist/esm/exporter/xlsx/style-builder.d.ts.map +1 -1
- package/dist/esm/exporter/xlsx/style-builder.js +28 -0
- package/dist/esm/exporter/xlsx/xlsx-export.d.ts +2 -2
- package/dist/esm/exporter/xlsx/xlsx-export.d.ts.map +1 -1
- package/dist/esm/exporter/xlsx/xlsx-export.js +451 -197
- package/package.json +11 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EmbedFormControlSpec } from "@rowsncolumns/spreadsheet";
|
|
1
|
+
import type { EmbedFormControlSpec, OverlayPosition } from "@rowsncolumns/spreadsheet";
|
|
2
2
|
/**
|
|
3
3
|
* Excel form-control writers — the inverse of
|
|
4
4
|
* `excel-parser/plugins/xlsx/form-controls.ts`. A control is three parts:
|
|
@@ -20,13 +20,25 @@ export type ControlCellAnchor = {
|
|
|
20
20
|
row: number;
|
|
21
21
|
rowOff: number;
|
|
22
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* The `<anchor moveWithCells sizeWithCells>` flags to write: the control's
|
|
25
|
+
* placement mode when its position carries one (Move and size = both, Move
|
|
26
|
+
* but don't size = `moveWithCells`, Don't move or size = neither) — a
|
|
27
|
+
* persisted second anchor is a "Move and size" object too — else the flags
|
|
28
|
+
* the spec arrived with (#668 C-46).
|
|
29
|
+
*/
|
|
30
|
+
export declare const controlAnchorFlags: (spec: Pick<EmbedFormControlSpec, "moveWithCells" | "sizeWithCells">, overlay?: Pick<OverlayPosition, "placement" | "toCell"> | null) => {
|
|
31
|
+
moveWithCells: boolean;
|
|
32
|
+
sizeWithCells: boolean;
|
|
33
|
+
};
|
|
23
34
|
/** One `<control>` element (inside the `<controls>` wrapper). */
|
|
24
|
-
export declare const buildControlElementXml: ({ spec, relId, shapeId, from, to, }: {
|
|
35
|
+
export declare const buildControlElementXml: ({ spec, relId, shapeId, from, to, overlay, }: {
|
|
25
36
|
spec: EmbedFormControlSpec;
|
|
26
37
|
relId: string;
|
|
27
38
|
shapeId: number;
|
|
28
39
|
from: ControlCellAnchor;
|
|
29
40
|
to: ControlCellAnchor;
|
|
41
|
+
overlay?: Pick<OverlayPosition, "placement" | "toCell"> | null;
|
|
30
42
|
}) => string;
|
|
31
43
|
/**
|
|
32
44
|
* The worksheet `<controls>` element. Excel wraps controls in an
|
|
@@ -47,11 +59,12 @@ export type FormControlVmlGeometry = {
|
|
|
47
59
|
anchor: [number, number, number, number, number, number, number, number];
|
|
48
60
|
};
|
|
49
61
|
/** One `<v:shape>` drawing a form control. */
|
|
50
|
-
export declare const buildFormControlVmlShape: ({ spec, shapeId, zIndex, geometry, }: {
|
|
62
|
+
export declare const buildFormControlVmlShape: ({ spec, shapeId, zIndex, geometry, overlay, }: {
|
|
51
63
|
spec: EmbedFormControlSpec;
|
|
52
64
|
shapeId: number;
|
|
53
65
|
zIndex: number;
|
|
54
66
|
geometry: FormControlVmlGeometry;
|
|
67
|
+
overlay?: Pick<OverlayPosition, "placement" | "toCell"> | null;
|
|
55
68
|
}) => string;
|
|
56
69
|
/** Wrap note + control shapes into one `vmlDrawing` part. */
|
|
57
70
|
export declare const buildVmlDrawingXml: ({ shapeTypes, shapes, }: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-controls-builder.d.ts","sourceRoot":"","sources":["../../../../exporter/xlsx/form-controls-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"form-controls-builder.d.ts","sourceRoot":"","sources":["../../../../exporter/xlsx/form-controls-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,eAAe,EAChB,MAAM,2BAA2B,CAAC;AAEnC;;;;;;;;GAQG;AAEH,eAAO,MAAM,sBAAsB,mDACe,CAAC;AACnD,eAAO,MAAM,kBAAkB,iFACiD,CAAC;AACjF,eAAO,MAAM,eAAe,kEACqC,CAAC;AAuBlE,yCAAyC;AACzC,eAAO,MAAM,gBAAgB,GAAI,MAAM,oBAAoB,KAAG,MAU7D,CAAC;AAEF,gEAAgE;AAChE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAC7B,MAAM,IAAI,CAAC,oBAAoB,EAAE,eAAe,GAAG,eAAe,CAAC,EACnE,UAAU,IAAI,CAAC,eAAe,EAAE,WAAW,GAAG,QAAQ,CAAC,GAAG,IAAI,KAC7D;IAAE,aAAa,EAAE,OAAO,CAAC;IAAC,aAAa,EAAE,OAAO,CAAA;CAalD,CAAC;AASF,iEAAiE;AACjE,eAAO,MAAM,sBAAsB,GAAI,8CAOpC;IACD,IAAI,EAAE,oBAAoB,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,iBAAiB,CAAC;IACxB,EAAE,EAAE,iBAAiB,CAAC;IACtB,OAAO,CAAC,EAAE,IAAI,CAAC,eAAe,EAAE,WAAW,GAAG,QAAQ,CAAC,GAAG,IAAI,CAAC;CAChE,KAAG,MAcH,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,iBAAiB,MAAM,EAAE,KAAG,MAK5D,CAAC;AAsEF,0EAA0E;AAC1E,eAAO,MAAM,0BAA0B,oSAA4Q,CAAC;AAEpT,iFAAiF;AACjF,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,qFAAqF;IACrF,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1E,CAAC;AAIF,8CAA8C;AAC9C,eAAO,MAAM,wBAAwB,GAAI,+CAMtC;IACD,IAAI,EAAE,oBAAoB,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,sBAAsB,CAAC;IACjC,OAAO,CAAC,EAAE,IAAI,CAAC,eAAe,EAAE,WAAW,GAAG,QAAQ,CAAC,GAAG,IAAI,CAAC;CAChE,KAAG,MAsBH,CAAC;AAEF,6DAA6D;AAC7D,eAAO,MAAM,kBAAkB,GAAI,yBAGhC;IACD,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,KAAG,MAAM,GAAG,SAKZ,CAAC"}
|
|
@@ -47,16 +47,38 @@ export var buildCtrlPropXml = function (spec) {
|
|
|
47
47
|
var open = "<formControlPr xmlns=\"".concat(FORM_CONTROL_NS, "\" objectType=\"").concat(escapeAttr(spec.objectType), "\"").concat(attrsXml(rest));
|
|
48
48
|
return "".concat(XML_DECLARATION).concat(body ? "".concat(open, ">").concat(body, "</formControlPr>") : "".concat(open, "/>"));
|
|
49
49
|
};
|
|
50
|
+
/**
|
|
51
|
+
* The `<anchor moveWithCells sizeWithCells>` flags to write: the control's
|
|
52
|
+
* placement mode when its position carries one (Move and size = both, Move
|
|
53
|
+
* but don't size = `moveWithCells`, Don't move or size = neither) — a
|
|
54
|
+
* persisted second anchor is a "Move and size" object too — else the flags
|
|
55
|
+
* the spec arrived with (#668 C-46).
|
|
56
|
+
*/
|
|
57
|
+
export var controlAnchorFlags = function (spec, overlay) {
|
|
58
|
+
var _a;
|
|
59
|
+
var placement = (_a = overlay === null || overlay === void 0 ? void 0 : overlay.placement) !== null && _a !== void 0 ? _a : ((overlay === null || overlay === void 0 ? void 0 : overlay.toCell) ? "moveAndSize" : undefined);
|
|
60
|
+
if (placement) {
|
|
61
|
+
return {
|
|
62
|
+
moveWithCells: placement !== "absolute",
|
|
63
|
+
sizeWithCells: placement === "moveAndSize",
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
moveWithCells: spec.moveWithCells === true,
|
|
68
|
+
sizeWithCells: spec.sizeWithCells === true,
|
|
69
|
+
};
|
|
70
|
+
};
|
|
50
71
|
var cellAnchorXml = function (tag, anchor) {
|
|
51
72
|
return "<".concat(tag, "><xdr:col>").concat(anchor.col, "</xdr:col><xdr:colOff>").concat(Math.round(anchor.colOff), "</xdr:colOff><xdr:row>").concat(anchor.row, "</xdr:row><xdr:rowOff>").concat(Math.round(anchor.rowOff), "</xdr:rowOff></").concat(tag, ">");
|
|
52
73
|
};
|
|
53
74
|
/** One `<control>` element (inside the `<controls>` wrapper). */
|
|
54
75
|
export var buildControlElementXml = function (_a) {
|
|
55
76
|
var _b;
|
|
56
|
-
var spec = _a.spec, relId = _a.relId, shapeId = _a.shapeId, from = _a.from, to = _a.to;
|
|
77
|
+
var spec = _a.spec, relId = _a.relId, shapeId = _a.shapeId, from = _a.from, to = _a.to, overlay = _a.overlay;
|
|
57
78
|
var name = (_b = spec.name) !== null && _b !== void 0 ? _b : "".concat(spec.objectType, " ").concat(shapeId);
|
|
58
|
-
var
|
|
59
|
-
|
|
79
|
+
var flags = controlAnchorFlags(spec, overlay);
|
|
80
|
+
var anchorAttrs = (flags.moveWithCells ? ' moveWithCells="1"' : "") +
|
|
81
|
+
(flags.sizeWithCells ? ' sizeWithCells="1"' : "");
|
|
60
82
|
return "<control shapeId=\"".concat(shapeId, "\" r:id=\"").concat(relId, "\" name=\"").concat(escapeAttr(name), "\"><controlPr").concat(attrsXml(spec.controlProperties), "><anchor").concat(anchorAttrs, ">").concat(cellAnchorXml("from", from)).concat(cellAnchorXml("to", to), "</anchor></controlPr></control>");
|
|
61
83
|
};
|
|
62
84
|
/**
|
|
@@ -84,7 +106,7 @@ var truthy = function (value) {
|
|
|
84
106
|
* range, selection, scroll values) from the VML, the ctrlProp part is the
|
|
85
107
|
* x14 mirror.
|
|
86
108
|
*/
|
|
87
|
-
var clientDataChildrenXml = function (spec) {
|
|
109
|
+
var clientDataChildrenXml = function (spec, flags) {
|
|
88
110
|
var _a, _b;
|
|
89
111
|
var p = (_a = spec.properties) !== null && _a !== void 0 ? _a : {};
|
|
90
112
|
var c = (_b = spec.controlProperties) !== null && _b !== void 0 ? _b : {};
|
|
@@ -95,9 +117,9 @@ var clientDataChildrenXml = function (spec) {
|
|
|
95
117
|
else
|
|
96
118
|
out.push("<x:".concat(tag, ">").concat(escapeText(value), "</x:").concat(tag, ">"));
|
|
97
119
|
};
|
|
98
|
-
if (
|
|
120
|
+
if (flags.moveWithCells)
|
|
99
121
|
push("MoveWithCells");
|
|
100
|
-
if (
|
|
122
|
+
if (flags.sizeWithCells)
|
|
101
123
|
push("SizeWithCells");
|
|
102
124
|
// Anchor is inserted by the caller (needs sheet geometry).
|
|
103
125
|
out.push("__ANCHOR__");
|
|
@@ -179,12 +201,12 @@ var toPt = function (px) { return "".concat((px * 0.75).toFixed(2).replace(/\.?0
|
|
|
179
201
|
/** One `<v:shape>` drawing a form control. */
|
|
180
202
|
export var buildFormControlVmlShape = function (_a) {
|
|
181
203
|
var _b;
|
|
182
|
-
var spec = _a.spec, shapeId = _a.shapeId, zIndex = _a.zIndex, geometry = _a.geometry;
|
|
204
|
+
var spec = _a.spec, shapeId = _a.shapeId, zIndex = _a.zIndex, geometry = _a.geometry, overlay = _a.overlay;
|
|
183
205
|
var objectType = (_b = VML_OBJECT_TYPE[spec.objectType]) !== null && _b !== void 0 ? _b : spec.objectType;
|
|
184
206
|
var caption = spec.text
|
|
185
207
|
? "<div style=\"text-align:left\"><font face=\"Tahoma\" size=\"160\" color=\"auto\">".concat(escapeText(spec.text), "</font></div>")
|
|
186
208
|
: "";
|
|
187
|
-
var clientData = clientDataChildrenXml(spec).replace("__ANCHOR__", "<x:Anchor>".concat(geometry.anchor.join(", "), "</x:Anchor>"));
|
|
209
|
+
var clientData = clientDataChildrenXml(spec, controlAnchorFlags(spec, overlay)).replace("__ANCHOR__", "<x:Anchor>".concat(geometry.anchor.join(", "), "</x:Anchor>"));
|
|
188
210
|
var style = "position:absolute;margin-left:".concat(toPt(geometry.leftPx), ";margin-top:").concat(toPt(geometry.topPx), ";width:").concat(toPt(geometry.widthPx), ";height:").concat(toPt(geometry.heightPx), ";z-index:").concat(zIndex, ";mso-wrap-style:tight");
|
|
189
211
|
return "<v:shape id=\"_x0000_s".concat(shapeId, "\" type=\"#_x0000_t201\" style=\"").concat(style, "\" filled=\"f\" fillcolor=\"window [65]\" stroked=\"f\" strokecolor=\"windowText [64]\" o:insetmode=\"auto\"><v:path shadowok=\"f\" o:extrusionok=\"f\" strokeok=\"f\" fillok=\"f\" o:connecttype=\"rect\"/><v:textbox style=\"mso-direction-alt:auto\" o:singleclick=\"f\">").concat(caption, "</v:textbox><x:ClientData ObjectType=\"").concat(escapeAttr(objectType), "\">").concat(clientData, "</x:ClientData></v:shape>");
|
|
190
212
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pivot-builder.d.ts","sourceRoot":"","sources":["../../../../exporter/xlsx/pivot-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"pivot-builder.d.ts","sourceRoot":"","sources":["../../../../exporter/xlsx/pivot-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,KAAK,EAKV,UAAU,EAEX,MAAM,2BAA2B,CAAC;AAqBnC;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,GAAI,SAAS,MAAM,KAAG,MAAM,EAYjE,CAAC;AA6HF;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B,GACvC,OAAO,UAAU,EACjB,WAAW,MAAM,EACjB,YAAY,MAAM,EAAE,KACnB,MAAM,GAAG,IA2CX,CAAC;AAsDF;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,GAC7B,OAAO,UAAU,EACjB,SAAS,MAAM,EACf,cAAc,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,KAChC,MAAM,GAAG,IAkKX,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,GACjC,UAAU,MAAM,EAChB,aAAa,MAAM,KAClB,MAUF,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __read, __spreadArray, __values } from "tslib";
|
|
1
|
+
import { __assign, __read, __spreadArray, __values } from "tslib";
|
|
2
2
|
import { XMLBuilder } from "fast-xml-parser";
|
|
3
3
|
/**
|
|
4
4
|
* `PivotValue.showAs` → `dataField@showDataAs` (ECMA-376) or, for the
|
|
@@ -52,10 +52,41 @@ export var calculatedFieldReferences = function (formula) {
|
|
|
52
52
|
};
|
|
53
53
|
var xmlBuilder = new XMLBuilder({
|
|
54
54
|
ignoreAttributes: false,
|
|
55
|
-
|
|
55
|
+
preserveOrder: true,
|
|
56
|
+
attributeNamePrefix: "",
|
|
57
|
+
suppressEmptyNode: true,
|
|
56
58
|
format: true,
|
|
57
59
|
indentBy: " ",
|
|
58
60
|
});
|
|
61
|
+
/** An element with `attributes` (undefined values dropped) and ordered `children`. */
|
|
62
|
+
var el = function (tag, attributes, children) {
|
|
63
|
+
var e_2, _a, _b, _c;
|
|
64
|
+
if (attributes === void 0) { attributes = {}; }
|
|
65
|
+
if (children === void 0) { children = []; }
|
|
66
|
+
var attrs = {};
|
|
67
|
+
try {
|
|
68
|
+
for (var _d = __values(Object.entries(attributes)), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
69
|
+
var _f = __read(_e.value, 2), key = _f[0], value = _f[1];
|
|
70
|
+
if (value !== undefined)
|
|
71
|
+
attrs[key] = value;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
75
|
+
finally {
|
|
76
|
+
try {
|
|
77
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
78
|
+
}
|
|
79
|
+
finally { if (e_2) throw e_2.error; }
|
|
80
|
+
}
|
|
81
|
+
return Object.keys(attrs).length ? (_b = {}, _b[tag] = children, _b[":@"] = attrs, _b) : (_c = {}, _c[tag] = children, _c);
|
|
82
|
+
};
|
|
83
|
+
var XML_DECLARATION = {
|
|
84
|
+
"?xml": [{ "#text": "" }],
|
|
85
|
+
":@": { version: "1.0", encoding: "UTF-8", standalone: "yes" },
|
|
86
|
+
};
|
|
87
|
+
var buildDocument = function (root) {
|
|
88
|
+
return xmlBuilder.build([XML_DECLARATION, root]);
|
|
89
|
+
};
|
|
59
90
|
/**
|
|
60
91
|
* Convert numeric col/row to A1 notation. 1-indexed.
|
|
61
92
|
* e.g. (1, 1) → "A1", (28, 5) → "AB5".
|
|
@@ -95,6 +126,24 @@ var aggToSubtotal = function (agg) {
|
|
|
95
126
|
};
|
|
96
127
|
return (_a = map[agg]) !== null && _a !== void 0 ? _a : "sum";
|
|
97
128
|
};
|
|
129
|
+
/** Preserved XLSX cache items by cache-field name (`PivotTable.cacheFields`). */
|
|
130
|
+
var preservedCacheFields = function (pivot) { var _a; return new Map(((_a = pivot.cacheFields) !== null && _a !== void 0 ? _a : []).map(function (field) { return [field.name, field]; })); };
|
|
131
|
+
/**
|
|
132
|
+
* Preserved `<sharedItems …>`: its attributes, `count` only with an item list
|
|
133
|
+
* (Excel's form — a numeric field keeps just its type attributes), children
|
|
134
|
+
* in document order (`<s v/>`, `<n v/>`, `<m/>`… with any further attributes).
|
|
135
|
+
*/
|
|
136
|
+
var buildSharedItems = function (shared) {
|
|
137
|
+
var _a;
|
|
138
|
+
return el("sharedItems", __assign(__assign({}, ((_a = shared.attributes) !== null && _a !== void 0 ? _a : {})), (shared.items.length ? { count: String(shared.items.length) } : {})), shared.items.map(function (item) { var _a; return el(item.type, __assign({ v: item.value }, ((_a = item.attributes) !== null && _a !== void 0 ? _a : {}))); }));
|
|
139
|
+
};
|
|
140
|
+
/** Preserved `<pivotField><items>`: `x`, `t`, the rest verbatim, in Excel's order. */
|
|
141
|
+
var buildFieldItems = function (items) {
|
|
142
|
+
return el("items", { count: String(items.length) }, items.map(function (item) {
|
|
143
|
+
var _a;
|
|
144
|
+
return el("item", __assign(__assign(__assign({}, (item.x !== undefined ? { x: String(item.x) } : {})), (item.t !== undefined ? { t: item.t } : {})), ((_a = item.attributes) !== null && _a !== void 0 ? _a : {})));
|
|
145
|
+
}));
|
|
146
|
+
};
|
|
98
147
|
/**
|
|
99
148
|
* Build pivotCacheDefinition XML for a pivot. The cacheSource
|
|
100
149
|
* points at the live worksheet range; `refreshOnLoad="1"` makes
|
|
@@ -112,35 +161,57 @@ export var buildPivotCacheDefinitionXml = function (pivot, sheetName, fieldNames
|
|
|
112
161
|
// Calculated fields are cache fields too (`databaseField="0"` +
|
|
113
162
|
// `formula`), listed after the source columns like Excel does.
|
|
114
163
|
var calculatedByName = new Map(((_a = pivot.calculatedFields) !== null && _a !== void 0 ? _a : []).map(function (c) { return [c.name, c.formula]; }));
|
|
164
|
+
var preserved = preservedCacheFields(pivot);
|
|
165
|
+
var preservedAny = false;
|
|
115
166
|
var cacheFields = fieldNames.map(function (name) {
|
|
167
|
+
var _a;
|
|
116
168
|
var formula = calculatedByName.get(name);
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
169
|
+
if (formula !== undefined) {
|
|
170
|
+
return el("cacheField", { name: name, formula: formula, databaseField: "0" });
|
|
171
|
+
}
|
|
172
|
+
var shared = (_a = preserved.get(name)) === null || _a === void 0 ? void 0 : _a.sharedItems;
|
|
173
|
+
if (!shared)
|
|
174
|
+
return el("cacheField", { name: name }, [el("sharedItems", { count: "0" })]);
|
|
175
|
+
preservedAny = true;
|
|
176
|
+
return el("cacheField", { name: name }, [buildSharedItems(shared)]);
|
|
120
177
|
});
|
|
121
|
-
|
|
122
|
-
"
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
178
|
+
return buildDocument(el("pivotCacheDefinition", __assign({ xmlns: "http://schemas.openxmlformats.org/spreadsheetml/2006/main", "xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships", invalid: "1", refreshOnLoad: "1", refreshedBy: "Rows n Columns", recordCount: "0" }, (preservedAny ? { saveData: "0" } : {})), [
|
|
179
|
+
el("cacheSource", { type: "worksheet" }, [
|
|
180
|
+
el("worksheetSource", { ref: sourceRef, sheet: sheetName }),
|
|
181
|
+
]),
|
|
182
|
+
el("cacheFields", { count: String(cacheFields.length) }, cacheFields),
|
|
183
|
+
]));
|
|
184
|
+
};
|
|
185
|
+
/** `PivotArea` → `<pivotArea …><references count><reference … count><x v/>…` (Excel's `<x/>` order). */
|
|
186
|
+
var buildPivotArea = function (area) {
|
|
187
|
+
var _a, _b;
|
|
188
|
+
var references = (_a = area.references) !== null && _a !== void 0 ? _a : [];
|
|
189
|
+
return el("pivotArea", (_b = area.attributes) !== null && _b !== void 0 ? _b : {}, references.length
|
|
190
|
+
? [
|
|
191
|
+
el("references", { count: String(references.length) }, references.map(function (ref) {
|
|
192
|
+
var _a, _b;
|
|
193
|
+
var items = (_a = ref.items) !== null && _a !== void 0 ? _a : [];
|
|
194
|
+
return el("reference", __assign(__assign({}, ((_b = ref.attributes) !== null && _b !== void 0 ? _b : {})), { count: String(items.length) }), items.map(function (v) { return el("x", { v: String(v) }); }));
|
|
195
|
+
})),
|
|
196
|
+
]
|
|
197
|
+
: []);
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* `PivotTable.chartFormats` → `<chartFormats count><chartFormat chart
|
|
201
|
+
* format series><pivotArea>…`: the pivot areas a PivotChart's
|
|
202
|
+
* `<c:pivotFmt>` entries (`format`) format, keyed by the chart's
|
|
203
|
+
* `<c:fmtId>` (`chart`). Nothing is written without formats — Excel
|
|
204
|
+
* itself keeps `<c:pivotFmt>` entries with no `<chartFormat>`.
|
|
205
|
+
*/
|
|
206
|
+
var buildChartFormats = function (pivot) {
|
|
207
|
+
var _a;
|
|
208
|
+
var formats = (_a = pivot.chartFormats) !== null && _a !== void 0 ? _a : [];
|
|
209
|
+
if (!formats.length)
|
|
210
|
+
return undefined;
|
|
211
|
+
return el("chartFormats", { count: String(formats.length) }, formats.map(function (format) {
|
|
212
|
+
var _a;
|
|
213
|
+
return el("chartFormat", __assign({ chart: String(format.chart), format: String(format.format) }, (format.series ? { series: "1" } : {})), [buildPivotArea((_a = format.pivotArea) !== null && _a !== void 0 ? _a : {})]);
|
|
214
|
+
}));
|
|
144
215
|
};
|
|
145
216
|
/**
|
|
146
217
|
* Build the pivotTable layout XML. Excel determines whether a cell
|
|
@@ -152,8 +223,8 @@ export var buildPivotCacheDefinitionXml = function (pivot, sheetName, fieldNames
|
|
|
152
223
|
* @param fieldIndices Maps row/col/value field names → cacheField indices
|
|
153
224
|
*/
|
|
154
225
|
export var buildPivotTableXml = function (pivot, cacheId, fieldIndices) {
|
|
155
|
-
var
|
|
156
|
-
var _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r
|
|
226
|
+
var e_3, _a, e_4, _b, e_5, _c, e_6, _d;
|
|
227
|
+
var _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
157
228
|
if (!pivot.pivotRange)
|
|
158
229
|
return null;
|
|
159
230
|
var ref = rangeRef(pivot.pivotRange);
|
|
@@ -167,190 +238,168 @@ export var buildPivotTableXml = function (pivot, cacheId, fieldIndices) {
|
|
|
167
238
|
// value fields and tag with the appropriate axis.
|
|
168
239
|
var fieldAxis = new Map();
|
|
169
240
|
try {
|
|
170
|
-
for (var
|
|
171
|
-
var r =
|
|
241
|
+
for (var _s = __values((_e = pivot.rows) !== null && _e !== void 0 ? _e : []), _t = _s.next(); !_t.done; _t = _s.next()) {
|
|
242
|
+
var r = _t.value;
|
|
172
243
|
var idx = fieldIndices.get(r.field);
|
|
173
244
|
if (idx != null)
|
|
174
245
|
fieldAxis.set(idx, "axisRow");
|
|
175
246
|
}
|
|
176
247
|
}
|
|
177
|
-
catch (
|
|
248
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
178
249
|
finally {
|
|
179
250
|
try {
|
|
180
|
-
if (
|
|
251
|
+
if (_t && !_t.done && (_a = _s.return)) _a.call(_s);
|
|
181
252
|
}
|
|
182
|
-
finally { if (
|
|
253
|
+
finally { if (e_3) throw e_3.error; }
|
|
183
254
|
}
|
|
184
255
|
try {
|
|
185
|
-
for (var
|
|
186
|
-
var c =
|
|
256
|
+
for (var _u = __values((_f = pivot.columns) !== null && _f !== void 0 ? _f : []), _v = _u.next(); !_v.done; _v = _u.next()) {
|
|
257
|
+
var c = _v.value;
|
|
187
258
|
var idx = fieldIndices.get(c.field);
|
|
188
259
|
if (idx != null)
|
|
189
260
|
fieldAxis.set(idx, "axisCol");
|
|
190
261
|
}
|
|
191
262
|
}
|
|
192
|
-
catch (
|
|
263
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
193
264
|
finally {
|
|
194
265
|
try {
|
|
195
|
-
if (
|
|
266
|
+
if (_v && !_v.done && (_b = _u.return)) _b.call(_u);
|
|
196
267
|
}
|
|
197
|
-
finally { if (
|
|
268
|
+
finally { if (e_4) throw e_4.error; }
|
|
198
269
|
}
|
|
199
270
|
var dataFieldIndices = new Set();
|
|
200
271
|
try {
|
|
201
|
-
for (var
|
|
202
|
-
var v =
|
|
272
|
+
for (var _w = __values((_g = pivot.values) !== null && _g !== void 0 ? _g : []), _x = _w.next(); !_x.done; _x = _w.next()) {
|
|
273
|
+
var v = _x.value;
|
|
203
274
|
var idx = fieldIndices.get(v.field);
|
|
204
275
|
if (idx != null)
|
|
205
276
|
dataFieldIndices.add(idx);
|
|
206
277
|
}
|
|
207
278
|
}
|
|
208
|
-
catch (
|
|
279
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
209
280
|
finally {
|
|
210
281
|
try {
|
|
211
|
-
if (
|
|
282
|
+
if (_x && !_x.done && (_c = _w.return)) _c.call(_w);
|
|
212
283
|
}
|
|
213
|
-
finally { if (
|
|
284
|
+
finally { if (e_5) throw e_5.error; }
|
|
214
285
|
}
|
|
215
286
|
var calculatedNames = new Set(((_h = pivot.calculatedFields) !== null && _h !== void 0 ? _h : []).map(function (c) { return c.name; }));
|
|
287
|
+
var preserved = preservedCacheFields(pivot);
|
|
216
288
|
// Need to emit one <pivotField> per cacheField in order, even
|
|
217
289
|
// for unused fields (Excel requires the array shapes match).
|
|
218
290
|
// Caller passes us the full field set via fieldIndices.
|
|
219
291
|
var sortedFieldIndices = __spreadArray([], __read(fieldIndices.entries()), false).sort(function (a, b) { return a[1] - b[1]; });
|
|
220
292
|
try {
|
|
221
293
|
for (var sortedFieldIndices_1 = __values(sortedFieldIndices), sortedFieldIndices_1_1 = sortedFieldIndices_1.next(); !sortedFieldIndices_1_1.done; sortedFieldIndices_1_1 = sortedFieldIndices_1.next()) {
|
|
222
|
-
var
|
|
294
|
+
var _y = __read(sortedFieldIndices_1_1.value, 2), name_1 = _y[0], idx = _y[1];
|
|
223
295
|
var axis = fieldAxis.get(idx);
|
|
224
|
-
var
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
entry["@_dataField"] = "1";
|
|
296
|
+
var attributes = {
|
|
297
|
+
axis: axis,
|
|
298
|
+
dataField: dataFieldIndices.has(idx) ? "1" : undefined,
|
|
299
|
+
};
|
|
229
300
|
if (calculatedNames.has(name_1)) {
|
|
230
301
|
// Excel pins calculated fields to the values area.
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
entry["@_dragToPage"] = "0";
|
|
234
|
-
entry["@_showAll"] = "0";
|
|
235
|
-
entry["@_defaultSubtotal"] = "0";
|
|
236
|
-
}
|
|
237
|
-
else {
|
|
238
|
-
entry["@_compact"] = "0";
|
|
239
|
-
if (axis)
|
|
240
|
-
entry.items = {};
|
|
302
|
+
pivotFields.push(el("pivotField", __assign(__assign({}, attributes), { dragToRow: "0", dragToCol: "0", dragToPage: "0", showAll: "0", defaultSubtotal: "0" })));
|
|
303
|
+
continue;
|
|
241
304
|
}
|
|
242
|
-
|
|
305
|
+
// Preserved `<items>` (C-84) keep Excel's item order — the indices the
|
|
306
|
+
// pivot's `<chartFormats>` pivot areas reference.
|
|
307
|
+
var items = (_j = preserved.get(name_1)) === null || _j === void 0 ? void 0 : _j.items;
|
|
308
|
+
var children = (items === null || items === void 0 ? void 0 : items.length) ? [buildFieldItems(items)] : axis ? [el("items")] : [];
|
|
309
|
+
pivotFields.push(el("pivotField", __assign(__assign({}, attributes), { compact: "0" }), children));
|
|
243
310
|
}
|
|
244
311
|
}
|
|
245
|
-
catch (
|
|
312
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
246
313
|
finally {
|
|
247
314
|
try {
|
|
248
315
|
if (sortedFieldIndices_1_1 && !sortedFieldIndices_1_1.done && (_d = sortedFieldIndices_1.return)) _d.call(sortedFieldIndices_1);
|
|
249
316
|
}
|
|
250
|
-
finally { if (
|
|
317
|
+
finally { if (e_6) throw e_6.error; }
|
|
251
318
|
}
|
|
252
|
-
var
|
|
319
|
+
var rowFieldIndices = ((_k = pivot.rows) !== null && _k !== void 0 ? _k : [])
|
|
253
320
|
.map(function (r) { return fieldIndices.get(r.field); })
|
|
254
|
-
.filter(function (i) { return i != null; })
|
|
255
|
-
|
|
256
|
-
var colFields = ((_k = pivot.columns) !== null && _k !== void 0 ? _k : [])
|
|
321
|
+
.filter(function (i) { return i != null; });
|
|
322
|
+
var colFieldIndices = ((_l = pivot.columns) !== null && _l !== void 0 ? _l : [])
|
|
257
323
|
.map(function (c) { return fieldIndices.get(c.field); })
|
|
258
|
-
.filter(function (i) { return i != null; })
|
|
259
|
-
|
|
324
|
+
.filter(function (i) { return i != null; });
|
|
325
|
+
var axisFields = function (indices) { return indices.map(function (i) { return el("field", { x: String(i) }); }); };
|
|
260
326
|
// Running totals need a base field: Excel defaults to the first row
|
|
261
327
|
// field (falls back to the first column field / field 0).
|
|
262
|
-
var runTotalBase = (
|
|
263
|
-
var dataFields = ((
|
|
328
|
+
var runTotalBase = String((_o = (_m = rowFieldIndices[0]) !== null && _m !== void 0 ? _m : colFieldIndices[0]) !== null && _o !== void 0 ? _o : 0);
|
|
329
|
+
var dataFields = ((_p = pivot.values) !== null && _p !== void 0 ? _p : [])
|
|
264
330
|
.map(function (v) {
|
|
265
331
|
var _a;
|
|
266
332
|
var idx = fieldIndices.get(v.field);
|
|
267
333
|
if (idx == null)
|
|
268
334
|
return null;
|
|
269
|
-
var entry = {
|
|
270
|
-
"@_name": (_a = v.displayName) !== null && _a !== void 0 ? _a : "".concat(v.aggFunc, " of ").concat(v.field),
|
|
271
|
-
"@_fld": String(idx),
|
|
272
|
-
"@_subtotal": calculatedNames.has(v.field)
|
|
273
|
-
? "sum"
|
|
274
|
-
: aggToSubtotal(v.aggFunc),
|
|
275
|
-
};
|
|
276
335
|
var showDataAs = v.showAs ? SHOW_DATA_AS[v.showAs] : undefined;
|
|
277
|
-
if (showDataAs) {
|
|
278
|
-
entry["@_showDataAs"] = showDataAs;
|
|
279
|
-
if (showDataAs === "runTotal")
|
|
280
|
-
entry["@_baseField"] = runTotalBase;
|
|
281
|
-
}
|
|
282
336
|
var pivotShowAs = v.showAs ? X14_PIVOT_SHOW_AS[v.showAs] : undefined;
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
337
|
+
return el("dataField", {
|
|
338
|
+
name: (_a = v.displayName) !== null && _a !== void 0 ? _a : "".concat(v.aggFunc, " of ").concat(v.field),
|
|
339
|
+
fld: String(idx),
|
|
340
|
+
subtotal: calculatedNames.has(v.field) ? "sum" : aggToSubtotal(v.aggFunc),
|
|
341
|
+
showDataAs: showDataAs,
|
|
342
|
+
baseField: showDataAs === "runTotal" ? runTotalBase : undefined,
|
|
343
|
+
}, pivotShowAs
|
|
344
|
+
? [
|
|
345
|
+
el("extLst", {}, [
|
|
346
|
+
el("ext", { uri: X14_DATA_FIELD_EXT_URI, "xmlns:x14": X14_NS }, [
|
|
347
|
+
el("x14:dataField", { pivotShowAs: pivotShowAs }),
|
|
348
|
+
]),
|
|
349
|
+
]),
|
|
350
|
+
]
|
|
351
|
+
: []);
|
|
293
352
|
})
|
|
294
353
|
.filter(function (d) { return d !== null; });
|
|
295
|
-
var styleInfo = (
|
|
354
|
+
var styleInfo = (_q = pivot.styleInfo) !== null && _q !== void 0 ? _q : {};
|
|
296
355
|
var styleFlag = function (value, fallback) {
|
|
297
356
|
return value === undefined ? fallback : value ? "1" : "0";
|
|
298
357
|
};
|
|
299
|
-
var
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
"@_name": styleInfo.name || "PivotStyleLight16",
|
|
345
|
-
"@_showRowHeaders": styleFlag(styleInfo.showRowHeaders, "1"),
|
|
346
|
-
"@_showColHeaders": styleFlag(styleInfo.showColHeaders, "1"),
|
|
347
|
-
"@_showRowStripes": styleFlag(styleInfo.showRowStripes, "0"),
|
|
348
|
-
"@_showColStripes": styleFlag(styleInfo.showColStripes, "0"),
|
|
349
|
-
"@_showLastColumn": styleFlag(styleInfo.showLastColumn, "1"),
|
|
350
|
-
},
|
|
351
|
-
},
|
|
352
|
-
};
|
|
353
|
-
return xmlBuilder.build(doc);
|
|
358
|
+
var chartFormats = buildChartFormats(pivot);
|
|
359
|
+
return buildDocument(el("pivotTableDefinition", {
|
|
360
|
+
xmlns: "http://schemas.openxmlformats.org/spreadsheetml/2006/main",
|
|
361
|
+
name: (_r = pivot.name) !== null && _r !== void 0 ? _r : "PivotTable".concat(pivot.pivotId),
|
|
362
|
+
cacheId: String(cacheId),
|
|
363
|
+
dataOnRows: "0",
|
|
364
|
+
applyNumberFormats: "0",
|
|
365
|
+
applyBorderFormats: "0",
|
|
366
|
+
applyFontFormats: "0",
|
|
367
|
+
applyPatternFormats: "0",
|
|
368
|
+
applyAlignmentFormats: "0",
|
|
369
|
+
applyWidthHeightFormats: "1",
|
|
370
|
+
dataCaption: "Values",
|
|
371
|
+
updatedVersion: "8",
|
|
372
|
+
minRefreshableVersion: "3",
|
|
373
|
+
showCalcMbrs: "0",
|
|
374
|
+
useAutoFormatting: "1",
|
|
375
|
+
itemPrintTitles: "1",
|
|
376
|
+
createdVersion: "8",
|
|
377
|
+
indent: "0",
|
|
378
|
+
outline: "1",
|
|
379
|
+
outlineData: "1",
|
|
380
|
+
multipleFieldFilters: "0",
|
|
381
|
+
rowGrandTotals: pivot.showRowGrandTotals === false ? "0" : "1",
|
|
382
|
+
colGrandTotals: pivot.showColumnGrandTotals === false ? "0" : "1",
|
|
383
|
+
}, __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([
|
|
384
|
+
el("location", { ref: ref, firstHeaderRow: "1", firstDataRow: "1", firstDataCol: "1" })
|
|
385
|
+
], __read((pivotFields.length
|
|
386
|
+
? [el("pivotFields", { count: String(pivotFields.length) }, pivotFields)]
|
|
387
|
+
: [])), false), __read((rowFieldIndices.length
|
|
388
|
+
? [el("rowFields", { count: String(rowFieldIndices.length) }, axisFields(rowFieldIndices))]
|
|
389
|
+
: [])), false), __read((colFieldIndices.length
|
|
390
|
+
? [el("colFields", { count: String(colFieldIndices.length) }, axisFields(colFieldIndices))]
|
|
391
|
+
: [])), false), __read((dataFields.length
|
|
392
|
+
? [el("dataFields", { count: String(dataFields.length) }, dataFields)]
|
|
393
|
+
: [])), false), __read((chartFormats ? [chartFormats] : [])), false), [
|
|
394
|
+
el("pivotTableStyleInfo", {
|
|
395
|
+
name: styleInfo.name || "PivotStyleLight16",
|
|
396
|
+
showRowHeaders: styleFlag(styleInfo.showRowHeaders, "1"),
|
|
397
|
+
showColHeaders: styleFlag(styleInfo.showColHeaders, "1"),
|
|
398
|
+
showRowStripes: styleFlag(styleInfo.showRowStripes, "0"),
|
|
399
|
+
showColStripes: styleFlag(styleInfo.showColStripes, "0"),
|
|
400
|
+
showLastColumn: styleFlag(styleInfo.showLastColumn, "1"),
|
|
401
|
+
}),
|
|
402
|
+
], false)));
|
|
354
403
|
};
|
|
355
404
|
/**
|
|
356
405
|
* Build the pivotTable.xml.rels file (links the pivot to its
|
|
@@ -361,16 +410,11 @@ export var buildPivotTableXml = function (pivot, cacheId, fieldIndices) {
|
|
|
361
410
|
* "../pivotCache/pivotCacheDefinition1.xml"
|
|
362
411
|
*/
|
|
363
412
|
export var buildPivotTableRelsXml = function (cacheRid, cacheTarget) {
|
|
364
|
-
|
|
365
|
-
"
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
"@_Target": cacheTarget,
|
|
372
|
-
},
|
|
373
|
-
},
|
|
374
|
-
};
|
|
375
|
-
return xmlBuilder.build(doc);
|
|
413
|
+
return buildDocument(el("Relationships", { xmlns: "http://schemas.openxmlformats.org/package/2006/relationships" }, [
|
|
414
|
+
el("Relationship", {
|
|
415
|
+
Id: cacheRid,
|
|
416
|
+
Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition",
|
|
417
|
+
Target: cacheTarget,
|
|
418
|
+
}),
|
|
419
|
+
]));
|
|
376
420
|
};
|