@simplysm/excel 13.0.0-beta.5 → 13.0.0-beta.50
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 +15 -0
- package/dist/excel-cell.d.ts.map +1 -0
- package/dist/excel-cell.js +3 -3
- package/dist/excel-cell.js.map +0 -1
- package/dist/excel-col.d.ts.map +1 -0
- package/dist/excel-col.js +1 -1
- package/dist/excel-col.js.map +0 -1
- package/dist/excel-row.d.ts.map +1 -0
- package/dist/excel-row.js +1 -1
- package/dist/excel-row.js.map +0 -1
- package/dist/excel-workbook.d.ts.map +1 -0
- package/dist/excel-workbook.js +7 -7
- package/dist/excel-workbook.js.map +1 -2
- package/dist/excel-worksheet.d.ts.map +1 -0
- package/dist/excel-worksheet.js +4 -4
- package/dist/excel-worksheet.js.map +0 -1
- package/dist/excel-wrapper.d.ts.map +1 -0
- package/dist/excel-wrapper.js +1 -1
- package/dist/excel-wrapper.js.map +0 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -8
- package/dist/index.js.map +0 -1
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js.map +0 -1
- package/dist/utils/excel-utils.d.ts.map +1 -0
- package/dist/utils/excel-utils.js.map +0 -1
- package/dist/utils/zip-cache.d.ts.map +1 -0
- package/dist/utils/zip-cache.js +8 -8
- package/dist/utils/zip-cache.js.map +0 -1
- package/dist/xml/excel-xml-content-type.d.ts.map +1 -0
- package/dist/xml/excel-xml-content-type.js.map +0 -1
- package/dist/xml/excel-xml-drawing.d.ts.map +1 -0
- package/dist/xml/excel-xml-drawing.js.map +0 -1
- package/dist/xml/excel-xml-relationship.d.ts.map +1 -0
- package/dist/xml/excel-xml-relationship.js.map +0 -1
- package/dist/xml/excel-xml-shared-string.d.ts.map +1 -0
- package/dist/xml/excel-xml-shared-string.js.map +0 -1
- package/dist/xml/excel-xml-style.d.ts.map +1 -0
- package/dist/xml/excel-xml-style.js.map +0 -1
- package/dist/xml/excel-xml-unknown.d.ts.map +1 -0
- package/dist/xml/excel-xml-unknown.js.map +0 -1
- package/dist/xml/excel-xml-workbook.d.ts.map +1 -0
- package/dist/xml/excel-xml-workbook.js.map +0 -1
- package/dist/xml/excel-xml-worksheet.d.ts.map +1 -0
- package/dist/xml/excel-xml-worksheet.js +1 -1
- package/dist/xml/excel-xml-worksheet.js.map +0 -1
- package/package.json +8 -4
- package/src/excel-workbook.ts +1 -1
- package/.cache/typecheck-browser.tsbuildinfo +0 -1
- package/.cache/typecheck-node.tsbuildinfo +0 -1
- package/.cache/typecheck-tests-browser.tsbuildinfo +0 -1
- package/.cache/typecheck-tests-node.tsbuildinfo +0 -1
- package/dist/core-common/src/common.types.d.ts +0 -74
- package/dist/core-common/src/common.types.d.ts.map +0 -1
- package/dist/core-common/src/env.d.ts +0 -6
- package/dist/core-common/src/env.d.ts.map +0 -1
- package/dist/core-common/src/errors/argument-error.d.ts +0 -25
- package/dist/core-common/src/errors/argument-error.d.ts.map +0 -1
- package/dist/core-common/src/errors/not-implemented-error.d.ts +0 -29
- package/dist/core-common/src/errors/not-implemented-error.d.ts.map +0 -1
- package/dist/core-common/src/errors/sd-error.d.ts +0 -27
- package/dist/core-common/src/errors/sd-error.d.ts.map +0 -1
- package/dist/core-common/src/errors/timeout-error.d.ts +0 -31
- package/dist/core-common/src/errors/timeout-error.d.ts.map +0 -1
- package/dist/core-common/src/extensions/arr-ext.d.ts +0 -15
- package/dist/core-common/src/extensions/arr-ext.d.ts.map +0 -1
- package/dist/core-common/src/extensions/arr-ext.helpers.d.ts +0 -19
- package/dist/core-common/src/extensions/arr-ext.helpers.d.ts.map +0 -1
- package/dist/core-common/src/extensions/arr-ext.types.d.ts +0 -215
- package/dist/core-common/src/extensions/arr-ext.types.d.ts.map +0 -1
- package/dist/core-common/src/extensions/map-ext.d.ts +0 -57
- package/dist/core-common/src/extensions/map-ext.d.ts.map +0 -1
- package/dist/core-common/src/extensions/set-ext.d.ts +0 -36
- package/dist/core-common/src/extensions/set-ext.d.ts.map +0 -1
- package/dist/core-common/src/features/debounce-queue.d.ts +0 -53
- package/dist/core-common/src/features/debounce-queue.d.ts.map +0 -1
- package/dist/core-common/src/features/event-emitter.d.ts +0 -66
- package/dist/core-common/src/features/event-emitter.d.ts.map +0 -1
- package/dist/core-common/src/features/serial-queue.d.ts +0 -47
- package/dist/core-common/src/features/serial-queue.d.ts.map +0 -1
- package/dist/core-common/src/index.d.ts +0 -32
- package/dist/core-common/src/index.d.ts.map +0 -1
- package/dist/core-common/src/types/date-only.d.ts +0 -152
- package/dist/core-common/src/types/date-only.d.ts.map +0 -1
- package/dist/core-common/src/types/date-time.d.ts +0 -96
- package/dist/core-common/src/types/date-time.d.ts.map +0 -1
- package/dist/core-common/src/types/lazy-gc-map.d.ts +0 -80
- package/dist/core-common/src/types/lazy-gc-map.d.ts.map +0 -1
- package/dist/core-common/src/types/time.d.ts +0 -68
- package/dist/core-common/src/types/time.d.ts.map +0 -1
- package/dist/core-common/src/types/uuid.d.ts +0 -35
- package/dist/core-common/src/types/uuid.d.ts.map +0 -1
- package/dist/core-common/src/utils/bytes.d.ts +0 -51
- package/dist/core-common/src/utils/bytes.d.ts.map +0 -1
- package/dist/core-common/src/utils/date-format.d.ts +0 -90
- package/dist/core-common/src/utils/date-format.d.ts.map +0 -1
- package/dist/core-common/src/utils/json.d.ts +0 -34
- package/dist/core-common/src/utils/json.d.ts.map +0 -1
- package/dist/core-common/src/utils/num.d.ts +0 -60
- package/dist/core-common/src/utils/num.d.ts.map +0 -1
- package/dist/core-common/src/utils/obj.d.ts +0 -258
- package/dist/core-common/src/utils/obj.d.ts.map +0 -1
- package/dist/core-common/src/utils/path.d.ts +0 -23
- package/dist/core-common/src/utils/path.d.ts.map +0 -1
- package/dist/core-common/src/utils/primitive.d.ts +0 -18
- package/dist/core-common/src/utils/primitive.d.ts.map +0 -1
- package/dist/core-common/src/utils/str.d.ts +0 -103
- package/dist/core-common/src/utils/str.d.ts.map +0 -1
- package/dist/core-common/src/utils/template-strings.d.ts +0 -84
- package/dist/core-common/src/utils/template-strings.d.ts.map +0 -1
- package/dist/core-common/src/utils/transferable.d.ts +0 -47
- package/dist/core-common/src/utils/transferable.d.ts.map +0 -1
- package/dist/core-common/src/utils/wait.d.ts +0 -19
- package/dist/core-common/src/utils/wait.d.ts.map +0 -1
- package/dist/core-common/src/utils/xml.d.ts +0 -36
- package/dist/core-common/src/utils/xml.d.ts.map +0 -1
- package/dist/core-common/src/zip/sd-zip.d.ts +0 -80
- package/dist/core-common/src/zip/sd-zip.d.ts.map +0 -1
- package/dist/excel/src/excel-cell.d.ts.map +0 -1
- package/dist/excel/src/excel-col.d.ts.map +0 -1
- package/dist/excel/src/excel-row.d.ts.map +0 -1
- package/dist/excel/src/excel-workbook.d.ts.map +0 -1
- package/dist/excel/src/excel-worksheet.d.ts.map +0 -1
- package/dist/excel/src/excel-wrapper.d.ts.map +0 -1
- package/dist/excel/src/index.d.ts.map +0 -1
- package/dist/excel/src/types.d.ts.map +0 -1
- package/dist/excel/src/utils/excel-utils.d.ts.map +0 -1
- package/dist/excel/src/utils/zip-cache.d.ts.map +0 -1
- package/dist/excel/src/xml/excel-xml-content-type.d.ts.map +0 -1
- package/dist/excel/src/xml/excel-xml-drawing.d.ts.map +0 -1
- package/dist/excel/src/xml/excel-xml-relationship.d.ts.map +0 -1
- package/dist/excel/src/xml/excel-xml-shared-string.d.ts.map +0 -1
- package/dist/excel/src/xml/excel-xml-style.d.ts.map +0 -1
- package/dist/excel/src/xml/excel-xml-unknown.d.ts.map +0 -1
- package/dist/excel/src/xml/excel-xml-workbook.d.ts.map +0 -1
- package/dist/excel/src/xml/excel-xml-worksheet.d.ts.map +0 -1
- package/tests/excel-cell.spec.ts +0 -407
- package/tests/excel-col.spec.ts +0 -112
- package/tests/excel-row.spec.ts +0 -71
- package/tests/excel-workbook.spec.ts +0 -166
- package/tests/excel-worksheet.spec.ts +0 -389
- package/tests/excel-wrapper.spec.ts +0 -275
- package/tests/fixtures/logo.png +0 -0
- package/tests/image-insert.spec.ts +0 -188
- package/tests/utils/excel-utils.spec.ts +0 -240
- /package/dist/{excel/src/excel-cell.d.ts → excel-cell.d.ts} +0 -0
- /package/dist/{excel/src/excel-col.d.ts → excel-col.d.ts} +0 -0
- /package/dist/{excel/src/excel-row.d.ts → excel-row.d.ts} +0 -0
- /package/dist/{excel/src/excel-workbook.d.ts → excel-workbook.d.ts} +0 -0
- /package/dist/{excel/src/excel-worksheet.d.ts → excel-worksheet.d.ts} +0 -0
- /package/dist/{excel/src/excel-wrapper.d.ts → excel-wrapper.d.ts} +0 -0
- /package/dist/{excel/src/index.d.ts → index.d.ts} +0 -0
- /package/dist/{excel/src/types.d.ts → types.d.ts} +0 -0
- /package/dist/{excel/src/utils → utils}/excel-utils.d.ts +0 -0
- /package/dist/{excel/src/utils → utils}/zip-cache.d.ts +0 -0
- /package/dist/{excel/src/xml → xml}/excel-xml-content-type.d.ts +0 -0
- /package/dist/{excel/src/xml → xml}/excel-xml-drawing.d.ts +0 -0
- /package/dist/{excel/src/xml → xml}/excel-xml-relationship.d.ts +0 -0
- /package/dist/{excel/src/xml → xml}/excel-xml-shared-string.d.ts +0 -0
- /package/dist/{excel/src/xml → xml}/excel-xml-style.d.ts +0 -0
- /package/dist/{excel/src/xml → xml}/excel-xml-unknown.d.ts +0 -0
- /package/dist/{excel/src/xml → xml}/excel-xml-workbook.d.ts +0 -0
- /package/dist/{excel/src/xml → xml}/excel-xml-worksheet.d.ts +0 -0
package/tests/excel-col.spec.ts
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { ExcelWorkbook } from "../src/excel-workbook";
|
|
3
|
-
|
|
4
|
-
describe("ExcelCol", () => {
|
|
5
|
-
describe("cell()", () => {
|
|
6
|
-
it("행 인덱스에 해당하는 셀을 반환한다", async () => {
|
|
7
|
-
const wb = new ExcelWorkbook();
|
|
8
|
-
const ws = await wb.createWorksheet("Test");
|
|
9
|
-
|
|
10
|
-
const col = ws.col(0);
|
|
11
|
-
const cell = col.cell(0);
|
|
12
|
-
|
|
13
|
-
await cell.setVal("Hello");
|
|
14
|
-
expect(await cell.getVal()).toBe("Hello");
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it("동일 인덱스에 대해 같은 인스턴스를 반환한다 (캐싱)", async () => {
|
|
18
|
-
const wb = new ExcelWorkbook();
|
|
19
|
-
const ws = await wb.createWorksheet("Test");
|
|
20
|
-
|
|
21
|
-
const col = ws.col(0);
|
|
22
|
-
const cell1 = col.cell(0);
|
|
23
|
-
const cell2 = col.cell(0);
|
|
24
|
-
|
|
25
|
-
expect(cell1).toBe(cell2);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it("다른 인덱스에 대해 다른 인스턴스를 반환한다", async () => {
|
|
29
|
-
const wb = new ExcelWorkbook();
|
|
30
|
-
const ws = await wb.createWorksheet("Test");
|
|
31
|
-
|
|
32
|
-
const col = ws.col(0);
|
|
33
|
-
const cell1 = col.cell(0);
|
|
34
|
-
const cell2 = col.cell(1);
|
|
35
|
-
|
|
36
|
-
expect(cell1).not.toBe(cell2);
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
describe("getCells()", () => {
|
|
41
|
-
it("범위 내 모든 셀을 반환한다", async () => {
|
|
42
|
-
const wb = new ExcelWorkbook();
|
|
43
|
-
const ws = await wb.createWorksheet("Test");
|
|
44
|
-
|
|
45
|
-
// 데이터 설정으로 범위 지정
|
|
46
|
-
await ws.cell(0, 0).setVal("A1");
|
|
47
|
-
await ws.cell(1, 0).setVal("A2");
|
|
48
|
-
await ws.cell(2, 0).setVal("A3");
|
|
49
|
-
|
|
50
|
-
const col = ws.col(0);
|
|
51
|
-
const cells = await col.getCells();
|
|
52
|
-
|
|
53
|
-
expect(cells.length).toBeGreaterThanOrEqual(3);
|
|
54
|
-
expect(await cells[0].getVal()).toBe("A1");
|
|
55
|
-
expect(await cells[1].getVal()).toBe("A2");
|
|
56
|
-
expect(await cells[2].getVal()).toBe("A3");
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it("빈 워크시트에서 기본 범위(0,0)에 해당하는 셀을 반환한다", async () => {
|
|
60
|
-
const wb = new ExcelWorkbook();
|
|
61
|
-
const ws = await wb.createWorksheet("Test");
|
|
62
|
-
|
|
63
|
-
const col = ws.col(0);
|
|
64
|
-
const cells = await col.getCells();
|
|
65
|
-
|
|
66
|
-
// 빈 워크시트의 기본 범위는 (0,0)-(0,0)이므로 하나의 셀 반환
|
|
67
|
-
expect(cells.length).toBe(1);
|
|
68
|
-
expect(await cells[0].getVal()).toBeUndefined();
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
describe("setWidth()", () => {
|
|
73
|
-
it("열 너비를 설정할 수 있다", async () => {
|
|
74
|
-
const wb = new ExcelWorkbook();
|
|
75
|
-
const ws = await wb.createWorksheet("Test");
|
|
76
|
-
|
|
77
|
-
// 데이터 추가 후 너비 설정
|
|
78
|
-
await ws.cell(0, 0).setVal("Test");
|
|
79
|
-
await ws.col(0).setWidth(20);
|
|
80
|
-
|
|
81
|
-
// 라운드트립으로 설정 확인
|
|
82
|
-
const bytes = await wb.getBytes();
|
|
83
|
-
const wb2 = new ExcelWorkbook(bytes);
|
|
84
|
-
const ws2 = await wb2.getWorksheet(0);
|
|
85
|
-
|
|
86
|
-
// 값이 유지되는지 확인 (너비는 직접 확인하기 어려우므로 에러 없이 동작하는지만 확인)
|
|
87
|
-
expect(await ws2.cell(0, 0).getVal()).toBe("Test");
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it("여러 열에 다른 너비를 설정할 수 있다", async () => {
|
|
91
|
-
const wb = new ExcelWorkbook();
|
|
92
|
-
const ws = await wb.createWorksheet("Test");
|
|
93
|
-
|
|
94
|
-
await ws.cell(0, 0).setVal("A");
|
|
95
|
-
await ws.cell(0, 1).setVal("B");
|
|
96
|
-
await ws.cell(0, 2).setVal("C");
|
|
97
|
-
|
|
98
|
-
await ws.col(0).setWidth(10);
|
|
99
|
-
await ws.col(1).setWidth(20);
|
|
100
|
-
await ws.col(2).setWidth(30);
|
|
101
|
-
|
|
102
|
-
// 에러 없이 라운드트립 가능
|
|
103
|
-
const bytes = await wb.getBytes();
|
|
104
|
-
const wb2 = new ExcelWorkbook(bytes);
|
|
105
|
-
const ws2 = await wb2.getWorksheet(0);
|
|
106
|
-
|
|
107
|
-
expect(await ws2.cell(0, 0).getVal()).toBe("A");
|
|
108
|
-
expect(await ws2.cell(0, 1).getVal()).toBe("B");
|
|
109
|
-
expect(await ws2.cell(0, 2).getVal()).toBe("C");
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
});
|
package/tests/excel-row.spec.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { ExcelWorkbook } from "../src/excel-workbook";
|
|
3
|
-
|
|
4
|
-
describe("ExcelRow", () => {
|
|
5
|
-
describe("cell()", () => {
|
|
6
|
-
it("열 인덱스에 해당하는 셀을 반환한다", async () => {
|
|
7
|
-
const wb = new ExcelWorkbook();
|
|
8
|
-
const ws = await wb.createWorksheet("Test");
|
|
9
|
-
|
|
10
|
-
const row = ws.row(0);
|
|
11
|
-
const cell = row.cell(0);
|
|
12
|
-
|
|
13
|
-
await cell.setVal("Hello");
|
|
14
|
-
expect(await cell.getVal()).toBe("Hello");
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it("동일 인덱스에 대해 같은 인스턴스를 반환한다 (캐싱)", async () => {
|
|
18
|
-
const wb = new ExcelWorkbook();
|
|
19
|
-
const ws = await wb.createWorksheet("Test");
|
|
20
|
-
|
|
21
|
-
const row = ws.row(0);
|
|
22
|
-
const cell1 = row.cell(0);
|
|
23
|
-
const cell2 = row.cell(0);
|
|
24
|
-
|
|
25
|
-
expect(cell1).toBe(cell2);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it("다른 인덱스에 대해 다른 인스턴스를 반환한다", async () => {
|
|
29
|
-
const wb = new ExcelWorkbook();
|
|
30
|
-
const ws = await wb.createWorksheet("Test");
|
|
31
|
-
|
|
32
|
-
const row = ws.row(0);
|
|
33
|
-
const cell1 = row.cell(0);
|
|
34
|
-
const cell2 = row.cell(1);
|
|
35
|
-
|
|
36
|
-
expect(cell1).not.toBe(cell2);
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
describe("getCells()", () => {
|
|
41
|
-
it("범위 내 모든 셀을 반환한다", async () => {
|
|
42
|
-
const wb = new ExcelWorkbook();
|
|
43
|
-
const ws = await wb.createWorksheet("Test");
|
|
44
|
-
|
|
45
|
-
// 데이터 설정으로 범위 지정
|
|
46
|
-
await ws.cell(0, 0).setVal("A1");
|
|
47
|
-
await ws.cell(0, 1).setVal("B1");
|
|
48
|
-
await ws.cell(0, 2).setVal("C1");
|
|
49
|
-
|
|
50
|
-
const row = ws.row(0);
|
|
51
|
-
const cells = await row.getCells();
|
|
52
|
-
|
|
53
|
-
expect(cells.length).toBeGreaterThanOrEqual(3);
|
|
54
|
-
expect(await cells[0].getVal()).toBe("A1");
|
|
55
|
-
expect(await cells[1].getVal()).toBe("B1");
|
|
56
|
-
expect(await cells[2].getVal()).toBe("C1");
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it("빈 워크시트에서 기본 범위(0,0)에 해당하는 셀을 반환한다", async () => {
|
|
60
|
-
const wb = new ExcelWorkbook();
|
|
61
|
-
const ws = await wb.createWorksheet("Test");
|
|
62
|
-
|
|
63
|
-
const row = ws.row(0);
|
|
64
|
-
const cells = await row.getCells();
|
|
65
|
-
|
|
66
|
-
// 빈 워크시트의 기본 범위는 (0,0)-(0,0)이므로 하나의 셀 반환
|
|
67
|
-
expect(cells.length).toBe(1);
|
|
68
|
-
expect(await cells[0].getVal()).toBeUndefined();
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
});
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { ExcelWorkbook } from "../src/excel-workbook";
|
|
3
|
-
import type { Bytes } from "@simplysm/core-common";
|
|
4
|
-
|
|
5
|
-
describe("ExcelWorkbook", () => {
|
|
6
|
-
describe("빈 워크북 생성", () => {
|
|
7
|
-
it("새 워크북을 생성할 수 있다", () => {
|
|
8
|
-
const wb = new ExcelWorkbook();
|
|
9
|
-
expect(wb).toBeDefined();
|
|
10
|
-
expect(wb.zipCache).toBeDefined();
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it("워크시트를 생성할 수 있다", async () => {
|
|
14
|
-
const wb = new ExcelWorkbook();
|
|
15
|
-
const ws = await wb.createWorksheet("TestSheet");
|
|
16
|
-
|
|
17
|
-
expect(ws).toBeDefined();
|
|
18
|
-
const name = await ws.getName();
|
|
19
|
-
expect(name).toBe("TestSheet");
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("여러 워크시트를 생성할 수 있다", async () => {
|
|
23
|
-
const wb = new ExcelWorkbook();
|
|
24
|
-
await wb.createWorksheet("Sheet1");
|
|
25
|
-
await wb.createWorksheet("Sheet2");
|
|
26
|
-
await wb.createWorksheet("Sheet3");
|
|
27
|
-
|
|
28
|
-
const names = await wb.getWorksheetNames();
|
|
29
|
-
expect(names).toEqual(["Sheet1", "Sheet2", "Sheet3"]);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
describe("워크시트 접근", () => {
|
|
34
|
-
it("인덱스로 워크시트를 가져올 수 있다", async () => {
|
|
35
|
-
const wb = new ExcelWorkbook();
|
|
36
|
-
await wb.createWorksheet("First");
|
|
37
|
-
await wb.createWorksheet("Second");
|
|
38
|
-
|
|
39
|
-
const ws = await wb.getWorksheet(1);
|
|
40
|
-
const name = await ws.getName();
|
|
41
|
-
expect(name).toBe("Second");
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it("이름으로 워크시트를 가져올 수 있다", async () => {
|
|
45
|
-
const wb = new ExcelWorkbook();
|
|
46
|
-
await wb.createWorksheet("MySheet");
|
|
47
|
-
|
|
48
|
-
const ws = await wb.getWorksheet("MySheet");
|
|
49
|
-
const name = await ws.getName();
|
|
50
|
-
expect(name).toBe("MySheet");
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it("존재하지 않는 시트 접근 시 에러", async () => {
|
|
54
|
-
const wb = new ExcelWorkbook();
|
|
55
|
-
await wb.createWorksheet("Sheet1");
|
|
56
|
-
|
|
57
|
-
await expect(wb.getWorksheet("NotExist")).rejects.toThrow();
|
|
58
|
-
await expect(wb.getWorksheet(10)).rejects.toThrow();
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
describe("Bytes/Blob 출력", () => {
|
|
63
|
-
it("Bytes로 출력할 수 있다", async () => {
|
|
64
|
-
const wb = new ExcelWorkbook();
|
|
65
|
-
const ws = await wb.createWorksheet("Test");
|
|
66
|
-
await ws.cell(0, 0).setVal("Hello");
|
|
67
|
-
|
|
68
|
-
const bytes: Bytes = await wb.getBytes();
|
|
69
|
-
expect(bytes).toBeInstanceOf(Uint8Array);
|
|
70
|
-
expect(bytes.length).toBeGreaterThan(0);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it("Blob으로 출력할 수 있다", async () => {
|
|
74
|
-
const wb = new ExcelWorkbook();
|
|
75
|
-
const ws = await wb.createWorksheet("Test");
|
|
76
|
-
await ws.cell(0, 0).setVal("Hello");
|
|
77
|
-
|
|
78
|
-
const blob = await wb.getBlob();
|
|
79
|
-
expect(blob).toBeInstanceOf(Blob);
|
|
80
|
-
expect(blob.type).toBe("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
81
|
-
expect(blob.size).toBeGreaterThan(0);
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
describe("워크북 읽기/쓰기 라운드트립", () => {
|
|
86
|
-
it("Blob으로 워크북을 생성할 수 있다", async () => {
|
|
87
|
-
// 먼저 Bytes로 워크북 생성
|
|
88
|
-
const wb1 = new ExcelWorkbook();
|
|
89
|
-
const ws1 = await wb1.createWorksheet("Test");
|
|
90
|
-
await ws1.cell(0, 0).setVal("BlobTest");
|
|
91
|
-
const bytes = await wb1.getBytes();
|
|
92
|
-
await wb1.close();
|
|
93
|
-
|
|
94
|
-
// Blob으로 변환
|
|
95
|
-
const blob = new Blob([bytes], {
|
|
96
|
-
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
// Blob으로 워크북 읽기
|
|
100
|
-
const wb2 = new ExcelWorkbook(blob);
|
|
101
|
-
const ws2 = await wb2.getWorksheet(0);
|
|
102
|
-
const val = await ws2.cell(0, 0).getVal();
|
|
103
|
-
|
|
104
|
-
expect(val).toBe("BlobTest");
|
|
105
|
-
await wb2.close();
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it("생성한 워크북을 Bytes로 저장 후 다시 읽을 수 있다", async () => {
|
|
109
|
-
// 생성
|
|
110
|
-
const wb1 = new ExcelWorkbook();
|
|
111
|
-
const ws1 = await wb1.createWorksheet("RoundTrip");
|
|
112
|
-
await ws1.cell(0, 0).setVal("TestValue");
|
|
113
|
-
await ws1.cell(0, 1).setVal(12345);
|
|
114
|
-
|
|
115
|
-
// 저장
|
|
116
|
-
const bytes = await wb1.getBytes();
|
|
117
|
-
await wb1.close();
|
|
118
|
-
|
|
119
|
-
// 다시 읽기
|
|
120
|
-
const wb2 = new ExcelWorkbook(bytes);
|
|
121
|
-
const names = await wb2.getWorksheetNames();
|
|
122
|
-
expect(names).toContain("RoundTrip");
|
|
123
|
-
|
|
124
|
-
const ws2 = await wb2.getWorksheet("RoundTrip");
|
|
125
|
-
const val1 = await ws2.cell(0, 0).getVal();
|
|
126
|
-
const val2 = await ws2.cell(0, 1).getVal();
|
|
127
|
-
|
|
128
|
-
expect(val1).toBe("TestValue");
|
|
129
|
-
expect(val2).toBe(12345);
|
|
130
|
-
|
|
131
|
-
await wb2.close();
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
describe("리소스 해제 후 에러", () => {
|
|
136
|
-
it("close() 후 getWorksheetNames() 호출 시 에러", async () => {
|
|
137
|
-
const wb = new ExcelWorkbook();
|
|
138
|
-
await wb.createWorksheet("Test");
|
|
139
|
-
await wb.close();
|
|
140
|
-
|
|
141
|
-
await expect(wb.getWorksheetNames()).rejects.toThrow();
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
it("close() 후 createWorksheet() 호출 시 에러", async () => {
|
|
145
|
-
const wb = new ExcelWorkbook();
|
|
146
|
-
await wb.close();
|
|
147
|
-
|
|
148
|
-
await expect(wb.createWorksheet("New")).rejects.toThrow();
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
it("close() 후 getWorksheet() 호출 시 에러", async () => {
|
|
152
|
-
const wb = new ExcelWorkbook();
|
|
153
|
-
await wb.createWorksheet("Test");
|
|
154
|
-
await wb.close();
|
|
155
|
-
|
|
156
|
-
await expect(wb.getWorksheet(0)).rejects.toThrow();
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
it("close() 후 getBytes() 호출 시 에러", async () => {
|
|
160
|
-
const wb = new ExcelWorkbook();
|
|
161
|
-
await wb.close();
|
|
162
|
-
|
|
163
|
-
await expect(wb.getBytes()).rejects.toThrow();
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
});
|