@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,219 +0,0 @@
1
- import type { Bytes } from "@simplysm/core-common";
2
- import { DateOnly, DateTime, numParseFloat, Time } from "@simplysm/core-common";
3
- import { type z, ZodBoolean, ZodDefault, ZodNullable, ZodNumber, ZodOptional, ZodString } from "zod";
4
- import { ExcelWorkbook } from "./excel-workbook";
5
- import type { ExcelValueType } from "./types";
6
-
7
- /**
8
- * Zod 스키마 기반 Excel 래퍼
9
- *
10
- * 스키마에서 타입 정보를 추론하여 타입 안전한 읽기/쓰기 제공
11
- */
12
- export class ExcelWrapper<T extends z.ZodObject<z.ZodRawShape>> {
13
- /**
14
- * @param _schema Zod 스키마 (레코드 구조 정의)
15
- * @param _displayNameMap 필드명-표시명 매핑 (Excel 헤더로 사용)
16
- */
17
- constructor(
18
- private readonly _schema: T,
19
- private readonly _displayNameMap: Record<keyof z.infer<T>, string>,
20
- ) {}
21
-
22
- /**
23
- * Excel 파일 읽기 → 레코드 배열
24
- */
25
- async read(file: Bytes | Blob, wsNameOrIndex: string | number = 0): Promise<z.infer<T>[]> {
26
- await using wb = new ExcelWorkbook(file);
27
-
28
- const ws = await wb.getWorksheet(wsNameOrIndex);
29
- const wsName = await ws.getName();
30
-
31
- const displayNames = Object.values(this._displayNameMap);
32
- const rawData = await ws.getDataTable({
33
- usableHeaderNameFn: (headerName) => displayNames.includes(headerName),
34
- });
35
-
36
- if (rawData.length === 0) {
37
- throw new Error(`[${wsName}] 엑셀파일에서 데이터를 찾을 수 없습니다. (기대 헤더: ${displayNames.join(", ")})`);
38
- }
39
-
40
- const reverseMap = this._getReverseDisplayNameMap();
41
- const shape = this._schema.shape;
42
- const result: z.infer<T>[] = [];
43
-
44
- for (const row of rawData) {
45
- const record: Record<string, unknown> = {};
46
- let hasNonNullValue = false;
47
-
48
- for (const [displayName, fieldKey] of reverseMap) {
49
- const rawValue = row[displayName];
50
- const fieldSchema = shape[fieldKey] as z.ZodType;
51
-
52
- if (rawValue != null && rawValue !== "") {
53
- hasNonNullValue = true;
54
- }
55
-
56
- record[fieldKey] = this._convertValue(rawValue, fieldSchema);
57
- }
58
-
59
- if (!hasNonNullValue) {
60
- continue;
61
- }
62
-
63
- // Zod 스키마로 검증
64
- const parseResult = this._schema.safeParse(record);
65
- if (!parseResult.success) {
66
- const errors = parseResult.error.issues.map((issue) => `${issue.path.join(".")}: ${issue.message}`).join(", ");
67
- throw new Error(`[${wsName}] 데이터 검증 실패: ${errors}`);
68
- }
69
-
70
- result.push(parseResult.data);
71
- }
72
-
73
- return result;
74
- }
75
-
76
- /**
77
- * 레코드 배열 → Excel 워크북
78
- *
79
- * @remarks
80
- * 반환된 워크북은 호출자가 리소스를 관리해야 합니다.
81
- * `await using`을 사용하거나 작업 완료 후 `close()`를 호출하세요.
82
- *
83
- * @example
84
- * ```typescript
85
- * await using wb = await wrapper.write("Sheet1", records);
86
- * const bytes = await wb.getBytes();
87
- * ```
88
- */
89
- async write(wsName: string, records: Partial<z.infer<T>>[]): Promise<ExcelWorkbook> {
90
- const wb = new ExcelWorkbook();
91
- const ws = await wb.createWorksheet(wsName);
92
-
93
- const keys = Object.keys(this._displayNameMap) as (keyof z.infer<T>)[];
94
- const headers = keys.map((key) => this._displayNameMap[key]);
95
-
96
- // 헤더 행 작성
97
- for (let c = 0; c < headers.length; c++) {
98
- await ws.cell(0, c).setVal(headers[c]);
99
- }
100
-
101
- // 데이터 행 작성
102
- for (let r = 0; r < records.length; r++) {
103
- for (let c = 0; c < keys.length; c++) {
104
- const key = keys[c];
105
- const value = records[r][key] as ExcelValueType;
106
- await ws.cell(r + 1, c).setVal(value);
107
- }
108
- }
109
-
110
- // 테두리 스타일 적용
111
- for (let r = 0; r < records.length + 1; r++) {
112
- for (let c = 0; c < keys.length; c++) {
113
- await ws.cell(r, c).setStyle({
114
- border: ["left", "right", "top", "bottom"],
115
- });
116
- }
117
- }
118
-
119
- // 필수 필드 헤더 강조 (노란색)
120
- const shape = this._schema.shape;
121
- for (let c = 0; c < keys.length; c++) {
122
- const fieldKey = keys[c] as string;
123
- const fieldSchema = shape[fieldKey] as z.ZodType;
124
-
125
- if (this._isRequired(fieldSchema) && !this._isBoolean(fieldSchema)) {
126
- await ws.cell(0, c).setStyle({
127
- background: "00FFFF00",
128
- });
129
- }
130
- }
131
-
132
- // 뷰 설정
133
- await ws.setZoom(85);
134
- await ws.setFix({ r: 0 });
135
-
136
- return wb;
137
- }
138
-
139
- //#region Private Methods
140
-
141
- private _getReverseDisplayNameMap(): Map<string, string> {
142
- const map = new Map<string, string>();
143
- for (const [fieldKey, displayName] of Object.entries(this._displayNameMap)) {
144
- map.set(displayName, fieldKey);
145
- }
146
- return map;
147
- }
148
-
149
- private _convertValue(rawValue: ExcelValueType, fieldSchema: z.ZodType): unknown {
150
- if (rawValue == null || rawValue === "") {
151
- return this._getDefaultForSchema(fieldSchema);
152
- }
153
-
154
- const innerSchema = this._unwrapSchema(fieldSchema);
155
-
156
- if (innerSchema instanceof ZodString) {
157
- return typeof rawValue === "string" ? rawValue : String(rawValue);
158
- }
159
-
160
- if (innerSchema instanceof ZodNumber) {
161
- if (typeof rawValue === "number") return rawValue;
162
- return numParseFloat(String(rawValue));
163
- }
164
-
165
- if (innerSchema instanceof ZodBoolean) {
166
- if (typeof rawValue === "boolean") return rawValue;
167
- if (rawValue === "1" || rawValue === "true") return true;
168
- if (rawValue === "0" || rawValue === "false") return false;
169
- return Boolean(rawValue);
170
- }
171
-
172
- // DateOnly, DateTime, Time은 instanceof로 처리
173
- if (rawValue instanceof DateOnly || rawValue instanceof DateTime || rawValue instanceof Time) {
174
- return rawValue;
175
- }
176
-
177
- return rawValue;
178
- }
179
-
180
- private _unwrapSchema(schema: z.ZodType): z.ZodType {
181
- if (schema instanceof ZodOptional || schema instanceof ZodNullable) {
182
- return this._unwrapSchema(schema.unwrap() as z.ZodType);
183
- }
184
- if (schema instanceof ZodDefault) {
185
- return this._unwrapSchema(schema.removeDefault() as z.ZodType);
186
- }
187
- return schema;
188
- }
189
-
190
- private _getDefaultForSchema(schema: z.ZodType): unknown {
191
- if (schema instanceof ZodDefault) {
192
- // ZodDefault.parse(undefined)는 기본값을 반환함
193
- return schema.parse(undefined);
194
- }
195
-
196
- if (schema instanceof ZodOptional || schema instanceof ZodNullable) {
197
- return undefined;
198
- }
199
-
200
- // Boolean 필수 필드의 기본값은 false
201
- const innerSchema = this._unwrapSchema(schema);
202
- if (innerSchema instanceof ZodBoolean) {
203
- return false;
204
- }
205
-
206
- return undefined;
207
- }
208
-
209
- private _isRequired(schema: z.ZodType): boolean {
210
- return !(schema instanceof ZodOptional) && !(schema instanceof ZodNullable) && !(schema instanceof ZodDefault);
211
- }
212
-
213
- private _isBoolean(schema: z.ZodType): boolean {
214
- const innerSchema = this._unwrapSchema(schema);
215
- return innerSchema instanceof ZodBoolean;
216
- }
217
-
218
- //#endregion
219
- }
package/src/index.ts DELETED
@@ -1,13 +0,0 @@
1
- // 타입 및 유틸리티
2
- export * from "./types";
3
- export * from "./utils/excel-utils";
4
-
5
- // 핵심 클래스
6
- export * from "./excel-cell";
7
- export * from "./excel-row";
8
- export * from "./excel-col";
9
- export * from "./excel-worksheet";
10
- export * from "./excel-workbook";
11
-
12
- // 래퍼 클래스
13
- export * from "./excel-wrapper";
package/src/types.ts DELETED
@@ -1,396 +0,0 @@
1
- import type { DateOnly, DateTime, Time } from "@simplysm/core-common";
2
-
3
- //#region XML Data Types
4
-
5
- export interface ExcelXmlContentTypeData {
6
- Types: {
7
- $: {
8
- xmlns: string;
9
- };
10
- Default: {
11
- $: {
12
- Extension: string;
13
- ContentType: string;
14
- };
15
- }[];
16
- Override: {
17
- $: {
18
- PartName: string;
19
- ContentType: string;
20
- };
21
- }[];
22
- };
23
- }
24
-
25
- export interface ExcelXmlRelationshipData {
26
- Relationships: {
27
- $: {
28
- xmlns: string;
29
- };
30
- Relationship?: ExcelRelationshipData[];
31
- };
32
- }
33
-
34
- export interface ExcelRelationshipData {
35
- $: {
36
- Id: string;
37
- Target: string;
38
- Type: string;
39
- };
40
- }
41
-
42
- export interface ExcelXmlWorkbookData {
43
- workbook: {
44
- $: {
45
- "xmlns": string;
46
- "xmlns:r"?: string;
47
- };
48
- bookViews?: [
49
- {
50
- workbookView: [{}];
51
- },
52
- ];
53
- sheets?: [
54
- {
55
- sheet: {
56
- $: {
57
- "name": string;
58
- "sheetId": string;
59
- "r:id": string;
60
- };
61
- }[];
62
- },
63
- ];
64
- };
65
- }
66
-
67
- export interface ExcelXmlWorksheetData {
68
- worksheet: {
69
- $: { "xmlns": string; "xmlns:r"?: string };
70
- dimension?: [
71
- {
72
- $: {
73
- ref: string;
74
- };
75
- },
76
- ];
77
- sheetViews?: [
78
- {
79
- sheetView: {
80
- $: {
81
- workbookViewId: string;
82
- zoomScale?: string;
83
- };
84
- pane?: [
85
- {
86
- $: {
87
- xSplit?: string;
88
- ySplit?: string;
89
- topLeftCell?: string;
90
- activePane?: string;
91
- state?: string;
92
- };
93
- },
94
- ];
95
- }[];
96
- },
97
- ];
98
- sheetFormatPr?: [
99
- {
100
- $: {
101
- defaultRowHeight: string;
102
- };
103
- },
104
- ];
105
- cols?: [
106
- {
107
- col: {
108
- $: {
109
- min: string;
110
- max: string;
111
- width?: string;
112
- bestFit?: string;
113
- customWidth?: string;
114
- };
115
- }[];
116
- },
117
- ];
118
- sheetData: [
119
- {
120
- row?: ExcelRowData[];
121
- },
122
- ];
123
- mergeCells?: [
124
- {
125
- $: { count: string };
126
- mergeCell: {
127
- $: { ref: string };
128
- }[];
129
- },
130
- ];
131
- drawing?: { $: { "r:id": string } }[];
132
- };
133
- }
134
-
135
- export interface ExcelRowData {
136
- $: {
137
- r: string; // address (1~)
138
- };
139
- c?: ExcelCellData[];
140
- }
141
-
142
- export interface ExcelCellData {
143
- $: {
144
- r: string; // address (A~)
145
- s?: string; // styleId
146
- t?: string; // type: s(sharedString)
147
- };
148
- v?: [string];
149
- f?: [string];
150
- is?: {
151
- t?: {
152
- _?: string;
153
- }[];
154
- }[];
155
- }
156
-
157
- export interface ExcelXmlDrawingData {
158
- wsDr: {
159
- $: {
160
- "xmlns": string;
161
- "xmlns:a"?: string;
162
- "xmlns:r"?: string;
163
- };
164
- twoCellAnchor?: {
165
- from?: {
166
- col: string[];
167
- colOff?: string[];
168
- row: string[];
169
- rowOff?: string[];
170
- }[];
171
- to?: {
172
- col: string[];
173
- colOff?: string[];
174
- row: string[];
175
- rowOff?: string[];
176
- }[];
177
- pic?: {
178
- nvPicPr?: {
179
- cNvPr?: { $: { id: string; name: string; descr?: string } }[];
180
- cNvPicPr?: Array<{ "a:picLocks"?: Array<{ $: { noChangeAspect?: string } }> }>;
181
- }[];
182
- blipFill?: {
183
- "a:blip"?: Array<{ $: { "r:embed": string } }>;
184
- "a:stretch"?: Array<{ "a:fillRect": unknown[] }>;
185
- }[];
186
- spPr?: {
187
- "a:xfrm"?: Array<{
188
- "a:off"?: Array<{ $: { x: string; y: string } }>;
189
- "a:ext"?: Array<{ $: { cx: string; cy: string } }>;
190
- }>;
191
- "a:prstGeom"?: Array<{ "$": { prst: string }; "a:avLst": unknown[] }>;
192
- }[];
193
- }[];
194
- clientData?: unknown[];
195
- }[];
196
- };
197
- }
198
-
199
- export interface ExcelXmlSharedStringData {
200
- sst: {
201
- $: { xmlns: string };
202
- si?: ExcelXmlSharedStringDataSi[];
203
- };
204
- }
205
-
206
- export type ExcelXmlSharedStringDataSi =
207
- | {
208
- t: ExcelXmlSharedStringDataText;
209
- }
210
- | {
211
- r: {
212
- t: ExcelXmlSharedStringDataText;
213
- }[];
214
- };
215
-
216
- export type ExcelXmlSharedStringDataText = [
217
- | string
218
- | {
219
- $: { space?: "preserve" };
220
- _?: string;
221
- },
222
- ];
223
-
224
- export interface ExcelXmlStyleData {
225
- styleSheet: {
226
- $: { xmlns: string };
227
- numFmts?: [
228
- {
229
- $: { count: string };
230
- numFmt?: {
231
- $: {
232
- numFmtId: string;
233
- formatCode: string;
234
- };
235
- }[];
236
- },
237
- ];
238
- fonts: [
239
- {
240
- $: { count: string };
241
- font: {}[];
242
- },
243
- ];
244
- fills: [
245
- {
246
- $: { count: string };
247
- fill: ExcelXmlStyleDataFill[];
248
- },
249
- ];
250
- borders: [
251
- {
252
- $: { count: string };
253
- border: ExcelXmlStyleDataBorder[];
254
- },
255
- ];
256
- cellXfs: [
257
- {
258
- $: { count: string };
259
- xf: ExcelXmlStyleDataXf[];
260
- },
261
- ];
262
- };
263
- }
264
-
265
- export interface ExcelXmlStyleDataXf {
266
- $: {
267
- numFmtId?: string;
268
- fontId?: string;
269
- fillId?: string;
270
- borderId?: string;
271
- xfId?: string;
272
- applyNumberFormat?: string;
273
- applyFont?: string;
274
- applyAlignment?: string;
275
- applyFill?: string;
276
- applyBorder?: string;
277
- };
278
- alignment?: [
279
- {
280
- $: { horizontal?: "center" | "left" | "right"; vertical?: "center" | "top" | "bottom" };
281
- },
282
- ];
283
- }
284
-
285
- export interface ExcelXmlStyleDataFill {
286
- patternFill: [
287
- {
288
- $: { patternType: "none" | "solid" | "gray125" };
289
- fgColor?: [{ $: { rgb: string } }];
290
- },
291
- ];
292
- }
293
-
294
- export interface ExcelXmlStyleDataBorder {
295
- top?: [
296
- {
297
- $: { style: "thin" | "medium" };
298
- color?: [{ $: { rgb: string } }];
299
- },
300
- ];
301
- left?: [
302
- {
303
- $: { style: "thin" | "medium" };
304
- color?: [{ $: { rgb: string } }];
305
- },
306
- ];
307
- right?: [
308
- {
309
- $: { style: "thin" | "medium" };
310
- color?: [{ $: { rgb: string } }];
311
- },
312
- ];
313
- bottom?: [
314
- {
315
- $: { style: "thin" | "medium" };
316
- color?: [{ $: { rgb: string } }];
317
- },
318
- ];
319
- }
320
-
321
- //#endregion
322
-
323
- //#region Value Types
324
-
325
- export type ExcelValueType = number | string | DateOnly | DateTime | Time | boolean | undefined;
326
- export type ExcelNumberFormat = "number" | "string" | "DateOnly" | "DateTime" | "Time";
327
-
328
- /**
329
- * Excel 셀 타입
330
- * - s: 공유 문자열 (SharedString)
331
- * - b: 불리언
332
- * - str: 수식 결과 문자열
333
- * - n: 숫자
334
- * - inlineStr: 인라인 문자열 (리치 텍스트)
335
- * - e: 에러
336
- */
337
- export type ExcelCellType = "s" | "b" | "str" | "n" | "inlineStr" | "e";
338
-
339
- //#endregion
340
-
341
- //#region Address Types
342
-
343
- export interface ExcelAddressPoint {
344
- r: number;
345
- c: number;
346
- }
347
-
348
- export interface ExcelAddressRangePoint {
349
- s: ExcelAddressPoint;
350
- e: ExcelAddressPoint;
351
- }
352
-
353
- //#endregion
354
-
355
- //#region Excel XML Interface
356
-
357
- export interface ExcelXml {
358
- readonly data: unknown;
359
- cleanup(): void;
360
- }
361
-
362
- //#endregion
363
-
364
- //#region Style Types
365
-
366
- export type ExcelBorderPosition = "left" | "right" | "top" | "bottom";
367
- export type ExcelHorizontalAlign = "center" | "left" | "right";
368
- export type ExcelVerticalAlign = "center" | "top" | "bottom";
369
-
370
- /**
371
- * 셀 스타일 옵션
372
- * @example
373
- * ```typescript
374
- * await cell.setStyle({
375
- * background: "00FF0000", // 빨간색
376
- * border: ["left", "right", "top", "bottom"],
377
- * horizontalAlign: "center",
378
- * verticalAlign: "center",
379
- * numberFormat: "number",
380
- * });
381
- * ```
382
- */
383
- export interface ExcelStyleOptions {
384
- /** 배경색 (ARGB 형식, 예: "00FF0000") */
385
- background?: string;
386
- /** 테두리 위치 */
387
- border?: ExcelBorderPosition[];
388
- /** 가로 정렬 */
389
- horizontalAlign?: ExcelHorizontalAlign;
390
- /** 세로 정렬 */
391
- verticalAlign?: ExcelVerticalAlign;
392
- /** 숫자 형식 */
393
- numberFormat?: ExcelNumberFormat;
394
- }
395
-
396
- //#endregion