@simplysm/excel 13.0.76 → 13.0.78
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 +539 -17
- package/dist/excel-cell.d.ts +4 -4
- package/dist/excel-cell.d.ts.map +1 -1
- package/dist/excel-cell.js +9 -10
- package/dist/excel-cell.js.map +1 -1
- package/dist/excel-workbook.d.ts +3 -3
- package/dist/excel-workbook.d.ts.map +1 -1
- package/dist/excel-workbook.js +3 -3
- package/dist/excel-workbook.js.map +1 -1
- package/dist/excel-worksheet.d.ts +1 -1
- package/dist/excel-worksheet.d.ts.map +1 -1
- package/dist/excel-worksheet.js +13 -17
- package/dist/excel-worksheet.js.map +1 -1
- package/dist/excel-wrapper.d.ts +1 -1
- package/dist/excel-wrapper.js +7 -7
- package/dist/excel-wrapper.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/excel-utils.d.ts +5 -5
- package/dist/utils/excel-utils.d.ts.map +1 -1
- package/dist/utils/excel-utils.js +15 -15
- package/dist/utils/excel-utils.js.map +1 -1
- package/dist/utils/zip-cache.js +3 -3
- package/dist/utils/zip-cache.js.map +1 -1
- package/dist/xml/excel-xml-relationship.js +2 -2
- package/dist/xml/excel-xml-relationship.js.map +1 -1
- package/dist/xml/excel-xml-style.js +16 -16
- package/dist/xml/excel-xml-style.js.map +1 -1
- package/dist/xml/excel-xml-workbook.js +6 -6
- package/dist/xml/excel-xml-workbook.js.map +1 -1
- package/dist/xml/excel-xml-worksheet.d.ts +5 -2
- package/dist/xml/excel-xml-worksheet.d.ts.map +1 -1
- package/dist/xml/excel-xml-worksheet.js +38 -20
- package/dist/xml/excel-xml-worksheet.js.map +1 -1
- package/package.json +2 -2
- package/src/excel-cell.ts +10 -11
- package/src/excel-workbook.ts +3 -3
- package/src/excel-worksheet.ts +17 -18
- package/src/excel-wrapper.ts +7 -7
- package/src/types.ts +1 -1
- package/src/utils/excel-utils.ts +15 -15
- package/src/utils/zip-cache.ts +3 -3
- package/src/xml/excel-xml-relationship.ts +2 -2
- package/src/xml/excel-xml-style.ts +16 -16
- package/src/xml/excel-xml-workbook.ts +6 -6
- package/src/xml/excel-xml-worksheet.ts +47 -22
- package/tests/excel-cell.spec.ts +85 -69
- package/tests/excel-col.spec.ts +17 -17
- package/tests/excel-row.spec.ts +13 -13
- package/tests/excel-workbook.spec.ts +26 -26
- package/tests/excel-worksheet.spec.ts +217 -101
- package/tests/excel-wrapper.spec.ts +24 -24
- package/tests/image-insert.spec.ts +5 -5
- package/tests/utils/excel-utils.spec.ts +14 -14
|
@@ -33,7 +33,7 @@ async function loadPngFile(): Promise<Uint8Array> {
|
|
|
33
33
|
describe("ExcelWorksheet.addImage integration", () => {
|
|
34
34
|
it("should write media, drawing, drawing rels, worksheet rel and content types", async () => {
|
|
35
35
|
const wb = new ExcelWorkbook();
|
|
36
|
-
const ws = await wb.
|
|
36
|
+
const ws = await wb.addWorksheet("Sheet1");
|
|
37
37
|
|
|
38
38
|
const bytes = await loadPngFile();
|
|
39
39
|
|
|
@@ -102,14 +102,14 @@ describe("ExcelWorksheet.addImage integration", () => {
|
|
|
102
102
|
expect(drawingElems.some((d: any) => d.$ != null && d.$["r:id"] != null)).toBeTruthy();
|
|
103
103
|
|
|
104
104
|
// Verify buffer creation
|
|
105
|
-
const resultBuffer = await wb.
|
|
105
|
+
const resultBuffer = await wb.toBytes();
|
|
106
106
|
expect(resultBuffer).toBeDefined();
|
|
107
107
|
expect(resultBuffer.length).toBeGreaterThan(0);
|
|
108
108
|
});
|
|
109
109
|
|
|
110
110
|
it("can insert multiple images into the same worksheet", async () => {
|
|
111
111
|
const wb = new ExcelWorkbook();
|
|
112
|
-
const ws = await wb.
|
|
112
|
+
const ws = await wb.addWorksheet("Sheet1");
|
|
113
113
|
|
|
114
114
|
const bytes = await loadPngFile();
|
|
115
115
|
|
|
@@ -170,14 +170,14 @@ describe("ExcelWorksheet.addImage integration", () => {
|
|
|
170
170
|
expect(relsArr.some((r: any) => r.$.Target === "../media/image2.png")).toBeTruthy();
|
|
171
171
|
|
|
172
172
|
// Verify buffer creation
|
|
173
|
-
const resultBuffer = await wb.
|
|
173
|
+
const resultBuffer = await wb.toBytes();
|
|
174
174
|
expect(resultBuffer).toBeDefined();
|
|
175
175
|
expect(resultBuffer.length).toBeGreaterThan(0);
|
|
176
176
|
});
|
|
177
177
|
|
|
178
178
|
it("throws error for unsupported file extensions", async () => {
|
|
179
179
|
const wb = new ExcelWorkbook();
|
|
180
|
-
const ws = await wb.
|
|
180
|
+
const ws = await wb.addWorksheet("Sheet1");
|
|
181
181
|
|
|
182
182
|
await expect(
|
|
183
183
|
ws.addImage({
|
|
@@ -2,7 +2,7 @@ import { describe, expect, it } from "vitest";
|
|
|
2
2
|
import { ExcelUtils } from "../../src/utils/excel-utils";
|
|
3
3
|
|
|
4
4
|
describe("ExcelUtils", () => {
|
|
5
|
-
describe("stringifyColAddr /
|
|
5
|
+
describe("stringifyColAddr / parseColAddr", () => {
|
|
6
6
|
it("converts 26 and above to AA, AB, etc.", () => {
|
|
7
7
|
expect(ExcelUtils.stringifyColAddr(26)).toBe("AA");
|
|
8
8
|
expect(ExcelUtils.stringifyColAddr(27)).toBe("AB");
|
|
@@ -18,13 +18,13 @@ describe("ExcelUtils", () => {
|
|
|
18
18
|
it("handles Excel maximum column index (XFD, 16383)", () => {
|
|
19
19
|
// Excel maximum column is XFD (index 16383, 0-based)
|
|
20
20
|
expect(ExcelUtils.stringifyColAddr(16383)).toBe("XFD");
|
|
21
|
-
expect(ExcelUtils.
|
|
21
|
+
expect(ExcelUtils.parseColAddr("XFD")).toBe(16383);
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
it("round-trip: stringify → parse returns original value", () => {
|
|
25
25
|
for (let i = 0; i < 100; i++) {
|
|
26
26
|
const stringified = ExcelUtils.stringifyColAddr(i);
|
|
27
|
-
const parsed = ExcelUtils.
|
|
27
|
+
const parsed = ExcelUtils.parseColAddr(stringified);
|
|
28
28
|
expect(parsed).toBe(i);
|
|
29
29
|
}
|
|
30
30
|
});
|
|
@@ -35,7 +35,7 @@ describe("ExcelUtils", () => {
|
|
|
35
35
|
});
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
-
describe("stringifyRowAddr /
|
|
38
|
+
describe("stringifyRowAddr / parseRowAddr", () => {
|
|
39
39
|
it("converts 0-based index to 1-based string", () => {
|
|
40
40
|
expect(ExcelUtils.stringifyRowAddr(0)).toBe("1");
|
|
41
41
|
expect(ExcelUtils.stringifyRowAddr(9)).toBe("10");
|
|
@@ -43,13 +43,13 @@ describe("ExcelUtils", () => {
|
|
|
43
43
|
});
|
|
44
44
|
|
|
45
45
|
it("parses 1-based string to 0-based index", () => {
|
|
46
|
-
expect(ExcelUtils.
|
|
47
|
-
expect(ExcelUtils.
|
|
48
|
-
expect(ExcelUtils.
|
|
46
|
+
expect(ExcelUtils.parseRowAddr("A1")).toBe(0);
|
|
47
|
+
expect(ExcelUtils.parseRowAddr("B10")).toBe(9);
|
|
48
|
+
expect(ExcelUtils.parseRowAddr("AA100")).toBe(99);
|
|
49
49
|
});
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
describe("stringifyAddr /
|
|
52
|
+
describe("stringifyAddr / parseCellAddr", () => {
|
|
53
53
|
it("correctly converts cell address", () => {
|
|
54
54
|
expect(ExcelUtils.stringifyAddr({ r: 0, c: 0 })).toBe("A1");
|
|
55
55
|
expect(ExcelUtils.stringifyAddr({ r: 9, c: 1 })).toBe("B10");
|
|
@@ -57,21 +57,21 @@ describe("ExcelUtils", () => {
|
|
|
57
57
|
});
|
|
58
58
|
|
|
59
59
|
it("correctly parses cell address", () => {
|
|
60
|
-
expect(ExcelUtils.
|
|
61
|
-
expect(ExcelUtils.
|
|
62
|
-
expect(ExcelUtils.
|
|
60
|
+
expect(ExcelUtils.parseCellAddr("A1")).toEqual({ r: 0, c: 0 });
|
|
61
|
+
expect(ExcelUtils.parseCellAddr("B10")).toEqual({ r: 9, c: 1 });
|
|
62
|
+
expect(ExcelUtils.parseCellAddr("AA100")).toEqual({ r: 99, c: 26 });
|
|
63
63
|
});
|
|
64
64
|
});
|
|
65
65
|
|
|
66
|
-
describe("
|
|
66
|
+
describe("parseRangeAddr / stringifyRangeAddr", () => {
|
|
67
67
|
it("parses single cell range", () => {
|
|
68
|
-
const range = ExcelUtils.
|
|
68
|
+
const range = ExcelUtils.parseRangeAddr("A1");
|
|
69
69
|
expect(range.s).toEqual({ r: 0, c: 0 });
|
|
70
70
|
expect(range.e).toEqual({ r: 0, c: 0 });
|
|
71
71
|
});
|
|
72
72
|
|
|
73
73
|
it("parses multi-cell range", () => {
|
|
74
|
-
const range = ExcelUtils.
|
|
74
|
+
const range = ExcelUtils.parseRangeAddr("A1:C3");
|
|
75
75
|
expect(range.s).toEqual({ r: 0, c: 0 });
|
|
76
76
|
expect(range.e).toEqual({ r: 2, c: 2 });
|
|
77
77
|
});
|