@simplysm/excel 13.0.99 → 14.0.1

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 (95) hide show
  1. package/dist/excel-cell.d.ts +28 -28
  2. package/dist/excel-cell.d.ts.map +1 -1
  3. package/dist/excel-cell.js +273 -264
  4. package/dist/excel-cell.js.map +1 -6
  5. package/dist/excel-col.d.ts +4 -4
  6. package/dist/excel-col.d.ts.map +1 -1
  7. package/dist/excel-col.js +33 -35
  8. package/dist/excel-col.js.map +1 -6
  9. package/dist/excel-row.d.ts +3 -3
  10. package/dist/excel-row.d.ts.map +1 -1
  11. package/dist/excel-row.js +28 -30
  12. package/dist/excel-row.js.map +1 -6
  13. package/dist/excel-workbook.d.ts +23 -23
  14. package/dist/excel-workbook.d.ts.map +1 -1
  15. package/dist/excel-workbook.js +151 -125
  16. package/dist/excel-workbook.js.map +1 -6
  17. package/dist/excel-worksheet.d.ts +32 -32
  18. package/dist/excel-worksheet.d.ts.map +1 -1
  19. package/dist/excel-worksheet.js +281 -253
  20. package/dist/excel-worksheet.js.map +1 -6
  21. package/dist/excel-wrapper.d.ts +7 -7
  22. package/dist/excel-wrapper.d.ts.map +1 -1
  23. package/dist/excel-wrapper.js +190 -226
  24. package/dist/excel-wrapper.js.map +1 -6
  25. package/dist/index.js +4 -1
  26. package/dist/index.js.map +1 -6
  27. package/dist/types.d.ts +13 -13
  28. package/dist/types.d.ts.map +1 -1
  29. package/dist/types.js +3 -1
  30. package/dist/types.js.map +1 -6
  31. package/dist/utils/excel-utils.d.ts +23 -23
  32. package/dist/utils/excel-utils.d.ts.map +1 -1
  33. package/dist/utils/excel-utils.js +183 -151
  34. package/dist/utils/excel-utils.js.map +1 -6
  35. package/dist/utils/zip-cache.d.ts +6 -6
  36. package/dist/utils/zip-cache.js +78 -60
  37. package/dist/utils/zip-cache.js.map +1 -6
  38. package/dist/xml/excel-xml-content-type.d.ts +2 -2
  39. package/dist/xml/excel-xml-content-type.js +55 -53
  40. package/dist/xml/excel-xml-content-type.js.map +1 -6
  41. package/dist/xml/excel-xml-drawing.d.ts +2 -2
  42. package/dist/xml/excel-xml-drawing.js +74 -73
  43. package/dist/xml/excel-xml-drawing.js.map +1 -6
  44. package/dist/xml/excel-xml-relationship.d.ts +2 -2
  45. package/dist/xml/excel-xml-relationship.js +67 -67
  46. package/dist/xml/excel-xml-relationship.js.map +1 -6
  47. package/dist/xml/excel-xml-shared-string.d.ts +2 -2
  48. package/dist/xml/excel-xml-shared-string.js +57 -55
  49. package/dist/xml/excel-xml-shared-string.js.map +1 -6
  50. package/dist/xml/excel-xml-style.d.ts +2 -2
  51. package/dist/xml/excel-xml-style.js +311 -295
  52. package/dist/xml/excel-xml-style.js.map +1 -6
  53. package/dist/xml/excel-xml-unknown.d.ts +2 -2
  54. package/dist/xml/excel-xml-unknown.js +11 -10
  55. package/dist/xml/excel-xml-unknown.js.map +1 -6
  56. package/dist/xml/excel-xml-workbook.d.ts +2 -2
  57. package/dist/xml/excel-xml-workbook.js +87 -90
  58. package/dist/xml/excel-xml-workbook.js.map +1 -6
  59. package/dist/xml/excel-xml-worksheet.d.ts +6 -6
  60. package/dist/xml/excel-xml-worksheet.js +450 -393
  61. package/dist/xml/excel-xml-worksheet.js.map +1 -6
  62. package/package.json +5 -7
  63. package/src/excel-cell.ts +36 -36
  64. package/src/excel-col.ts +4 -4
  65. package/src/excel-row.ts +3 -3
  66. package/src/excel-workbook.ts +38 -38
  67. package/src/excel-worksheet.ts +69 -51
  68. package/src/excel-wrapper.ts +55 -50
  69. package/src/index.ts +3 -3
  70. package/src/types.ts +17 -17
  71. package/src/utils/excel-utils.ts +47 -41
  72. package/src/utils/zip-cache.ts +6 -6
  73. package/src/xml/excel-xml-content-type.ts +3 -3
  74. package/src/xml/excel-xml-drawing.ts +2 -2
  75. package/src/xml/excel-xml-relationship.ts +3 -3
  76. package/src/xml/excel-xml-shared-string.ts +2 -2
  77. package/src/xml/excel-xml-style.ts +11 -11
  78. package/src/xml/excel-xml-unknown.ts +2 -2
  79. package/src/xml/excel-xml-workbook.ts +5 -5
  80. package/src/xml/excel-xml-worksheet.ts +43 -43
  81. package/README.md +0 -119
  82. package/docs/core-classes.md +0 -541
  83. package/docs/types.md +0 -297
  84. package/docs/utilities.md +0 -128
  85. package/docs/wrapper.md +0 -100
  86. package/tests/excel-cell.spec.ts +0 -393
  87. package/tests/excel-col.spec.ts +0 -81
  88. package/tests/excel-row.spec.ts +0 -61
  89. package/tests/excel-workbook.spec.ts +0 -205
  90. package/tests/excel-worksheet.spec.ts +0 -469
  91. package/tests/excel-wrapper.spec.ts +0 -273
  92. package/tests/fixtures/logo.png +0 -0
  93. package/tests/fixtures//354/264/210/352/270/260/355/231/224.xlsx +0 -0
  94. package/tests/image-insert.spec.ts +0 -190
  95. package/tests/utils/excel-utils.spec.ts +0 -198
