ooxml-core 1.19.2 → 1.20.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/README.md +12 -1
- package/dist/{PptxHandler-2V4PQL6O.mjs → PptxHandler-FYD7IYXT.mjs} +2 -2
- package/dist/PptxHandler-SITN3K3F.mjs +4 -0
- package/dist/{PptxHandler-6TNIQ7S5.cjs → PptxHandler-TEKISCJO.cjs} +3 -3
- package/dist/{PresentationBuilder-HQ6C7L4V.mjs → PresentationBuilder-EYI6Z2JP.mjs} +2 -2
- package/dist/{PresentationBuilder-G7MPEGXJ.mjs → PresentationBuilder-IMB4DVRN.mjs} +2 -2
- package/dist/{PresentationBuilder-RM52LCVN.cjs → PresentationBuilder-NCKASKXU.cjs} +5 -5
- package/dist/automation/index.cjs +257 -30
- package/dist/automation/index.mjs +256 -31
- package/dist/automation/xlsx-read.d.ts +56 -0
- package/dist/automation/xlsx-read.d.ts.map +1 -0
- package/dist/automation/xlsx.d.ts +105 -4
- package/dist/automation/xlsx.d.ts.map +1 -1
- package/dist/{chunk-M6GDBVQ7.mjs → chunk-GQYQQ3GA.mjs} +1 -1
- package/dist/{chunk-SLNQNVQM.mjs → chunk-LEV2SVMK.mjs} +1 -1
- package/dist/{chunk-JUABSM7C.mjs → chunk-LVM3IZJ2.mjs} +1 -1
- package/dist/{chunk-TJPUAUWL.mjs → chunk-MN27HKHM.mjs} +8 -194
- package/dist/{chunk-4FTUAD2B.mjs → chunk-MNXKRXFB.mjs} +715 -200
- package/dist/{chunk-R5FIHHGB.cjs → chunk-NXKATFM5.cjs} +1598 -1204
- package/dist/{chunk-ZJ2OKIJN.mjs → chunk-WXY5EDGT.mjs} +592 -198
- package/dist/index.cjs +25 -0
- package/dist/index.mjs +25 -0
- package/dist/pptx/automation/index.cjs +887 -453
- package/dist/pptx/automation/index.d.ts +2 -2
- package/dist/pptx/automation/index.mjs +5 -5
- package/dist/pptx/chunks/{index-Bqm-jFG-.d.ts → index-CgFX0T7b.d.ts} +7573 -7508
- package/dist/pptx/chunks/index-CgFX0T7b.d.ts.map +1 -0
- package/dist/pptx/chunks/{index-B9x557hr.d.ts → index-qwVYoFn6.d.ts} +2 -2
- package/dist/pptx/chunks/{index-B9x557hr.d.ts.map → index-qwVYoFn6.d.ts.map} +1 -1
- package/dist/pptx/cli/index.cjs +654 -221
- package/dist/pptx/cli/index.mjs +4 -4
- package/dist/pptx/converter/index.d.ts +1 -1
- package/dist/pptx/converter/index.mjs +2 -2
- package/dist/pptx/editor/render/find-replace.cjs +14 -14
- package/dist/pptx/editor/render/find-replace.d.ts +1 -1
- package/dist/pptx/editor/render/find-replace.mjs +1 -1
- package/dist/pptx/editor/render/slide-operations.cjs +8 -8
- package/dist/pptx/editor/render/slide-operations.mjs +2 -2
- package/dist/pptx/index.cjs +991 -619
- package/dist/pptx/index.d.ts +3 -3
- package/dist/pptx/index.mjs +5 -5
- package/dist/visio/index.cjs +61 -7
- package/dist/visio/index.mjs +61 -7
- package/dist/visio/ui/contract.d.ts +2 -1
- package/dist/visio/ui/contract.d.ts.map +1 -1
- package/dist/visio/ui/index.cjs +62 -7
- package/dist/visio/ui/index.mjs +62 -7
- package/dist/xlsx/edit/dimensions.d.ts.map +1 -1
- package/dist/xlsx/edit/history-rows.d.ts +7 -0
- package/dist/xlsx/edit/history-rows.d.ts.map +1 -0
- package/dist/xlsx/edit/history.d.ts +11 -1
- package/dist/xlsx/edit/history.d.ts.map +1 -1
- package/dist/xlsx/edit/outline.d.ts.map +1 -1
- package/dist/xlsx/edit/row-autofit.d.ts.map +1 -1
- package/dist/xlsx/index.cjs +90 -16
- package/dist/xlsx/index.mjs +90 -16
- package/dist/xlsx/load/index.cjs +61 -7
- package/dist/xlsx/load/index.mjs +61 -7
- package/dist/xlsx/numfmt/format.d.ts +8 -0
- package/dist/xlsx/numfmt/format.d.ts.map +1 -1
- package/dist/xlsx/read/sheet-data-source.d.ts.map +1 -1
- package/dist/xlsx/ui/index.cjs +138 -16
- package/dist/xlsx/ui/index.d.ts +1 -0
- package/dist/xlsx/ui/index.d.ts.map +1 -1
- package/dist/xlsx/ui/index.mjs +138 -17
- package/dist/xlsx/ui/selection-format.d.ts +13 -0
- package/dist/xlsx/ui/selection-format.d.ts.map +1 -0
- package/dist/xml/index.cjs +25 -0
- package/dist/xml/index.mjs +25 -0
- package/dist/xml/lite.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/PptxHandler-HSPKEP5E.mjs +0 -4
- package/dist/pptx/chunks/index-Bqm-jFG-.d.ts.map +0 -1
- /package/dist/{chunk-NYTR4UZ5.cjs → chunk-3IENHIFD.cjs} +0 -0
- /package/dist/{chunk-XTSHZGSM.mjs → chunk-CC5UNZOO.mjs} +0 -0
package/README.md
CHANGED
|
@@ -99,11 +99,22 @@ import { PptxHandler } from 'ooxml-core/pptx';
|
|
|
99
99
|
|
|
100
100
|
const { handler, data, createSlide } = await PptxHandler.create({ title: 'Quarterly Review' });
|
|
101
101
|
data.slides.push(
|
|
102
|
-
createSlide(
|
|
102
|
+
createSlide('Title Slide')
|
|
103
|
+
.addPlaceholder('ctrTitle', 'Quarterly Review')
|
|
104
|
+
.addPlaceholder('subTitle', 'Results and next steps')
|
|
105
|
+
.build(),
|
|
103
106
|
);
|
|
104
107
|
const bytes = await handler.save(data.slides); // a valid .pptx
|
|
105
108
|
```
|
|
106
109
|
|
|
110
|
+
`addPlaceholder(type, text, { idx? })` binds text to the selected layout and inherits
|
|
111
|
+
its position, size, and text styles. Use `{ idx: 1 }` or `{ idx: 2 }` for repeated
|
|
112
|
+
content slots in Two Content. Optional `x`, `y`, `width`, and `height` override the
|
|
113
|
+
inherited frame. If a template's master frame needs a compatible-role fallback,
|
|
114
|
+
only the newly created placeholder receives an explicit frame. A missing slot
|
|
115
|
+
requires a complete explicit frame; otherwise the builder throws. Standalone `new SlideBuilder(number, layoutPath, name, handler)`
|
|
116
|
+
requires a loaded handler for this method. Use `addText` for a free text box.
|
|
117
|
+
|
|
107
118
|
**Work at the package level**
|
|
108
119
|
|
|
109
120
|
```ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { PptxHandler } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { PptxHandler } from './chunk-MNXKRXFB.mjs';
|
|
2
|
+
import './chunk-LEV2SVMK.mjs';
|
|
3
3
|
import './chunk-M4XLF4R7.mjs';
|
|
4
4
|
import './chunk-3GXV5MPC.mjs';
|
|
5
5
|
import './chunk-54S5A5PZ.mjs';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var chunkNXKATFM5_cjs = require('./chunk-NXKATFM5.cjs');
|
|
4
|
+
require('./chunk-3IENHIFD.cjs');
|
|
5
5
|
require('./chunk-XZPZHXV4.cjs');
|
|
6
6
|
require('./chunk-5W2QL4SB.cjs');
|
|
7
7
|
|
|
@@ -9,5 +9,5 @@ require('./chunk-5W2QL4SB.cjs');
|
|
|
9
9
|
|
|
10
10
|
Object.defineProperty(exports, "PptxHandler", {
|
|
11
11
|
enumerable: true,
|
|
12
|
-
get: function () { return
|
|
12
|
+
get: function () { return chunkNXKATFM5_cjs.PptxHandler; }
|
|
13
13
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { PresentationBuilder, STANDARD_LAYOUTS, buildBlankPresentationArchive } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { PresentationBuilder, STANDARD_LAYOUTS, buildBlankPresentationArchive } from './chunk-MNXKRXFB.mjs';
|
|
2
|
+
import './chunk-LEV2SVMK.mjs';
|
|
3
3
|
import './chunk-M4XLF4R7.mjs';
|
|
4
4
|
import './chunk-3GXV5MPC.mjs';
|
|
5
5
|
import './chunk-54S5A5PZ.mjs';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { PresentationBuilder, STANDARD_LAYOUTS, buildBlankPresentationArchive } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { PresentationBuilder, STANDARD_LAYOUTS, buildBlankPresentationArchive } from './chunk-WXY5EDGT.mjs';
|
|
2
|
+
import './chunk-CC5UNZOO.mjs';
|
|
3
3
|
import './chunk-GXHKNSZX.mjs';
|
|
4
4
|
import './chunk-CA7KCNL3.mjs';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var chunkNXKATFM5_cjs = require('./chunk-NXKATFM5.cjs');
|
|
4
|
+
require('./chunk-3IENHIFD.cjs');
|
|
5
5
|
require('./chunk-XZPZHXV4.cjs');
|
|
6
6
|
require('./chunk-5W2QL4SB.cjs');
|
|
7
7
|
|
|
@@ -9,13 +9,13 @@ require('./chunk-5W2QL4SB.cjs');
|
|
|
9
9
|
|
|
10
10
|
Object.defineProperty(exports, "PresentationBuilder", {
|
|
11
11
|
enumerable: true,
|
|
12
|
-
get: function () { return
|
|
12
|
+
get: function () { return chunkNXKATFM5_cjs.PresentationBuilder; }
|
|
13
13
|
});
|
|
14
14
|
Object.defineProperty(exports, "STANDARD_LAYOUTS", {
|
|
15
15
|
enumerable: true,
|
|
16
|
-
get: function () { return
|
|
16
|
+
get: function () { return chunkNXKATFM5_cjs.STANDARD_LAYOUTS; }
|
|
17
17
|
});
|
|
18
18
|
Object.defineProperty(exports, "buildBlankPresentationArchive", {
|
|
19
19
|
enumerable: true,
|
|
20
|
-
get: function () { return
|
|
20
|
+
get: function () { return chunkNXKATFM5_cjs.buildBlankPresentationArchive; }
|
|
21
21
|
});
|
|
@@ -242,6 +242,12 @@ function parseLiteFragment(xml, container, namespaces) {
|
|
|
242
242
|
}
|
|
243
243
|
if (lt < 0) break;
|
|
244
244
|
const next = source2.charCodeAt(lt + 1);
|
|
245
|
+
if (next === 33) {
|
|
246
|
+
const after = skipCommentOrCdata(source2, lt, top);
|
|
247
|
+
if (after < 0) return void 0;
|
|
248
|
+
pos = after;
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
245
251
|
if (next === 47) {
|
|
246
252
|
const gt = source2.indexOf(">", lt);
|
|
247
253
|
if (gt < 0 || stack2.length < 2 || source2.slice(lt + 2, gt).trimEnd() !== top.tagName)
|
|
@@ -262,6 +268,25 @@ function parseLiteFragment(xml, container, namespaces) {
|
|
|
262
268
|
}
|
|
263
269
|
return stack2.length === 1 ? root : void 0;
|
|
264
270
|
}
|
|
271
|
+
var DECLARATIONS = /<!DOCTYPE|<!ENTITY/i;
|
|
272
|
+
function skipCommentOrCdata(source2, lt, parent) {
|
|
273
|
+
if (source2.startsWith("<!--", lt)) {
|
|
274
|
+
const end = source2.indexOf("-->", lt + 4);
|
|
275
|
+
if (end < 0) return -1;
|
|
276
|
+
const body = source2.slice(lt + 4, end);
|
|
277
|
+
if (body.includes("--") || body.endsWith("-") || DECLARATIONS.test(body)) return -1;
|
|
278
|
+
return end + 3;
|
|
279
|
+
}
|
|
280
|
+
if (source2.startsWith("<![CDATA[", lt)) {
|
|
281
|
+
const end = source2.indexOf("]]>", lt + 9);
|
|
282
|
+
if (end < 0) return -1;
|
|
283
|
+
const text8 = source2.slice(lt + 9, end);
|
|
284
|
+
if (DECLARATIONS.test(text8)) return -1;
|
|
285
|
+
parent.childNodes.push(text8);
|
|
286
|
+
return end + 3;
|
|
287
|
+
}
|
|
288
|
+
return -1;
|
|
289
|
+
}
|
|
265
290
|
function startTag(source2, from, namespaces) {
|
|
266
291
|
const n = source2.length;
|
|
267
292
|
let i2 = from;
|
|
@@ -23722,6 +23747,37 @@ function formatValue(value3, format5, options2 = {}) {
|
|
|
23722
23747
|
function isDateFormat(format5) {
|
|
23723
23748
|
return compileFormat(format5).isDate;
|
|
23724
23749
|
}
|
|
23750
|
+
var DAY_PARTS = /* @__PURE__ */ new Set([
|
|
23751
|
+
"y",
|
|
23752
|
+
"yyyy",
|
|
23753
|
+
"e",
|
|
23754
|
+
"g",
|
|
23755
|
+
"b",
|
|
23756
|
+
"bbbb",
|
|
23757
|
+
"m",
|
|
23758
|
+
"mm",
|
|
23759
|
+
"mmm",
|
|
23760
|
+
"mmmm",
|
|
23761
|
+
"mmmmm",
|
|
23762
|
+
"d",
|
|
23763
|
+
"dd",
|
|
23764
|
+
"ddd",
|
|
23765
|
+
"dddd"
|
|
23766
|
+
]);
|
|
23767
|
+
function dateTimeParts(format5, value3) {
|
|
23768
|
+
const section3 = chooseSection(compileFormat(format5), value3)?.section;
|
|
23769
|
+
if (section3?.kind !== "date") return void 0;
|
|
23770
|
+
let date2 = false;
|
|
23771
|
+
let time = false;
|
|
23772
|
+
for (const token of section3.tokens) {
|
|
23773
|
+
if (token.t === "elapsed") return void 0;
|
|
23774
|
+
if (token.t === "date") {
|
|
23775
|
+
if (DAY_PARTS.has(token.part)) date2 = true;
|
|
23776
|
+
else time = true;
|
|
23777
|
+
} else if (token.t === "ampm" || token.t === "subsec") time = true;
|
|
23778
|
+
}
|
|
23779
|
+
return date2 || time ? { date: date2, time } : void 0;
|
|
23780
|
+
}
|
|
23725
23781
|
|
|
23726
23782
|
// xlsx/numfmt/input-date.ts
|
|
23727
23783
|
var MONTH_NAMES = [
|
|
@@ -29675,21 +29731,50 @@ function rootNamespaces(xml) {
|
|
|
29675
29731
|
for (const match2 of (root[2] ?? "").matchAll(DECLARATION3)) out[match2[1] ?? ""] = match2[3] ?? "";
|
|
29676
29732
|
return out;
|
|
29677
29733
|
}
|
|
29734
|
+
var SPECIAL = /<[!?]/g;
|
|
29735
|
+
var SECTIONS = [
|
|
29736
|
+
["<!--", "-->"],
|
|
29737
|
+
["<![CDATA[", "]]>"],
|
|
29738
|
+
["<?", "?>"]
|
|
29739
|
+
];
|
|
29740
|
+
function blankComments(xml) {
|
|
29741
|
+
if (!xml.includes("<!--") && !xml.includes("<![CDATA[")) return xml;
|
|
29742
|
+
const pieces = [];
|
|
29743
|
+
let copied = 0;
|
|
29744
|
+
SPECIAL.lastIndex = 0;
|
|
29745
|
+
for (let match2 = SPECIAL.exec(xml); match2; match2 = SPECIAL.exec(xml)) {
|
|
29746
|
+
const at2 = match2.index;
|
|
29747
|
+
const section3 = SECTIONS.find(([open2]) => xml.startsWith(open2, at2));
|
|
29748
|
+
if (!section3) return void 0;
|
|
29749
|
+
const [open, close4] = section3;
|
|
29750
|
+
const end = xml.indexOf(close4, at2 + open.length);
|
|
29751
|
+
if (end < 0) return void 0;
|
|
29752
|
+
const after = end + close4.length;
|
|
29753
|
+
if (open !== "<?") {
|
|
29754
|
+
pieces.push(xml.slice(copied, at2), " ".repeat(after - at2));
|
|
29755
|
+
copied = after;
|
|
29756
|
+
}
|
|
29757
|
+
SPECIAL.lastIndex = after;
|
|
29758
|
+
}
|
|
29759
|
+
pieces.push(xml.slice(copied));
|
|
29760
|
+
return pieces.join("");
|
|
29761
|
+
}
|
|
29678
29762
|
function splitSheetData(xml) {
|
|
29679
|
-
|
|
29680
|
-
|
|
29681
|
-
const
|
|
29763
|
+
const plain5 = blankComments(xml);
|
|
29764
|
+
if (plain5 === void 0) return void 0;
|
|
29765
|
+
const namespaces = rootNamespaces(plain5);
|
|
29766
|
+
const open = OPEN.exec(plain5);
|
|
29682
29767
|
if (!namespaces || !open) return void 0;
|
|
29683
29768
|
const prefix3 = (open[1] ?? "").slice(0, -1);
|
|
29684
29769
|
const ns = namespaces[prefix3];
|
|
29685
29770
|
if (prefix3 && ns === void 0) return void 0;
|
|
29686
29771
|
const tagName2 = `${open[1] ?? ""}sheetData`;
|
|
29687
|
-
const openEnd =
|
|
29772
|
+
const openEnd = plain5.indexOf(">", open.index);
|
|
29688
29773
|
if (openEnd < 0) return void 0;
|
|
29689
|
-
const attributes =
|
|
29774
|
+
const attributes = plain5.slice(open.index + tagName2.length + 1, openEnd);
|
|
29690
29775
|
if (attributes.trimEnd().endsWith("/") || attributes.includes("xmlns")) return void 0;
|
|
29691
|
-
const close4 =
|
|
29692
|
-
if (close4 < 0 || OPEN.test(
|
|
29776
|
+
const close4 = plain5.indexOf(`</${tagName2}`, openEnd);
|
|
29777
|
+
if (close4 < 0 || OPEN.test(plain5.slice(openEnd))) return void 0;
|
|
29693
29778
|
const container = new LiteElement(tagName2, "sheetData", ns || null);
|
|
29694
29779
|
const data = parseLiteFragment(xml.slice(openEnd + 1, close4), container, namespaces);
|
|
29695
29780
|
if (!data) return void 0;
|
|
@@ -49030,7 +49115,7 @@ function setColumnWidth(ctx, s, cols, width, measure2) {
|
|
|
49030
49115
|
ctx.run(
|
|
49031
49116
|
"Column width",
|
|
49032
49117
|
"view",
|
|
49033
|
-
[{ kind: "
|
|
49118
|
+
[{ kind: "parts", sheet: s, parts: ["columns"] }],
|
|
49034
49119
|
() => editColumns(sheet, cols, (info) => {
|
|
49035
49120
|
const next = widths.get(info.min);
|
|
49036
49121
|
if (next === void 0) {
|
|
@@ -49065,7 +49150,7 @@ function setRowHeight(ctx, s, rows, height) {
|
|
|
49065
49150
|
ctx.run(
|
|
49066
49151
|
"Row height",
|
|
49067
49152
|
"view",
|
|
49068
|
-
[{ kind: "
|
|
49153
|
+
[{ kind: "rowInfo", sheet: s, rows }],
|
|
49069
49154
|
() => {
|
|
49070
49155
|
for (const row3 of rows) {
|
|
49071
49156
|
const info = { ...sheet.rowInfo.get(row3) };
|
|
@@ -49095,7 +49180,9 @@ function setHidden(ctx, s, axis, indices, hidden) {
|
|
|
49095
49180
|
ctx.run(
|
|
49096
49181
|
`${hidden ? "Hide" : "Unhide"} ${noun}`,
|
|
49097
49182
|
"view",
|
|
49098
|
-
[
|
|
49183
|
+
[
|
|
49184
|
+
axis === "col" ? { kind: "parts", sheet: s, parts: ["columns"] } : { kind: "rowInfo", sheet: s, rows: indices }
|
|
49185
|
+
],
|
|
49099
49186
|
() => {
|
|
49100
49187
|
if (axis === "col") {
|
|
49101
49188
|
editColumns(sheet, indices, (info) => {
|
|
@@ -49689,6 +49776,19 @@ function shiftEdgeCells(sheet, spec2, phase) {
|
|
|
49689
49776
|
return out;
|
|
49690
49777
|
}
|
|
49691
49778
|
|
|
49779
|
+
// xlsx/edit/history-rows.ts
|
|
49780
|
+
function captureRowInfo(sheet, rows) {
|
|
49781
|
+
return [...new Set(rows)].map((row3) => {
|
|
49782
|
+
const info = sheet.rowInfo.get(row3);
|
|
49783
|
+
return [row3, info && structuredClone(info)];
|
|
49784
|
+
});
|
|
49785
|
+
}
|
|
49786
|
+
function restoreRowInfo(sheet, entries) {
|
|
49787
|
+
for (const [row3, info] of entries)
|
|
49788
|
+
if (info) sheet.rowInfo.set(row3, structuredClone(info));
|
|
49789
|
+
else sheet.rowInfo.delete(row3);
|
|
49790
|
+
}
|
|
49791
|
+
|
|
49692
49792
|
// xlsx/edit/history.ts
|
|
49693
49793
|
var SETTING_KEYS = [
|
|
49694
49794
|
"structureLocked",
|
|
@@ -49773,6 +49873,8 @@ function captureScope(workbook, scope, before) {
|
|
|
49773
49873
|
if (!sheet) throw new RangeError(`No sheet at index ${scope.sheet}`);
|
|
49774
49874
|
if (scope.kind === "sheet")
|
|
49775
49875
|
return { kind: "sheet", sheet: scope.sheet, data: structuredClone(sheet) };
|
|
49876
|
+
if (scope.kind === "rowInfo")
|
|
49877
|
+
return { kind: "rowInfo", sheet: scope.sheet, rows: captureRowInfo(sheet, scope.rows) };
|
|
49776
49878
|
if (scope.kind === "parts") {
|
|
49777
49879
|
const data = {};
|
|
49778
49880
|
for (const part of scope.parts) if (sheet[part] !== void 0) data[part] = sheet[part];
|
|
@@ -49824,6 +49926,7 @@ function restoreSnapshot(workbook, snapshot) {
|
|
|
49824
49926
|
}
|
|
49825
49927
|
const sheet = workbook.sheets[snapshot.sheet];
|
|
49826
49928
|
if (!sheet) return;
|
|
49929
|
+
if (snapshot.kind === "rowInfo") return restoreRowInfo(sheet, snapshot.rows);
|
|
49827
49930
|
if (snapshot.kind === "parts") {
|
|
49828
49931
|
const target2 = sheet;
|
|
49829
49932
|
const data = structuredClone(snapshot.data);
|
|
@@ -52433,12 +52536,13 @@ function span2(from, to) {
|
|
|
52433
52536
|
}
|
|
52434
52537
|
function outlineRows(ctx, s, from, to, delta) {
|
|
52435
52538
|
const sheet = sheetAt(ctx.workbook, s);
|
|
52539
|
+
const rows = span2(from, to);
|
|
52436
52540
|
ctx.run(
|
|
52437
52541
|
delta > 0 ? "Group rows" : "Ungroup rows",
|
|
52438
52542
|
"structure",
|
|
52439
|
-
[{ kind: "
|
|
52543
|
+
[{ kind: "rowInfo", sheet: s, rows }],
|
|
52440
52544
|
() => {
|
|
52441
|
-
for (const row3 of
|
|
52545
|
+
for (const row3 of rows) {
|
|
52442
52546
|
const info = { ...sheet.rowInfo.get(row3) };
|
|
52443
52547
|
const level2 = nextLevel(info.outlineLevel, delta);
|
|
52444
52548
|
if (level2) info.outlineLevel = level2;
|
|
@@ -52458,7 +52562,7 @@ function outlineColumns(ctx, s, from, to, delta) {
|
|
|
52458
52562
|
ctx.run(
|
|
52459
52563
|
delta > 0 ? "Group columns" : "Ungroup columns",
|
|
52460
52564
|
"structure",
|
|
52461
|
-
[{ kind: "
|
|
52565
|
+
[{ kind: "parts", sheet: s, parts: ["columns"] }],
|
|
52462
52566
|
() => editColumns(sheet, span2(from, to), (info) => {
|
|
52463
52567
|
const level2 = nextLevel(info.outlineLevel, delta);
|
|
52464
52568
|
if (level2) info.outlineLevel = level2;
|
|
@@ -52481,7 +52585,7 @@ function setDefaultColumnWidth(ctx, s, width) {
|
|
|
52481
52585
|
ctx.run(
|
|
52482
52586
|
"Standard width",
|
|
52483
52587
|
"format",
|
|
52484
|
-
[{ kind: "
|
|
52588
|
+
[{ kind: "parts", sheet: s, parts: ["defaultColWidth"] }],
|
|
52485
52589
|
() => {
|
|
52486
52590
|
if (width === void 0) Reflect.deleteProperty(sheet, "defaultColWidth");
|
|
52487
52591
|
else sheet.defaultColWidth = width;
|
|
@@ -55055,10 +55159,11 @@ function autoGrowRows(ctx, s, rows, measure2 = approximateMeasure) {
|
|
|
55055
55159
|
updates.push([row3, next]);
|
|
55056
55160
|
}
|
|
55057
55161
|
if (!updates.length) return [];
|
|
55162
|
+
const changed = updates.map(([row3]) => row3);
|
|
55058
55163
|
ctx.run(
|
|
55059
55164
|
"Row height",
|
|
55060
55165
|
"view",
|
|
55061
|
-
[{ kind: "
|
|
55166
|
+
[{ kind: "rowInfo", sheet: s, rows: changed }],
|
|
55062
55167
|
() => {
|
|
55063
55168
|
for (const [row3, height] of updates) {
|
|
55064
55169
|
const info = { ...sheet.rowInfo.get(row3) };
|
|
@@ -55070,7 +55175,7 @@ function autoGrowRows(ctx, s, rows, measure2 = approximateMeasure) {
|
|
|
55070
55175
|
},
|
|
55071
55176
|
{ sheet: s, structural: true }
|
|
55072
55177
|
);
|
|
55073
|
-
return
|
|
55178
|
+
return changed;
|
|
55074
55179
|
}
|
|
55075
55180
|
var MAX_REFIT_ROWS = 1e4;
|
|
55076
55181
|
function rowsToRefit(sheet, ranges) {
|
|
@@ -55826,11 +55931,84 @@ function createEditSession(workbook, options2 = {}) {
|
|
|
55826
55931
|
};
|
|
55827
55932
|
}
|
|
55828
55933
|
|
|
55934
|
+
// automation/xlsx-read.ts
|
|
55935
|
+
var INSPECT_LIST_LIMIT = 500;
|
|
55936
|
+
function sheetSummaries(workbook) {
|
|
55937
|
+
return workbook.sheets.map((sheet, index3) => {
|
|
55938
|
+
const used = usedRange(sheet);
|
|
55939
|
+
const omitted2 = sheet.tables.length - INSPECT_LIST_LIMIT;
|
|
55940
|
+
return {
|
|
55941
|
+
index: index3,
|
|
55942
|
+
name: sheet.name,
|
|
55943
|
+
state: sheet.state,
|
|
55944
|
+
usedRange: used ? formatRange(used) : null,
|
|
55945
|
+
rows: used ? used.end.row - used.start.row + 1 : 0,
|
|
55946
|
+
columns: used ? used.end.col - used.start.col + 1 : 0,
|
|
55947
|
+
tables: sheet.tables.slice(0, INSPECT_LIST_LIMIT).map((table4) => ({
|
|
55948
|
+
name: table4.displayName,
|
|
55949
|
+
range: formatRange(table4.range),
|
|
55950
|
+
headerRow: table4.headerRow,
|
|
55951
|
+
totalsRow: table4.totalsRow
|
|
55952
|
+
})),
|
|
55953
|
+
...omitted2 > 0 ? { tablesOmitted: omitted2 } : {}
|
|
55954
|
+
};
|
|
55955
|
+
});
|
|
55956
|
+
}
|
|
55957
|
+
function definedNameList(workbook) {
|
|
55958
|
+
const visible = workbook.definedNames.filter((name3) => !name3.hidden);
|
|
55959
|
+
const definedNames = visible.slice(0, INSPECT_LIST_LIMIT).map((name3) => ({
|
|
55960
|
+
name: name3.name,
|
|
55961
|
+
refersTo: name3.formula,
|
|
55962
|
+
...name3.localSheet === void 0 ? {} : { sheetIndex: name3.localSheet }
|
|
55963
|
+
}));
|
|
55964
|
+
const omitted2 = visible.length - INSPECT_LIST_LIMIT;
|
|
55965
|
+
return omitted2 > 0 ? { definedNames, definedNamesOmitted: omitted2 } : { definedNames };
|
|
55966
|
+
}
|
|
55967
|
+
function isoOf(serial, date1904, shows2) {
|
|
55968
|
+
if (!(serial >= 0) || serial > MAX_DATE_SERIAL + 1) return void 0;
|
|
55969
|
+
if (!date1904 && serial >= 60 && serial < 61) return void 0;
|
|
55970
|
+
const date2 = serialToDate(serial, date1904);
|
|
55971
|
+
if (date2.getUTCFullYear() > 9999) return void 0;
|
|
55972
|
+
const iso = date2.toISOString();
|
|
55973
|
+
const time = iso.slice(11, iso.endsWith(".000Z") ? 19 : 23);
|
|
55974
|
+
if (serial < 1 && (!date1904 || !shows2.date)) return time;
|
|
55975
|
+
return Number.isInteger(serial) && !shows2.time ? iso.slice(0, 10) : `${iso.slice(0, 10)}T${time}`;
|
|
55976
|
+
}
|
|
55977
|
+
function cellView2(workbook, cell) {
|
|
55978
|
+
const value3 = cell?.value ?? null;
|
|
55979
|
+
const text8 = displayText(workbook, cell);
|
|
55980
|
+
const view = cell?.formula ? { value: value3, formula: cell.formula, text: text8 } : { value: value3, text: text8 };
|
|
55981
|
+
const numFmt = styleAt(workbook, cell?.styleId).numFmt;
|
|
55982
|
+
if (numFmt === "General") return view;
|
|
55983
|
+
view.numberFormat = numFmt;
|
|
55984
|
+
const parts = typeof value3 === "number" ? dateTimeParts(numFmt, value3) : void 0;
|
|
55985
|
+
if (parts && typeof value3 === "number") {
|
|
55986
|
+
const iso = isoOf(value3, workbook.date1904, parts);
|
|
55987
|
+
if (iso) view.iso = iso;
|
|
55988
|
+
}
|
|
55989
|
+
return view;
|
|
55990
|
+
}
|
|
55991
|
+
var READ_LIMIT = 1e4;
|
|
55992
|
+
function rangeCells(workbook, sheet, range2) {
|
|
55993
|
+
const count2 = (range2.end.row - range2.start.row + 1) * (range2.end.col - range2.start.col + 1);
|
|
55994
|
+
if (count2 > READ_LIMIT) throw new Error(`Read at most ${READ_LIMIT} cells per request`);
|
|
55995
|
+
const cells3 = [];
|
|
55996
|
+
for (let row3 = range2.start.row; row3 <= range2.end.row; row3++)
|
|
55997
|
+
for (let col = range2.start.col; col <= range2.end.col; col++)
|
|
55998
|
+
cells3.push({
|
|
55999
|
+
address: formatAddress({ row: row3, col }),
|
|
56000
|
+
...cellView2(workbook, getCell(sheet, row3, col))
|
|
56001
|
+
});
|
|
56002
|
+
return cells3;
|
|
56003
|
+
}
|
|
56004
|
+
|
|
55829
56005
|
// automation/xlsx.ts
|
|
55830
56006
|
async function inspectXlsx(bytes) {
|
|
55831
56007
|
const workbook = await loadXlsx(bytes);
|
|
55832
56008
|
return {
|
|
55833
|
-
sheets: workbook
|
|
56009
|
+
sheets: sheetSummaries(workbook),
|
|
56010
|
+
activeSheet: workbook.activeSheet,
|
|
56011
|
+
...definedNameList(workbook),
|
|
55834
56012
|
properties: workbook.properties,
|
|
55835
56013
|
warnings: workbook.warnings
|
|
55836
56014
|
};
|
|
@@ -55853,19 +56031,7 @@ async function readXlsxRange(bytes, sheetIndex2, reference2) {
|
|
|
55853
56031
|
const range2 = parseRange(reference2);
|
|
55854
56032
|
if (!sheet || !range2 || range2.end.col > MAX_COL || range2.end.row > MAX_ROW)
|
|
55855
56033
|
throw new Error("Invalid sheet or range");
|
|
55856
|
-
|
|
55857
|
-
if (count2 > 1e4) throw new Error("Read at most 10000 cells per request");
|
|
55858
|
-
const cells3 = [];
|
|
55859
|
-
for (let row3 = range2.start.row; row3 <= range2.end.row; row3++)
|
|
55860
|
-
for (let col = range2.start.col; col <= range2.end.col; col++) {
|
|
55861
|
-
const cell = getCell(sheet, row3, col);
|
|
55862
|
-
cells3.push({
|
|
55863
|
-
address: formatAddress({ row: row3, col }),
|
|
55864
|
-
value: cell?.value ?? null,
|
|
55865
|
-
formula: cell?.formula
|
|
55866
|
-
});
|
|
55867
|
-
}
|
|
55868
|
-
return { cells: cells3, warnings: workbook.warnings };
|
|
56034
|
+
return { cells: rangeCells(workbook, sheet, range2), warnings: workbook.warnings };
|
|
55869
56035
|
}
|
|
55870
56036
|
async function setXlsxCells(bytes, sheetIndex2, cells3) {
|
|
55871
56037
|
const workbook = await loadXlsx(bytes);
|
|
@@ -55908,6 +56074,65 @@ async function readXlsxFilledCells(bytes, { maxCells = 5e3 } = {}) {
|
|
|
55908
56074
|
warnings: workbook.warnings
|
|
55909
56075
|
};
|
|
55910
56076
|
}
|
|
56077
|
+
async function findXlsxCells(bytes, text8, options2 = {}) {
|
|
56078
|
+
if (!text8) throw new Error("The search text is empty");
|
|
56079
|
+
const max = options2.maxResults ?? 100;
|
|
56080
|
+
if (!Number.isSafeInteger(max) || max < 1 || max > 1e3)
|
|
56081
|
+
throw new Error("Return between 1 and 1000 matches per request");
|
|
56082
|
+
const workbook = await loadXlsx(bytes);
|
|
56083
|
+
const query = { text: text8, lookIn: options2.lookIn ?? "formulas" };
|
|
56084
|
+
const { sheetIndex: sheetIndex2 } = options2;
|
|
56085
|
+
if (sheetIndex2 !== void 0) {
|
|
56086
|
+
if (!Number.isSafeInteger(sheetIndex2) || !workbook.sheets[sheetIndex2])
|
|
56087
|
+
throw new Error("Invalid sheet");
|
|
56088
|
+
query.sheet = sheetIndex2;
|
|
56089
|
+
}
|
|
56090
|
+
if (options2.range !== void 0) {
|
|
56091
|
+
const range2 = parseRange(options2.range);
|
|
56092
|
+
if (sheetIndex2 === void 0) throw new Error("A range needs a sheetIndex");
|
|
56093
|
+
if (!range2) throw new Error("Invalid range");
|
|
56094
|
+
query.range = range2;
|
|
56095
|
+
}
|
|
56096
|
+
if (options2.matchCase) query.matchCase = true;
|
|
56097
|
+
if (options2.wholeCell) query.wholeCell = true;
|
|
56098
|
+
if (options2.wildcards === false) query.wildcards = false;
|
|
56099
|
+
const found = findAll(workbook, query);
|
|
56100
|
+
const matches2 = found.slice(0, max).map((match2) => {
|
|
56101
|
+
const sheet = workbook.sheets[match2.sheet];
|
|
56102
|
+
return {
|
|
56103
|
+
sheetIndex: match2.sheet,
|
|
56104
|
+
sheet: sheet?.name ?? "",
|
|
56105
|
+
address: formatAddress(match2),
|
|
56106
|
+
...cellView2(workbook, sheet && getCell(sheet, match2.row, match2.col))
|
|
56107
|
+
};
|
|
56108
|
+
});
|
|
56109
|
+
return {
|
|
56110
|
+
matches: matches2,
|
|
56111
|
+
total: found.length,
|
|
56112
|
+
truncated: found.length > max,
|
|
56113
|
+
warnings: workbook.warnings
|
|
56114
|
+
};
|
|
56115
|
+
}
|
|
56116
|
+
async function readXlsxTable(bytes, name3) {
|
|
56117
|
+
const workbook = await loadXlsx(bytes);
|
|
56118
|
+
const wanted = name3.toLowerCase();
|
|
56119
|
+
for (const [sheetIndex2, sheet] of workbook.sheets.entries()) {
|
|
56120
|
+
const table4 = sheet.tables.find((t) => t.displayName.toLowerCase() === wanted);
|
|
56121
|
+
if (!table4) continue;
|
|
56122
|
+
return {
|
|
56123
|
+
sheetIndex: sheetIndex2,
|
|
56124
|
+
sheet: sheet.name,
|
|
56125
|
+
name: table4.displayName,
|
|
56126
|
+
range: formatRange(table4.range),
|
|
56127
|
+
headerRow: table4.headerRow,
|
|
56128
|
+
totalsRow: table4.totalsRow,
|
|
56129
|
+
columns: table4.columns.map((column2) => column2.name),
|
|
56130
|
+
cells: rangeCells(workbook, sheet, table4.range),
|
|
56131
|
+
warnings: workbook.warnings
|
|
56132
|
+
};
|
|
56133
|
+
}
|
|
56134
|
+
throw new Error(`No table named ${name3}`);
|
|
56135
|
+
}
|
|
55911
56136
|
|
|
55912
56137
|
// visio/package-common.ts
|
|
55913
56138
|
var VisioPackageError = class extends Error {
|
|
@@ -82501,11 +82726,13 @@ exports.createDocxFromOutline = createDocxFromOutline;
|
|
|
82501
82726
|
exports.createXlsx = createXlsx;
|
|
82502
82727
|
exports.createXlsxFromSheets = createXlsxFromSheets;
|
|
82503
82728
|
exports.editVisio = editVsdx;
|
|
82729
|
+
exports.findXlsxCells = findXlsxCells;
|
|
82504
82730
|
exports.inspectDocx = inspectDocx;
|
|
82505
82731
|
exports.inspectVisio = inspectVisio;
|
|
82506
82732
|
exports.inspectXlsx = inspectXlsx;
|
|
82507
82733
|
exports.readXlsxFilledCells = readXlsxFilledCells;
|
|
82508
82734
|
exports.readXlsxRange = readXlsxRange;
|
|
82735
|
+
exports.readXlsxTable = readXlsxTable;
|
|
82509
82736
|
exports.setDocxRunText = setDocxRunText;
|
|
82510
82737
|
exports.setXlsxCells = setXlsxCells;
|
|
82511
82738
|
exports.suggestDocxRunText = suggestDocxRunText;
|