@simplysm/excel 13.0.0-beta.4 → 13.0.0-beta.44

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.
Files changed (163) hide show
  1. package/README.md +15 -0
  2. package/dist/excel-cell.d.ts.map +1 -0
  3. package/dist/excel-cell.js +3 -3
  4. package/dist/excel-col.d.ts.map +1 -0
  5. package/dist/excel-col.js +1 -1
  6. package/dist/excel-row.d.ts.map +1 -0
  7. package/dist/excel-row.js +1 -1
  8. package/dist/excel-workbook.d.ts.map +1 -0
  9. package/dist/excel-workbook.js +7 -7
  10. package/dist/excel-workbook.js.map +2 -2
  11. package/dist/excel-worksheet.d.ts.map +1 -0
  12. package/dist/excel-worksheet.js +4 -4
  13. package/dist/excel-wrapper.d.ts.map +1 -0
  14. package/dist/excel-wrapper.js +1 -1
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +8 -8
  17. package/dist/types.d.ts.map +1 -0
  18. package/dist/utils/excel-utils.d.ts.map +1 -0
  19. package/dist/utils/zip-cache.d.ts.map +1 -0
  20. package/dist/utils/zip-cache.js +8 -8
  21. package/dist/xml/excel-xml-content-type.d.ts.map +1 -0
  22. package/dist/xml/excel-xml-drawing.d.ts.map +1 -0
  23. package/dist/xml/excel-xml-relationship.d.ts.map +1 -0
  24. package/dist/xml/excel-xml-shared-string.d.ts.map +1 -0
  25. package/dist/xml/excel-xml-style.d.ts.map +1 -0
  26. package/dist/xml/excel-xml-unknown.d.ts.map +1 -0
  27. package/dist/xml/excel-xml-workbook.d.ts.map +1 -0
  28. package/dist/xml/excel-xml-worksheet.d.ts.map +1 -0
  29. package/dist/xml/excel-xml-worksheet.js +1 -1
  30. package/package.json +7 -4
  31. package/.cache/typecheck-browser.tsbuildinfo +0 -1
  32. package/.cache/typecheck-node.tsbuildinfo +0 -1
  33. package/.cache/typecheck-tests-browser.tsbuildinfo +0 -1
  34. package/.cache/typecheck-tests-node.tsbuildinfo +0 -1
  35. package/dist/core-common/src/common.types.d.ts +0 -74
  36. package/dist/core-common/src/common.types.d.ts.map +0 -1
  37. package/dist/core-common/src/env.d.ts +0 -6
  38. package/dist/core-common/src/env.d.ts.map +0 -1
  39. package/dist/core-common/src/errors/argument-error.d.ts +0 -25
  40. package/dist/core-common/src/errors/argument-error.d.ts.map +0 -1
  41. package/dist/core-common/src/errors/not-implemented-error.d.ts +0 -29
  42. package/dist/core-common/src/errors/not-implemented-error.d.ts.map +0 -1
  43. package/dist/core-common/src/errors/sd-error.d.ts +0 -27
  44. package/dist/core-common/src/errors/sd-error.d.ts.map +0 -1
  45. package/dist/core-common/src/errors/timeout-error.d.ts +0 -31
  46. package/dist/core-common/src/errors/timeout-error.d.ts.map +0 -1
  47. package/dist/core-common/src/extensions/arr-ext.d.ts +0 -15
  48. package/dist/core-common/src/extensions/arr-ext.d.ts.map +0 -1
  49. package/dist/core-common/src/extensions/arr-ext.helpers.d.ts +0 -19
  50. package/dist/core-common/src/extensions/arr-ext.helpers.d.ts.map +0 -1
  51. package/dist/core-common/src/extensions/arr-ext.types.d.ts +0 -215
  52. package/dist/core-common/src/extensions/arr-ext.types.d.ts.map +0 -1
  53. package/dist/core-common/src/extensions/map-ext.d.ts +0 -57
  54. package/dist/core-common/src/extensions/map-ext.d.ts.map +0 -1
  55. package/dist/core-common/src/extensions/set-ext.d.ts +0 -36
  56. package/dist/core-common/src/extensions/set-ext.d.ts.map +0 -1
  57. package/dist/core-common/src/features/debounce-queue.d.ts +0 -53
  58. package/dist/core-common/src/features/debounce-queue.d.ts.map +0 -1
  59. package/dist/core-common/src/features/event-emitter.d.ts +0 -66
  60. package/dist/core-common/src/features/event-emitter.d.ts.map +0 -1
  61. package/dist/core-common/src/features/serial-queue.d.ts +0 -47
  62. package/dist/core-common/src/features/serial-queue.d.ts.map +0 -1
  63. package/dist/core-common/src/index.d.ts +0 -32
  64. package/dist/core-common/src/index.d.ts.map +0 -1
  65. package/dist/core-common/src/types/date-only.d.ts +0 -152
  66. package/dist/core-common/src/types/date-only.d.ts.map +0 -1
  67. package/dist/core-common/src/types/date-time.d.ts +0 -96
  68. package/dist/core-common/src/types/date-time.d.ts.map +0 -1
  69. package/dist/core-common/src/types/lazy-gc-map.d.ts +0 -80
  70. package/dist/core-common/src/types/lazy-gc-map.d.ts.map +0 -1
  71. package/dist/core-common/src/types/time.d.ts +0 -68
  72. package/dist/core-common/src/types/time.d.ts.map +0 -1
  73. package/dist/core-common/src/types/uuid.d.ts +0 -35
  74. package/dist/core-common/src/types/uuid.d.ts.map +0 -1
  75. package/dist/core-common/src/utils/bytes.d.ts +0 -51
  76. package/dist/core-common/src/utils/bytes.d.ts.map +0 -1
  77. package/dist/core-common/src/utils/date-format.d.ts +0 -90
  78. package/dist/core-common/src/utils/date-format.d.ts.map +0 -1
  79. package/dist/core-common/src/utils/json.d.ts +0 -34
  80. package/dist/core-common/src/utils/json.d.ts.map +0 -1
  81. package/dist/core-common/src/utils/num.d.ts +0 -60
  82. package/dist/core-common/src/utils/num.d.ts.map +0 -1
  83. package/dist/core-common/src/utils/obj.d.ts +0 -258
  84. package/dist/core-common/src/utils/obj.d.ts.map +0 -1
  85. package/dist/core-common/src/utils/path.d.ts +0 -23
  86. package/dist/core-common/src/utils/path.d.ts.map +0 -1
  87. package/dist/core-common/src/utils/primitive.d.ts +0 -18
  88. package/dist/core-common/src/utils/primitive.d.ts.map +0 -1
  89. package/dist/core-common/src/utils/str.d.ts +0 -103
  90. package/dist/core-common/src/utils/str.d.ts.map +0 -1
  91. package/dist/core-common/src/utils/template-strings.d.ts +0 -84
  92. package/dist/core-common/src/utils/template-strings.d.ts.map +0 -1
  93. package/dist/core-common/src/utils/transferable.d.ts +0 -47
  94. package/dist/core-common/src/utils/transferable.d.ts.map +0 -1
  95. package/dist/core-common/src/utils/wait.d.ts +0 -19
  96. package/dist/core-common/src/utils/wait.d.ts.map +0 -1
  97. package/dist/core-common/src/utils/xml.d.ts +0 -36
  98. package/dist/core-common/src/utils/xml.d.ts.map +0 -1
  99. package/dist/core-common/src/zip/sd-zip.d.ts +0 -80
  100. package/dist/core-common/src/zip/sd-zip.d.ts.map +0 -1
  101. package/dist/excel/src/excel-cell.d.ts.map +0 -1
  102. package/dist/excel/src/excel-col.d.ts.map +0 -1
  103. package/dist/excel/src/excel-row.d.ts.map +0 -1
  104. package/dist/excel/src/excel-workbook.d.ts.map +0 -1
  105. package/dist/excel/src/excel-worksheet.d.ts.map +0 -1
  106. package/dist/excel/src/excel-wrapper.d.ts.map +0 -1
  107. package/dist/excel/src/index.d.ts.map +0 -1
  108. package/dist/excel/src/types.d.ts.map +0 -1
  109. package/dist/excel/src/utils/excel-utils.d.ts.map +0 -1
  110. package/dist/excel/src/utils/zip-cache.d.ts.map +0 -1
  111. package/dist/excel/src/xml/excel-xml-content-type.d.ts.map +0 -1
  112. package/dist/excel/src/xml/excel-xml-drawing.d.ts.map +0 -1
  113. package/dist/excel/src/xml/excel-xml-relationship.d.ts.map +0 -1
  114. package/dist/excel/src/xml/excel-xml-shared-string.d.ts.map +0 -1
  115. package/dist/excel/src/xml/excel-xml-style.d.ts.map +0 -1
  116. package/dist/excel/src/xml/excel-xml-unknown.d.ts.map +0 -1
  117. package/dist/excel/src/xml/excel-xml-workbook.d.ts.map +0 -1
  118. package/dist/excel/src/xml/excel-xml-worksheet.d.ts.map +0 -1
  119. package/src/excel-cell.ts +0 -326
  120. package/src/excel-col.ts +0 -43
  121. package/src/excel-row.ts +0 -37
  122. package/src/excel-workbook.ts +0 -206
  123. package/src/excel-worksheet.ts +0 -380
  124. package/src/excel-wrapper.ts +0 -219
  125. package/src/index.ts +0 -13
  126. package/src/types.ts +0 -396
  127. package/src/utils/excel-utils.ts +0 -201
  128. package/src/utils/zip-cache.ts +0 -103
  129. package/src/xml/excel-xml-content-type.ts +0 -64
  130. package/src/xml/excel-xml-drawing.ts +0 -87
  131. package/src/xml/excel-xml-relationship.ts +0 -86
  132. package/src/xml/excel-xml-shared-string.ts +0 -80
  133. package/src/xml/excel-xml-style.ts +0 -393
  134. package/src/xml/excel-xml-unknown.ts +0 -11
  135. package/src/xml/excel-xml-workbook.ts +0 -112
  136. package/src/xml/excel-xml-worksheet.ts +0 -544
  137. package/tests/excel-cell.spec.ts +0 -407
  138. package/tests/excel-col.spec.ts +0 -112
  139. package/tests/excel-row.spec.ts +0 -71
  140. package/tests/excel-workbook.spec.ts +0 -166
  141. package/tests/excel-worksheet.spec.ts +0 -389
  142. package/tests/excel-wrapper.spec.ts +0 -275
  143. package/tests/fixtures/logo.png +0 -0
  144. package/tests/image-insert.spec.ts +0 -188
  145. package/tests/utils/excel-utils.spec.ts +0 -240
  146. /package/dist/{excel/src/excel-cell.d.ts → excel-cell.d.ts} +0 -0
  147. /package/dist/{excel/src/excel-col.d.ts → excel-col.d.ts} +0 -0
  148. /package/dist/{excel/src/excel-row.d.ts → excel-row.d.ts} +0 -0
  149. /package/dist/{excel/src/excel-workbook.d.ts → excel-workbook.d.ts} +0 -0
  150. /package/dist/{excel/src/excel-worksheet.d.ts → excel-worksheet.d.ts} +0 -0
  151. /package/dist/{excel/src/excel-wrapper.d.ts → excel-wrapper.d.ts} +0 -0
  152. /package/dist/{excel/src/index.d.ts → index.d.ts} +0 -0
  153. /package/dist/{excel/src/types.d.ts → types.d.ts} +0 -0
  154. /package/dist/{excel/src/utils → utils}/excel-utils.d.ts +0 -0
  155. /package/dist/{excel/src/utils → utils}/zip-cache.d.ts +0 -0
  156. /package/dist/{excel/src/xml → xml}/excel-xml-content-type.d.ts +0 -0
  157. /package/dist/{excel/src/xml → xml}/excel-xml-drawing.d.ts +0 -0
  158. /package/dist/{excel/src/xml → xml}/excel-xml-relationship.d.ts +0 -0
  159. /package/dist/{excel/src/xml → xml}/excel-xml-shared-string.d.ts +0 -0
  160. /package/dist/{excel/src/xml → xml}/excel-xml-style.d.ts +0 -0
  161. /package/dist/{excel/src/xml → xml}/excel-xml-unknown.d.ts +0 -0
  162. /package/dist/{excel/src/xml → xml}/excel-xml-workbook.d.ts +0 -0
  163. /package/dist/{excel/src/xml → xml}/excel-xml-worksheet.d.ts +0 -0