@@ -1,58 +1,58 @@
1
1
  import type { ZipCache } from "./utils/zip-cache";
2
2
  import type { ExcelAddressPoint, ExcelStyleOptions, ExcelValueType } from "./types";
3
3
  /**
4
- * Class representing an Excel cell.
5
- * Provides value read/write, formula, style, and cell merge functionality.
4
+ * Excel 셀을 나타내는 클래스.
5
+ * 읽기/쓰기, 수식, 스타일, 병합 기능을 제공한다.
6
6
  *
7
7
  * @remarks
8
- * ## Async Method Design
8
+ * ## 비동기 메서드 설계
9
9
  *
10
- * Why all cell methods like `getValue()`, `setValue()` are `async`:
11
- * - Only the XML needed for the cell type is selectively loaded
12
- * - String cell: loads SharedStrings.xml
13
- * - Number cell: does not load SharedStrings
14
- * - Styled cell: loads Styles.xml
10
+ * `getValue()`, `setValue()` 모든 셀 메서드가 `async`인 이유:
11
+ * - 타입에 필요한 XML 선택적으로 로드함
12
+ * - 문자열 셀: SharedStrings.xml 로드
13
+ * - 숫자 셀: SharedStrings 로드하지 않음
14
+ * - 스타일 적용 셀: Styles.xml 로드
15
15
  *
16
- * Since the cell to be read cannot be known in advance, a synchronous design is not feasible.
17
- * A synchronous design would require preloading all XML, causing memory issues with large files.
16
+ * 읽을 셀을 사전에 없으므로 동기 설계가 불가능하다.
17
+ * 동기 설계는 모든 XML을 미리 로드해야 하므로 대용량 파일에서 메모리 문제가 발생한다.
18
18
  */