@@ -1,407 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { ExcelWorkbook } from "../src/excel-workbook";
3
- import { DateOnly, DateTime, Time } from "@simplysm/core-common";
4
-
5
- describe("ExcelCell", () => {
6
- describe("셀 값 읽기/쓰기 - 기본 타입", () => {
7
- it("string 값을 읽고 쓸 수 있다", async () => {
8
- const wb = new ExcelWorkbook();
9
- const ws = await wb.createWorksheet("Test");
10
-
11
- await ws.cell(0, 0).setVal("Hello World");
12
- const val = await ws.cell(0, 0).getVal();
13
-
14
- expect(val).toBe("Hello World");
15
- });
16
-
17
- it("number 값을 읽고 쓸 수 있다", async () => {
18
- const wb = new ExcelWorkbook();
19
- const ws = await wb.createWorksheet("Test");
20
-
21
- await ws.cell(0, 0).setVal(12345);
22
- await ws.cell(0, 1).setVal(3.14159);
23
- await ws.cell(0, 2).setVal(-100);
24
- await ws.cell(0, 3).setVal(0);
25
-
26
- expect(await ws.cell(0, 0).getVal()).toBe(12345);
27
- expect(await ws.cell(0, 1).getVal()).toBe(3.14159);
28
- expect(await ws.cell(0, 2).getVal()).toBe(-100);
29
- expect(await ws.cell(0, 3).getVal()).toBe(0);
30
- });
31
-
32
- it("boolean 값을 읽고 쓸 수 있다", async () => {
33
- const wb = new ExcelWorkbook();
34
- const ws = await wb.createWorksheet("Test");
35
-
36
- await ws.cell(0, 0).setVal(true);
37
- await ws.cell(0, 1).setVal(false);
38
-
39
- expect(await ws.cell(0, 0).getVal()).toBe(true);
40
- expect(await ws.cell(0, 1).getVal()).toBe(false);
41
- });
42
-
43
- it("undefined 값을 쓰면 셀이 삭제된다", async () => {
44
- const wb = new ExcelWorkbook();
45
- const ws = await wb.createWorksheet("Test");
46
-
47
- await ws.cell(0, 0).setVal("Initial");
48
- expect(await ws.cell(0, 0).getVal()).toBe("Initial");
49
-
50
- await ws.cell(0, 0).setVal(undefined);
51
- expect(await ws.cell(0, 0).getVal()).toBeUndefined();
52
- });
53
-
54
- it("매우 큰 숫자를 처리할 수 있다", async () => {
55
- const wb = new ExcelWorkbook();
56
- const ws = await wb.createWorksheet("Test");
57
-
58
- // MAX_SAFE_INTEGER 이하의 큰 숫자
59
- const bigNumber = Number.MAX_SAFE_INTEGER;
60
- await ws.cell(0, 0).setVal(bigNumber);
61
-
62
- const val = await ws.cell(0, 0).getVal();
63
- expect(val).toBe(bigNumber);
64
- });
65
-
66
- it("매우 작은 소수를 처리할 수 있다", async () => {
67
- const wb = new ExcelWorkbook();
68
- const ws = await wb.createWorksheet("Test");
69
-
70
- // Excel이 처리 가능한 정밀도 범위 내의 작은 소수
71
- const smallDecimal = 0.0001;
72
- await ws.cell(0, 0).setVal(smallDecimal);
73
-
74
- const val = await ws.cell(0, 0).getVal();
75
- expect(val).toBeCloseTo(smallDecimal, 6);
76
- });
77
-
78
- it("지원되지 않는 타입을 설정하면 에러 발생", async () => {
79
- const wb = new ExcelWorkbook();
80
- const ws = await wb.createWorksheet("Test");
81
-
82
- await expect(ws.cell(0, 0).setVal({} as any)).rejects.toThrow("지원되지 않는 타입");
83
-
84
- await expect(ws.cell(0, 1).setVal([] as any)).rejects.toThrow("지원되지 않는 타입");
85
- });
86
- });
87
-
88
- describe("셀 값 읽기/쓰기 - 날짜/시간 타입", () => {
89
- it("DateOnly 값을 읽고 쓸 수 있다", async () => {
90
- const wb = new ExcelWorkbook();
91
- const ws = await wb.createWorksheet("Test");
92
-
93
- const date = new DateOnly(2024, 6, 15);
94
- await ws.cell(0, 0).setVal(date);
95
-
96
- const val = await ws.cell(0, 0).getVal();
97
- expect(val).toBeInstanceOf(DateOnly);
98
- expect((val as DateOnly).year).toBe(2024);
99
- expect((val as DateOnly).month).toBe(6);
100
- expect((val as DateOnly).day).toBe(15);
101
- });
102
-
103
- it("DateTime 값을 읽고 쓸 수 있다", async () => {
104
- const wb = new ExcelWorkbook();
105
- const ws = await wb.createWorksheet("Test");
106
-
107
- const dateTime = new DateTime(2024, 6, 15, 14, 30, 45);
108
- await ws.cell(0, 0).setVal(dateTime);
109
-
110
- const val = await ws.cell(0, 0).getVal();
111
- expect(val).toBeInstanceOf(DateTime);
112
- expect((val as DateTime).year).toBe(2024);
113
- expect((val as DateTime).month).toBe(6);
114
- expect((val as DateTime).day).toBe(15);
115
- expect((val as DateTime).hour).toBe(14);
116
- expect((val as DateTime).minute).toBe(30);
117
- expect((val as DateTime).second).toBe(45);
118
- });
119
-
120
- it("Time 값을 읽고 쓸 수 있다", async () => {
121
- const wb = new ExcelWorkbook();
122
- const ws = await wb.createWorksheet("Test");
123
-
124
- const time = new Time(14, 30, 45);
125
- await ws.cell(0, 0).setVal(time);
126
-
127
- const val = await ws.cell(0, 0).getVal();
128
- expect(val).toBeInstanceOf(Time);
129
- expect((val as Time).hour).toBe(14);
130
- expect((val as Time).minute).toBe(30);
131
- expect((val as Time).second).toBe(45);
132
- });
133
-
134
- it("DateOnly 값이 라운드트립 후에도 유지된다", async () => {
135
- const wb = new ExcelWorkbook();
136
- const ws = await wb.createWorksheet("Test");
137
-
138
- const date = new DateOnly(2024, 6, 15);
139
- await ws.cell(0, 0).setVal(date);
140
-
141
- const bytes = await wb.getBytes();
142
- await wb.close();
143
-
144
- const wb2 = new ExcelWorkbook(bytes);
145
- const ws2 = await wb2.getWorksheet(0);
146
-
147
- const val = await ws2.cell(0, 0).getVal();
148
- expect(val).toBeInstanceOf(DateOnly);
149
- expect((val as DateOnly).year).toBe(2024);
150
- expect((val as DateOnly).month).toBe(6);
151
- expect((val as DateOnly).day).toBe(15);
152
- await wb2.close();
153
- });
154
-
155
- it("DateTime 값이 라운드트립 후에도 유지된다", async () => {
156
- const wb = new ExcelWorkbook();
157
- const ws = await wb.createWorksheet("Test");
158
-
159
- const dateTime = new DateTime(2024, 6, 15, 14, 30, 45);
160
- await ws.cell(0, 0).setVal(dateTime);
161
-
162
- const bytes = await wb.getBytes();
163
- await wb.close();
164
-
165
- const wb2 = new ExcelWorkbook(bytes);
166
- const ws2 = await wb2.getWorksheet(0);
167
-
168
- const val = await ws2.cell(0, 0).getVal();
169
- expect(val).toBeInstanceOf(DateTime);
170
- expect((val as DateTime).year).toBe(2024);
171
- expect((val as DateTime).month).toBe(6);
172
- expect((val as DateTime).day).toBe(15);
173
- expect((val as DateTime).hour).toBe(14);
174
- expect((val as DateTime).minute).toBe(30);
175
- expect((val as DateTime).second).toBe(45);
176
- await wb2.close();
177
- });
178
-
179
- it("Time 값이 라운드트립 후에도 유지된다", async () => {
180
- const wb = new ExcelWorkbook();
181
- const ws = await wb.createWorksheet("Test");
182
-
183
- const time = new Time(14, 30, 45);
184
- await ws.cell(0, 0).setVal(time);
185
-
186
- const bytes = await wb.getBytes();
187
- await wb.close();
188
-
189
- const wb2 = new ExcelWorkbook(bytes);
190
- const ws2 = await wb2.getWorksheet(0);
191
-
192
- const val = await ws2.cell(0, 0).getVal();
193
- expect(val).toBeInstanceOf(Time);
194
- expect((val as Time).hour).toBe(14);
195
- expect((val as Time).minute).toBe(30);
196
- expect((val as Time).second).toBe(45);
197
- await wb2.close();
198
- });
199
- });
200
-
201
- describe("수식", () => {
202
- it("수식을 설정할 수 있다", async () => {
203
- const wb = new ExcelWorkbook();
204
- const ws = await wb.createWorksheet("Test");
205
-
206
- await ws.cell(0, 0).setVal(10);
207
- await ws.cell(0, 1).setVal(20);
208
- await ws.cell(0, 2).setFormula("A1+B1");
209
-
210
- // 수식 직접 검증
211
- const formula = await ws.cell(0, 2).getFormula();
212
- expect(formula).toBe("A1+B1");
213
-
214
- // 라운드트립으로도 검증
215
- const buffer = await wb.getBytes();
216
-
217
- const wb2 = new ExcelWorkbook(buffer);
218
- const ws2 = await wb2.getWorksheet(0);
219
- // 수식은 있지만 값은 Excel에서 계산해야 함
220
- expect(ws2).toBeDefined();
221
- });
222
-
223
- it("수식이 라운드트립 후에도 유지된다", async () => {
224
- const wb = new ExcelWorkbook();
225
- const ws = await wb.createWorksheet("Test");
226
-
227
- await ws.cell(0, 0).setVal(10);
228
- await ws.cell(0, 1).setVal(20);
229
- await ws.cell(0, 2).setFormula("SUM(A1:B1)");
230
-
231
- const buffer = await wb.getBytes();
232
- await wb.close();
233
-
234
- const wb2 = new ExcelWorkbook(buffer);
235
- const ws2 = await wb2.getWorksheet(0);
236
-
237
- // 수식 문자열이 저장되었는지 직접 검증
238
- const formula = await ws2.cell(0, 2).getFormula();
239
- expect(formula).toBe("SUM(A1:B1)");
240
- await wb2.close();
241
- });
242
-
243
- it("수식을 undefined로 설정하면 삭제된다", async () => {
244
- const wb = new ExcelWorkbook();
245
- const ws = await wb.createWorksheet("Test");
246
-
247
- await ws.cell(0, 0).setFormula("A1+B1");
248
- await ws.cell(0, 0).setFormula(undefined);
249
-
250
- expect(await ws.cell(0, 0).getVal()).toBeUndefined();
251
- });
252
- });
253
-
254
- describe("셀 병합", () => {
255
- it("셀을 병합할 수 있다", async () => {
256
- const wb = new ExcelWorkbook();
257
- const ws = await wb.createWorksheet("Test");
258
-
259
- await ws.cell(0, 0).setVal("Merged");
260
- await ws.cell(0, 0).merge(2, 3); // 2행 x 3열 병합
261
-
262
- // 라운드트립으로 병합 확인
263
- const buffer = await wb.getBytes();
264
- const wb2 = new ExcelWorkbook(buffer);
265
- const ws2 = await wb2.getWorksheet(0);
266
-
267
- const val = await ws2.cell(0, 0).getVal();
268
- expect(val).toBe("Merged");
269
- });
270
-
271
- it("겹치는 범위로 병합 시도 시 에러 발생", async () => {
272
- const wb = new ExcelWorkbook();
273
- const ws = await wb.createWorksheet("Test");
274
-
275
- await ws.cell(0, 0).merge(2, 2); // A1:B2 병합
276
-
277
- // 겹치는 범위(B2:C3)로 병합 시도
278
- await expect(ws.cell(1, 1).merge(2, 2)).rejects.toThrow("병합 셀이 기존 병합 범위");
279
- });
280
- });
281
-
282
- describe("셀 스타일", () => {
283
- it("배경색을 설정할 수 있다", async () => {
284
- const wb = new ExcelWorkbook();
285
- const ws = await wb.createWorksheet("Test");
286
-
287
- await ws.cell(0, 0).setVal("Colored");
288
- await ws.cell(0, 0).setStyle({ background: "00FF0000" }); // 빨간색
289
-
290
- const styleId = await ws.cell(0, 0).getStyleId();
291
- expect(styleId).toBeDefined();
292
- });
293
-
294
- it("테두리를 설정할 수 있다", async () => {
295
- const wb = new ExcelWorkbook();
296
- const ws = await wb.createWorksheet("Test");
297
-
298
- await ws.cell(0, 0).setVal("Bordered");
299
- await ws.cell(0, 0).setStyle({ border: ["left", "right", "top", "bottom"] });
300
-
301
- const styleId = await ws.cell(0, 0).getStyleId();
302
- expect(styleId).toBeDefined();
303
- });
304
-
305
- it("정렬을 설정할 수 있다", async () => {
306
- const wb = new ExcelWorkbook();
307
- const ws = await wb.createWorksheet("Test");
308
-
309
- await ws.cell(0, 0).setVal("Aligned");
310
- await ws.cell(0, 0).setStyle({
311
- horizontalAlign: "center",
312
- verticalAlign: "center",
313
- });
314
-
315
- const styleId = await ws.cell(0, 0).getStyleId();
316
- expect(styleId).toBeDefined();
317
- });
318
-
319
- it("숫자 형식을 설정할 수 있다", async () => {
320
- const wb = new ExcelWorkbook();
321
- const ws = await wb.createWorksheet("Test");
322
-
323
- await ws.cell(0, 0).setVal(12345.6789);
324
- await ws.cell(0, 0).setStyle({ numberFormat: "number" });
325
-
326
- const styleId = await ws.cell(0, 0).getStyleId();
327
- expect(styleId).toBeDefined();
328
- });
329
-
330
- it("여러 스타일을 동시에 설정할 수 있다", async () => {
331
- const wb = new ExcelWorkbook();
332
- const ws = await wb.createWorksheet("Test");
333
-
334
- await ws.cell(0, 0).setVal("Multi-Style");
335
- await ws.cell(0, 0).setStyle({
336
- background: "00FFFF00",
337
- border: ["left", "right"],
338
- horizontalAlign: "center",
339
- verticalAlign: "top",
340
- });
341
-
342
- const styleId = await ws.cell(0, 0).getStyleId();
343
- expect(styleId).toBeDefined();
344
- });
345
-
346
- it("잘못된 색상 형식은 에러 발생", async () => {
347
- const wb = new ExcelWorkbook();
348
- const ws = await wb.createWorksheet("Test");
349
-
350
- await ws.cell(0, 0).setVal("Test");
351
- await expect(ws.cell(0, 0).setStyle({ background: "invalid" })).rejects.toThrow();
352
- });
353
-
354
- it("설정한 스타일이 라운드트립 후에도 유지된다", async () => {
355
- const wb = new ExcelWorkbook();
356
- const ws = await wb.createWorksheet("Test");
357
-
358
- // 다양한 스타일 설정
359
- await ws.cell(0, 0).setVal("Styled");
360
- await ws.cell(0, 0).setStyle({
361
- background: "00FF0000", // 빨간색
362
- border: ["left", "right", "top", "bottom"],
363
- horizontalAlign: "center",
364
- verticalAlign: "top",
365
- });
366
-
367
- const bytes = await wb.getBytes();
368
-
369
- // 라운드트립 후 스타일 확인
370
- const wb2 = new ExcelWorkbook(bytes);
371
- const ws2 = await wb2.getWorksheet("Test");
372
-
373
- // 값 확인
374
- const val = await ws2.cell(0, 0).getVal();
375
- expect(val).toBe("Styled");
376
-
377
- // 스타일 ID가 존재하는지 확인
378
- const styleId = await ws2.cell(0, 0).getStyleId();
379
- expect(styleId).toBeDefined();
380
-
381
- // XML 레벨에서 스타일 데이터 확인
382
- const styleData = await (wb2 as any).zipCache.get("xl/styles.xml");
383
- const styleIdNum = parseInt(styleId!, 10);
384
- const xf = styleData.data.styleSheet.cellXfs[0].xf[styleIdNum];
385
-
386
- // 배경색 확인
387
- expect(xf.$.fillId).toBeDefined();
388
- const fillId = parseInt(xf.$.fillId, 10);
389
- const fill = styleData.data.styleSheet.fills[0].fill[fillId];
390
- expect(fill.patternFill[0].fgColor[0].$.rgb).toBe("00FF0000");
391
-
392
- // 테두리 확인
393
- expect(xf.$.borderId).toBeDefined();
394
- const borderId = parseInt(xf.$.borderId, 10);
395
- const border = styleData.data.styleSheet.borders[0].border[borderId];
396
- expect(border.left).toBeDefined();
397
- expect(border.right).toBeDefined();
398
- expect(border.top).toBeDefined();
399
- expect(border.bottom).toBeDefined();
400
-
401
- // 정렬 확인
402
- expect(xf.alignment).toBeDefined();
403
- expect(xf.alignment[0].$.horizontal).toBe("center");
404
- expect(xf.alignment[0].$.vertical).toBe("top");
405
- });
406
- });
407
- });
@@ -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
- });
@@ -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
- });