19
19
  export declare class ExcelCell {
20
20
  private readonly _zipCache;
21
21
  private readonly _targetFileName;
22
22
  private readonly _r;
23
23
  private readonly _c;
24
- /** Cell address (0-based row/column index) */
24
+ /** 주소 (0 기반 행/열 인덱스) */
25
25
  readonly addr: ExcelAddressPoint;
26
26
  constructor(_zipCache: ZipCache, _targetFileName: string, _r: number, _c: number);
27
- /** Set formula on cell (undefined: remove formula) */
27
+ /** 셀에 수식 설정 (undefined: 수식 제거) */
28
28
  setFormula(val: string | undefined): Promise<void>;
29
- /** Return cell formula */
29
+ /** 수식 반환 */
30
30
  getFormula(): Promise<string | undefined>;
31
- /** Set cell value (undefined: delete cell) */
31
+ /** 설정 (undefined: 삭제) */
32
32
  setValue(val: ExcelValueType): Promise<void>;
33
- /** Return cell value */
33
+ /** 반환 */
34
34
  getValue(): Promise<ExcelValueType>;
35
35
  /**
36
- * Merge cells from current cell to the specified end coordinates
37
- * @param r End row index of merge (0-based)
38
- * @param c End column index of merge (0-based)
36
+ * 현재 셀에서 지정된 좌표까지 병합
37
+ * @param r 병합 인덱스 (0 기반)
38
+ * @param c 병합 인덱스 (0 기반)
39
39
  * @example
40
- * // Called from cell A1, merges range A1:C3 (3 rows x 3 columns)
40
+ * // A1 셀에서 호출하여 A1:C3 범위 병합 (3 x 3)
41
41
  * await ws.cell(0, 0).merge(2, 2);
42
42
  */
43
43
  merge(r: number, c: number): Promise<void>;
44
- /** Return cell style ID */
44
+ /** 스타일 ID 반환 */
45
45
  getStyleId(): Promise<string | undefined>;
46
- /** Set cell style ID */
46
+ /** 스타일 ID 설정 */
47
47
  setStyleId(styleId: string | undefined): Promise<void>;
48
48
  /**
49
- * Set cell style
50
- * @param opts Style options
51
- * @param opts.background Background color (ARGB format, 8-digit hex. e.g. "00FF0000")
52
- * @param opts.border Border position array (e.g. ["left", "right", "top", "bottom"])
53
- * @param opts.horizontalAlign Horizontal alignment ("left", "center", "right")
54
- * @param opts.verticalAlign Vertical alignment ("top", "center", "bottom")
55
- * @param opts.numberFormat Number format ("number", "DateOnly", "DateTime", "Time", "string")
49
+ * 스타일 설정
50
+ * @param opts 스타일 옵션
51
+ * @param opts.background 배경색 (ARGB 형식, 8자리 16진수. 예: "00FF0000")
52
+ * @param opts.border 테두리 위치 배열 (예: ["left", "right", "top", "bottom"])
53
+ * @param opts.horizontalAlign 가로 정렬 ("left", "center", "right")
54
+ * @param opts.verticalAlign 세로 정렬 ("top", "center", "bottom")
55
+ * @param opts.numberFormat 숫자 형식 ("number", "DateOnly", "DateTime", "Time", "string")
56
56
  */
57
57
  setStyle(opts: ExcelStyleOptions): Promise<void>;
58
58
  private _deleteCell;
@@ -1 +1 @@
1
- {"version":3,"file":"excel-cell.d.ts","sourceRoot":"","sources":["..\\src\\excel-cell.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAYpF;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,SAAS;IAKlB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,EAAE;IACnB,OAAO,CAAC,QAAQ,CAAC,EAAE;IAPrB,8CAA8C;IAC9C,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;gBAGd,SAAS,EAAE,QAAQ,EACnB,eAAe,EAAE,MAAM,EACvB,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM;IAO7B,sDAAsD;IAChD,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAWxD,0BAA0B;IACpB,UAAU,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAK/C,8CAA8C;IACxC,QAAQ,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAwClD,wBAAwB;IAClB,QAAQ,IAAI,OAAO,CAAC,cAAc,CAAC;IAwFzC;;;;;;;OAOG;IACG,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAShD,2BAA2B;IACrB,UAAU,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAK/C,wBAAwB;IAClB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAK5D;;;;;;;;OAQG;IACG,QAAQ,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;YAiCxC,WAAW;YAKX,UAAU;YAIV,iBAAiB;YAYjB,YAAY;YAIZ,UAAU;YAIV,aAAa;YAIb,aAAa;YAIb,kBAAkB;YAqBlB,qBAAqB;CAsBpC"}
1
+ {"version":3,"file":"excel-cell.d.ts","sourceRoot":"","sources":["..\\src\\excel-cell.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAYpF;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,SAAS;IAKlB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,EAAE;IACnB,OAAO,CAAC,QAAQ,CAAC,EAAE;IAPrB,0BAA0B;IAC1B,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;gBAGd,SAAS,EAAE,QAAQ,EACnB,eAAe,EAAE,MAAM,EACvB,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM;IAO7B,kCAAkC;IAC5B,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAWxD,cAAc;IACR,UAAU,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAK/C,+BAA+B;IACzB,QAAQ,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAwClD,aAAa;IACP,QAAQ,IAAI,OAAO,CAAC,cAAc,CAAC;IAwFzC;;;;;;;OAOG;IACG,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAShD,kBAAkB;IACZ,UAAU,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAK/C,kBAAkB;IACZ,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAK5D;;;;;;;;OAQG;IACG,QAAQ,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;YAiCxC,WAAW;YAKX,UAAU;YAIV,iBAAiB;YAYjB,YAAY;YAIZ,UAAU;YAIV,aAAa;YAIb,aAAa;YAIb,kBAAkB;YAqBlB,qBAAqB;CAsBpC"}
@@ -1,283 +1,292 @@
1
- import {
2
- DateOnly,
3
- DateTime,
4
- num,
5
- str,
6
- Time
7
- } from "@simplysm/core-common";
1
+ import { DateOnly, DateTime, num, str, Time, } from "@simplysm/core-common";
8
2
  import { ExcelXmlSharedString as ExcelXmlSharedStringClass } from "./xml/excel-xml-shared-string.js";
9
3
  import { ExcelXmlStyle as ExcelXmlStyleClass } from "./xml/excel-xml-style.js";
10
4
  import { ExcelUtils } from "./utils/excel-utils.js";
11
- class ExcelCell {
12
- constructor(_zipCache, _targetFileName, _r, _c) {
13
- this._zipCache = _zipCache;
14
- this._targetFileName = _targetFileName;
15
- this._r = _r;
16
- this._c = _c;
17
- this.addr = { r: this._r, c: this._c };
18
- }
19
- /** Cell address (0-based row/column index) */
20
- addr;
21
- //#region Value Methods
22
- /** Set formula on cell (undefined: remove formula) */
23
- async setFormula(val) {
24
- if (val === void 0) {
25
- await this._deleteCell(this.addr);
26
- } else {
27
- const wsData = await this._getWsData();
28
- wsData.setCellType(this.addr, "str");
29
- wsData.setCellVal(this.addr, void 0);
30
- wsData.setCellFormula(this.addr, val);
5
+ /**
6
+ * Excel 셀을 나타내는 클래스.
7
+ * 값 읽기/쓰기, 수식, 스타일, 셀 병합 기능을 제공한다.
8
+ *
9
+ * @remarks
10
+ * ## 비동기 메서드 설계
11
+ *
12
+ * `getValue()`, `setValue()` 등 모든 셀 메서드가 `async`인 이유:
13
+ * - 타입에 필요한 XML만 선택적으로 로드함
14
+ * - 문자열 셀: SharedStrings.xml 로드
15
+ * - 숫자 셀: SharedStrings 로드하지 않음
16
+ * - 스타일 적용 셀: Styles.xml 로드
17
+ *
18
+ * 읽을 셀을 사전에 알 수 없으므로 동기 설계가 불가능하다.
19
+ * 동기 설계는 모든 XML을 미리 로드해야 하므로 대용량 파일에서 메모리 문제가 발생한다.
20
+ */
21
+ export class ExcelCell {
22
+ _zipCache;
23
+ _targetFileName;
24
+ _r;
25
+ _c;
26
+ /** 셀 주소 (0 기반 행/열 인덱스) */
27
+ addr;
28
+ constructor(_zipCache, _targetFileName, _r, _c) {
29
+ this._zipCache = _zipCache;
30
+ this._targetFileName = _targetFileName;
31
+ this._r = _r;
32
+ this._c = _c;
33
+ this.addr = { r: this._r, c: this._c };
31
34
  }
32
- }
33
- /** Return cell formula */
34
- async getFormula() {
35
- const wsData = await this._getWsData();
36
- return wsData.getCellFormula(this.addr);
37
- }
38
- /** Set cell value (undefined: delete cell) */
39
- async setValue(val) {
40
- if (val === void 0) {
41
- await this._deleteCell(this.addr);
42
- } else if (typeof val === "string") {
43
- const wsData = await this._getWsData();
44
- const ssData = await this._getOrCreateSsData();
45
- const ssId = ssData.getIdByString(val);
46
- if (ssId !== void 0) {
47
- wsData.setCellType(this.addr, "s");
48
- wsData.setCellVal(this.addr, ssId.toString());
49
- } else {
50
- const newSsId = ssData.add(val);
51
- wsData.setCellType(this.addr, "s");
52
- wsData.setCellVal(this.addr, newSsId.toString());
53
- }
54
- } else if (typeof val === "boolean") {
55
- const wsData = await this._getWsData();
56
- wsData.setCellType(this.addr, "b");
57
- wsData.setCellVal(this.addr, val ? "1" : "0");
58
- } else if (typeof val === "number") {
59
- const wsData = await this._getWsData();
60
- wsData.setCellType(this.addr, void 0);
61
- wsData.setCellVal(this.addr, val.toString());
62
- } else if (val instanceof DateOnly || val instanceof DateTime || val instanceof Time) {
63
- const wsData = await this._getWsData();
64
- wsData.setCellType(this.addr, void 0);
65
- wsData.setCellVal(this.addr, ExcelUtils.convertTimeTickToNumber(val.tick).toString());
66
- const numFmtName = val instanceof DateOnly ? "DateOnly" : val instanceof DateTime ? "DateTime" : "Time";
67
- await this._setStyleInternal({
68
- numFmtId: ExcelUtils.convertNumFmtNameToId(numFmtName).toString()
69
- });
70
- } else {
71
- throw new Error(
72
- `[${ExcelUtils.stringifyAddr(this.addr)}] Unsupported type: ${typeof val}`
73
- );
35
+ //#region Value Methods
36
+ /** 셀에 수식 설정 (undefined: 수식 제거) */
37
+ async setFormula(val) {
38
+ if (val === undefined) {
39
+ await this._deleteCell(this.addr);
40
+ }
41
+ else {
42
+ const wsData = await this._getWsData();
43
+ wsData.setCellType(this.addr, "str");
44
+ wsData.setCellVal(this.addr, undefined);
45
+ wsData.setCellFormula(this.addr, val);
46
+ }
47
+ }
48
+ /** 수식 반환 */
49
+ async getFormula() {
50
+ const wsData = await this._getWsData();
51
+ return wsData.getCellFormula(this.addr);
52
+ }
53
+ /** 설정 (undefined: 셀 삭제) */
54
+ async setValue(val) {
55
+ if (val === undefined) {
56
+ await this._deleteCell(this.addr);
57
+ }
58
+ else if (typeof val === "string") {
59
+ const wsData = await this._getWsData();
60
+ const ssData = await this._getOrCreateSsData();
61
+ const ssId = ssData.getIdByString(val);
62
+ if (ssId !== undefined) {
63
+ wsData.setCellType(this.addr, "s");
64
+ wsData.setCellVal(this.addr, ssId.toString());
65
+ }
66
+ else {
67
+ const newSsId = ssData.add(val);
68
+ wsData.setCellType(this.addr, "s");
69
+ wsData.setCellVal(this.addr, newSsId.toString());
70
+ }
71
+ }
72
+ else if (typeof val === "boolean") {
73
+ const wsData = await this._getWsData();
74
+ wsData.setCellType(this.addr, "b");
75
+ wsData.setCellVal(this.addr, val ? "1" : "0");
76
+ }
77
+ else if (typeof val === "number") {
78
+ const wsData = await this._getWsData();
79
+ wsData.setCellType(this.addr, undefined);
80
+ wsData.setCellVal(this.addr, val.toString());
81
+ }
82
+ else if (val instanceof DateOnly || val instanceof DateTime || val instanceof Time) {
83
+ const wsData = await this._getWsData();
84
+ wsData.setCellType(this.addr, undefined);
85
+ wsData.setCellVal(this.addr, ExcelUtils.convertTimeTickToNumber(val.tick).toString());
86
+ const numFmtName = val instanceof DateOnly ? "DateOnly" : val instanceof DateTime ? "DateTime" : "Time";
87
+ await this._setStyleInternal({
88
+ numFmtId: ExcelUtils.convertNumFmtNameToId(numFmtName).toString(),
89
+ });
90
+ }
91
+ else {
92
+ throw new Error(`[${ExcelUtils.stringifyAddr(this.addr)}] 지원하지 않는 타입: ${typeof val}`);
93
+ }
94
+ }
95
+ /** 셀 값 반환 */
96
+ async getValue() {
97
+ const wsData = await this._getWsData();
98
+ const cellVal = wsData.getCellVal(this.addr);
99
+ if (cellVal === undefined || str.isNullOrEmpty(cellVal)) {
100
+ return undefined;
101
+ }
102
+ const cellType = wsData.getCellType(this.addr);
103
+ if (cellType === "s") {
104
+ const ssData = await this._getOrCreateSsData();
105
+ const ssId = num.parseInt(cellVal);
106
+ if (ssId == null) {
107
+ throw new Error(`[${ExcelUtils.stringifyAddr(this.addr)}] SharedString ID 파싱 실패: ${cellVal}`);
108
+ }
109
+ return ssData.getStringById(ssId);
110
+ }
111
+ else if (cellType === "str") {
112
+ return cellVal;
113
+ }
114
+ else if (cellType === "inlineStr") {
115
+ return cellVal;
116
+ }
117
+ else if (cellType === "b") {
118
+ return cellVal === "1";
119
+ }
120
+ else if (cellType === "n") {
121
+ return parseFloat(cellVal);
122
+ }
123
+ else if (cellType === "e") {
124
+ throw new Error(`[${ExcelUtils.stringifyAddr(this.addr)}] 셀 타입 분석 실패: 셀에 에러 값이 포함되어 있음 (${cellVal})`);
125
+ }
126
+ else {
127
+ // cellType === undefined: 숫자 또는 날짜/시간 타입
128
+ const cellStyleId = wsData.getCellStyleId(this.addr);
129
+ if (cellStyleId === undefined) {
130
+ return parseFloat(cellVal);
131
+ }
132
+ const styleData = await this._getStyleData();
133
+ if (styleData == null) {
134
+ return parseFloat(cellVal);
135
+ }
136
+ const numFmtId = styleData.get(cellStyleId).numFmtId;
137
+ if (numFmtId === undefined) {
138
+ return parseFloat(cellVal);
139
+ }
140
+ const numFmtCode = styleData.getNumFmtCode(numFmtId);
141
+ let numFmt;
142
+ if (numFmtCode !== undefined) {
143
+ numFmt = ExcelUtils.convertNumFmtCodeToName(numFmtCode);
144
+ }
145
+ else {
146
+ const numFmtIdNum = num.parseInt(numFmtId);
147
+ if (numFmtIdNum == null) {
148
+ throw new Error(`[${ExcelUtils.stringifyAddr(this.addr)}] numFmtId 파싱 실패: ${numFmtId}`);
149
+ }
150
+ numFmt = ExcelUtils.convertNumFmtIdToName(numFmtIdNum);
151
+ }
152
+ if (numFmt === "number") {
153
+ return parseFloat(cellVal);
154
+ }
155
+ else if (numFmt === "string") {
156
+ return cellVal;
157
+ }
158
+ else {
159
+ // DateOnly, DateTime, Time 타입
160
+ const dateNum = num.parseFloat(cellVal);
161
+ if (dateNum == null) {
162
+ throw new Error(`[${ExcelUtils.stringifyAddr(this.addr)}] 날짜 숫자 파싱 실패: ${cellVal}`);
163
+ }
164
+ const tick = ExcelUtils.convertNumberToTimeTick(dateNum);
165
+ if (numFmt === "DateOnly") {
166
+ return new DateOnly(tick);
167
+ }
168
+ else if (numFmt === "DateTime") {
169
+ return new DateTime(tick);
170
+ }
171
+ else {
172
+ return new Time(tick);
173
+ }
174
+ }
175
+ }
176
+ }
177
+ //#endregion
178
+ //#region Merge Methods
179
+ /**
180
+ * 현재 셀에서 지정된 끝 좌표까지 셀 병합
181
+ * @param r 병합 끝 행 인덱스 (0 기반)
182
+ * @param c 병합 끝 열 인덱스 (0 기반)
183
+ * @example
184
+ * // A1 셀에서 호출하여 A1:C3 범위 병합 (3행 x 3열)
185
+ * await ws.cell(0, 0).merge(2, 2);
186
+ */
187
+ async merge(r, c) {
188
+ const wsData = await this._getWsData();
189
+ wsData.setMergeCells(this.addr, { r, c });
190
+ }
191
+ //#endregion
192
+ //#region Style Methods
193
+ /** 셀 스타일 ID 반환 */
194
+ async getStyleId() {
195
+ const wsData = await this._getWsData();
196
+ return wsData.getCellStyleId(this.addr);
74
197
  }
75
- }
76
- /** Return cell value */
77
- async getValue() {
78
- const wsData = await this._getWsData();
79
- const cellVal = wsData.getCellVal(this.addr);
80
- if (cellVal === void 0 || str.isNullOrEmpty(cellVal)) {
81
- return void 0;
198
+ /** 셀 스타일 ID 설정 */
199
+ async setStyleId(styleId) {
200
+ const wsData = await this._getWsData();
201
+ wsData.setCellStyleId(this.addr, styleId);
82
202
  }
83
- const cellType = wsData.getCellType(this.addr);
84
- if (cellType === "s") {
85
- const ssData = await this._getOrCreateSsData();
86
- const ssId = num.parseInt(cellVal);
87
- if (ssId == null) {
88
- throw new Error(
89
- `[${ExcelUtils.stringifyAddr(this.addr)}] Failed to parse SharedString ID: ${cellVal}`
90
- );
91
- }
92
- return ssData.getStringById(ssId);
93
- } else if (cellType === "str") {
94
- return cellVal;
95
- } else if (cellType === "inlineStr") {
96
- return cellVal;
97
- } else if (cellType === "b") {
98
- return cellVal === "1";
99
- } else if (cellType === "n") {
100
- return parseFloat(cellVal);
101
- } else if (cellType === "e") {
102
- throw new Error(
103
- `[${ExcelUtils.stringifyAddr(this.addr)}] Cell type analysis failed: cell contains error value (${cellVal})`
104
- );
105
- } else {
106
- const cellStyleId = wsData.getCellStyleId(this.addr);
107
- if (cellStyleId === void 0) {
108
- return parseFloat(cellVal);
109
- }
110
- const styleData = await this._getStyleData();
111
- if (styleData == null) {
112
- return parseFloat(cellVal);
113
- }
114
- const numFmtId = styleData.get(cellStyleId).numFmtId;
115
- if (numFmtId === void 0) {
116
- return parseFloat(cellVal);
117
- }
118
- const numFmtCode = styleData.getNumFmtCode(numFmtId);
119
- let numFmt;
120
- if (numFmtCode !== void 0) {
121
- numFmt = ExcelUtils.convertNumFmtCodeToName(numFmtCode);
122
- } else {
123
- const numFmtIdNum = num.parseInt(numFmtId);
124
- if (numFmtIdNum == null) {
125
- throw new Error(
126
- `[${ExcelUtils.stringifyAddr(this.addr)}] Failed to parse numFmtId: ${numFmtId}`
127
- );
203
+ /**
204
+ * 스타일 설정
205
+ * @param opts 스타일 옵션
206
+ * @param opts.background 배경색 (ARGB 형식, 8자리 16진수. 예: "00FF0000")
207
+ * @param opts.border 테두리 위치 배열 (예: ["left", "right", "top", "bottom"])
208
+ * @param opts.horizontalAlign 가로 정렬 ("left", "center", "right")
209
+ * @param opts.verticalAlign 세로 정렬 ("top", "center", "bottom")
210
+ * @param opts.numberFormat 숫자 형식 ("number", "DateOnly", "DateTime", "Time", "string")
211
+ */
212
+ async setStyle(opts) {
213
+ const style = {};
214
+ if (opts.background != null) {
215
+ if (!/^[0-9A-F]{8}$/i.test(opts.background)) {
216
+ throw new Error("잘못된 색상 형식입니다. (형식: 00000000: alpha(반전)+rgb)");
217
+ }
218
+ style.background = opts.background;
128
219
  }
129
- numFmt = ExcelUtils.convertNumFmtIdToName(numFmtIdNum);
130
- }
131
- if (numFmt === "number") {
132
- return parseFloat(cellVal);
133
- } else if (numFmt === "string") {
134
- return cellVal;
135
- } else {
136
- const dateNum = num.parseFloat(cellVal);
137
- if (dateNum == null) {
138
- throw new Error(
139
- `[${ExcelUtils.stringifyAddr(this.addr)}] Failed to parse date number: ${cellVal}`
140
- );
220
+ if (opts.border != null) {
221
+ style.border = opts.border;
141
222
  }
142
- const tick = ExcelUtils.convertNumberToTimeTick(dateNum);
143
- if (numFmt === "DateOnly") {
144
- return new DateOnly(tick);
145
- } else if (numFmt === "DateTime") {
146
- return new DateTime(tick);
147
- } else {
148
- return new Time(tick);
223
+ if (opts.horizontalAlign != null) {
224
+ style.horizontalAlign = opts.horizontalAlign;
149
225
  }
150
- }
226
+ if (opts.verticalAlign != null) {
227
+ style.verticalAlign = opts.verticalAlign;
228
+ }
229
+ if (opts.numberFormat != null) {
230
+ style.numFmtId = ExcelUtils.convertNumFmtNameToId(opts.numberFormat).toString();
231
+ }
232
+ await this._setStyleInternal(style);
151
233
  }
152
- }
153
- //#endregion
154
- //#region Merge Methods
155
- /**
156
- * Merge cells from current cell to the specified end coordinates
157
- * @param r End row index of merge (0-based)
158
- * @param c End column index of merge (0-based)
159
- * @example
160
- * // Called from cell A1, merges range A1:C3 (3 rows x 3 columns)
161
- * await ws.cell(0, 0).merge(2, 2);
162
- */
163
- async merge(r, c) {
164
- const wsData = await this._getWsData();
165
- wsData.setMergeCells(this.addr, { r, c });
166
- }
167
- //#endregion
168
- //#region Style Methods
169
- /** Return cell style ID */
170
- async getStyleId() {
171
- const wsData = await this._getWsData();
172
- return wsData.getCellStyleId(this.addr);
173
- }
174
- /** Set cell style ID */
175
- async setStyleId(styleId) {
176
- const wsData = await this._getWsData();
177
- wsData.setCellStyleId(this.addr, styleId);
178
- }
179
- /**
180
- * Set cell style
181
- * @param opts Style options
182
- * @param opts.background Background color (ARGB format, 8-digit hex. e.g. "00FF0000")
183
- * @param opts.border Border position array (e.g. ["left", "right", "top", "bottom"])
184
- * @param opts.horizontalAlign Horizontal alignment ("left", "center", "right")
185
- * @param opts.verticalAlign Vertical alignment ("top", "center", "bottom")
186
- * @param opts.numberFormat Number format ("number", "DateOnly", "DateTime", "Time", "string")
187
- */
188
- async setStyle(opts) {
189
- const style = {};
190
- if (opts.background != null) {
191
- if (!/^[0-9A-F]{8}$/i.test(opts.background)) {
192
- throw new Error("Invalid color format. (Format: 00000000: alpha(reversed)+rgb)");
193
- }
194
- style.background = opts.background;
234
+ //#endregion
235
+ //#region Private Methods
236
+ async _deleteCell(addr) {
237
+ const wsData = await this._getWsData();
238
+ wsData.deleteCell(addr);
195
239
  }
196
- if (opts.border != null) {
197
- style.border = opts.border;
240
+ async _getWsData() {
241
+ return (await this._zipCache.get(`xl/worksheets/${this._targetFileName}`));
198
242
  }
199
- if (opts.horizontalAlign != null) {
200
- style.horizontalAlign = opts.horizontalAlign;
243
+ async _setStyleInternal(style) {
244
+ const wsData = await this._getWsData();
245
+ const styleData = await this._getOrCreateStyleData();
246
+ let styleId = wsData.getCellStyleId(this.addr);
247
+ if (styleId == null) {
248
+ styleId = styleData.add(style);
249
+ }
250
+ else {
251
+ styleId = styleData.addWithClone(styleId, style);
252
+ }
253
+ wsData.setCellStyleId(this.addr, styleId);
201
254
  }
202
- if (opts.verticalAlign != null) {
203
- style.verticalAlign = opts.verticalAlign;
255
+ async _getTypeData() {
256
+ return (await this._zipCache.get("[Content_Types].xml"));
204
257
  }
205
- if (opts.numberFormat != null) {
206
- style.numFmtId = ExcelUtils.convertNumFmtNameToId(opts.numberFormat).toString();
258
+ async _getSsData() {
259
+ return (await this._zipCache.get("xl/sharedStrings.xml"));
207
260
  }
208
- await this._setStyleInternal(style);
209
- }
210
- //#endregion
211
- //#region Private Methods
212
- async _deleteCell(addr) {
213
- const wsData = await this._getWsData();
214
- wsData.deleteCell(addr);
215
- }
216
- async _getWsData() {
217
- return await this._zipCache.get(`xl/worksheets/${this._targetFileName}`);
218
- }
219
- async _setStyleInternal(style) {
220
- const wsData = await this._getWsData();
221
- const styleData = await this._getOrCreateStyleData();
222
- let styleId = wsData.getCellStyleId(this.addr);
223
- if (styleId == null) {
224
- styleId = styleData.add(style);
225
- } else {
226
- styleId = styleData.addWithClone(styleId, style);
261
+ async _getWbRelData() {
262
+ return (await this._zipCache.get("xl/_rels/workbook.xml.rels"));
227
263
  }
228
- wsData.setCellStyleId(this.addr, styleId);
229
- }
230
- async _getTypeData() {
231
- return await this._zipCache.get("[Content_Types].xml");
232
- }
233
- async _getSsData() {
234
- return await this._zipCache.get("xl/sharedStrings.xml");
235
- }
236
- async _getWbRelData() {
237
- return await this._zipCache.get("xl/_rels/workbook.xml.rels");
238
- }
239
- async _getStyleData() {
240
- return await this._zipCache.get("xl/styles.xml");
241
- }
242
- async _getOrCreateSsData() {
243
- let ssData = await this._getSsData();
244
- if (ssData == null) {
245
- ssData = new ExcelXmlSharedStringClass();
246
- this._zipCache.set("xl/sharedStrings.xml", ssData);
247
- const typeData = await this._getTypeData();
248
- typeData.add(
249
- "/xl/sharedStrings.xml",
250
- "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml"
251
- );
252
- const wbRelData = await this._getWbRelData();
253
- wbRelData.add(
254
- "sharedStrings.xml",
255
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings"
256
- );
264
+ async _getStyleData() {
265
+ return (await this._zipCache.get("xl/styles.xml"));
257
266
  }
258
- return ssData;
259
- }
260
- async _getOrCreateStyleData() {
261
- let styleData = await this._getStyleData();
262
- if (styleData == null) {
263
- styleData = new ExcelXmlStyleClass();
264
- this._zipCache.set("xl/styles.xml", styleData);
265
- const typeData = await this._getTypeData();
266
- typeData.add(
267
- "/xl/styles.xml",
268
- "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"
269
- );
270
- const wbRelData = await this._getWbRelData();
271
- wbRelData.add(
272
- "styles.xml",
273
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles"
274
- );
267
+ async _getOrCreateSsData() {
268
+ let ssData = await this._getSsData();
269
+ if (ssData == null) {
270
+ ssData = new ExcelXmlSharedStringClass();
271
+ this._zipCache.set("xl/sharedStrings.xml", ssData);
272
+ const typeData = await this._getTypeData();
273
+ typeData.add("/xl/sharedStrings.xml", "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml");
274
+ const wbRelData = await this._getWbRelData();
275
+ wbRelData.add("sharedStrings.xml", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings");
276
+ }
277
+ return ssData;
278
+ }
279
+ async _getOrCreateStyleData() {
280
+ let styleData = await this._getStyleData();
281
+ if (styleData == null) {
282
+ styleData = new ExcelXmlStyleClass();
283
+ this._zipCache.set("xl/styles.xml", styleData);
284
+ const typeData = await this._getTypeData();
285
+ typeData.add("/xl/styles.xml", "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml");
286
+ const wbRelData = await this._getWbRelData();
287
+ wbRelData.add("styles.xml", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles");
288
+ }
289
+ return styleData;
275
290
  }
276
- return styleData;
277
- }
278
- //#endregion
279
291
  }
280
- export {
281
- ExcelCell
282
- };
283
- //# sourceMappingURL=excel-cell.js.map
292
+ //# sourceMappingURL=excel-cell.js.map