@simplysm/excel 13.0.100 → 14.0.4
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 +66 -78
- package/dist/excel-cell.d.ts +28 -28
- package/dist/excel-cell.d.ts.map +1 -1
- package/dist/excel-cell.js +273 -264
- package/dist/excel-cell.js.map +1 -6
- package/dist/excel-col.d.ts +4 -4
- package/dist/excel-col.d.ts.map +1 -1
- package/dist/excel-col.js +33 -35
- package/dist/excel-col.js.map +1 -6
- package/dist/excel-row.d.ts +3 -3
- package/dist/excel-row.d.ts.map +1 -1
- package/dist/excel-row.js +28 -30
- package/dist/excel-row.js.map +1 -6
- package/dist/excel-workbook.d.ts +23 -23
- package/dist/excel-workbook.d.ts.map +1 -1
- package/dist/excel-workbook.js +151 -125
- package/dist/excel-workbook.js.map +1 -6
- package/dist/excel-worksheet.d.ts +32 -32
- package/dist/excel-worksheet.d.ts.map +1 -1
- package/dist/excel-worksheet.js +281 -253
- package/dist/excel-worksheet.js.map +1 -6
- package/dist/excel-wrapper.d.ts +7 -7
- package/dist/excel-wrapper.d.ts.map +1 -1
- package/dist/excel-wrapper.js +190 -226
- package/dist/excel-wrapper.js.map +1 -6
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -6
- package/dist/types.d.ts +13 -13
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -1
- package/dist/types.js.map +1 -6
- package/dist/utils/excel-utils.d.ts +23 -23
- package/dist/utils/excel-utils.d.ts.map +1 -1
- package/dist/utils/excel-utils.js +183 -151
- package/dist/utils/excel-utils.js.map +1 -6
- package/dist/utils/zip-cache.d.ts +6 -6
- package/dist/utils/zip-cache.js +78 -60
- package/dist/utils/zip-cache.js.map +1 -6
- package/dist/xml/excel-xml-content-type.d.ts +2 -2
- package/dist/xml/excel-xml-content-type.js +55 -53
- package/dist/xml/excel-xml-content-type.js.map +1 -6
- package/dist/xml/excel-xml-drawing.d.ts +2 -2
- package/dist/xml/excel-xml-drawing.js +74 -73
- package/dist/xml/excel-xml-drawing.js.map +1 -6
- package/dist/xml/excel-xml-relationship.d.ts +2 -2
- package/dist/xml/excel-xml-relationship.js +67 -67
- package/dist/xml/excel-xml-relationship.js.map +1 -6
- package/dist/xml/excel-xml-shared-string.d.ts +2 -2
- package/dist/xml/excel-xml-shared-string.js +57 -55
- package/dist/xml/excel-xml-shared-string.js.map +1 -6
- package/dist/xml/excel-xml-style.d.ts +2 -2
- package/dist/xml/excel-xml-style.js +311 -295
- package/dist/xml/excel-xml-style.js.map +1 -6
- package/dist/xml/excel-xml-unknown.d.ts +2 -2
- package/dist/xml/excel-xml-unknown.js +11 -10
- package/dist/xml/excel-xml-unknown.js.map +1 -6
- package/dist/xml/excel-xml-workbook.d.ts +3 -2
- package/dist/xml/excel-xml-workbook.d.ts.map +1 -1
- package/dist/xml/excel-xml-workbook.js +95 -90
- package/dist/xml/excel-xml-workbook.js.map +1 -6
- package/dist/xml/excel-xml-worksheet.d.ts +6 -6
- package/dist/xml/excel-xml-worksheet.js +450 -393
- package/dist/xml/excel-xml-worksheet.js.map +1 -6
- package/docs/core.md +147 -0
- package/docs/types.md +201 -212
- package/docs/wrapper.md +32 -62
- package/package.json +8 -6
- package/src/excel-cell.ts +36 -36
- package/src/excel-col.ts +4 -4
- package/src/excel-row.ts +3 -3
- package/src/excel-workbook.ts +38 -38
- package/src/excel-worksheet.ts +69 -51
- package/src/excel-wrapper.ts +55 -50
- package/src/index.ts +3 -3
- package/src/types.ts +17 -17
- package/src/utils/excel-utils.ts +47 -41
- package/src/utils/zip-cache.ts +6 -6
- package/src/xml/excel-xml-content-type.ts +3 -3
- package/src/xml/excel-xml-drawing.ts +2 -2
- package/src/xml/excel-xml-relationship.ts +3 -3
- package/src/xml/excel-xml-shared-string.ts +2 -2
- package/src/xml/excel-xml-style.ts +13 -13
- package/src/xml/excel-xml-unknown.ts +2 -2
- package/src/xml/excel-xml-workbook.ts +14 -6
- package/src/xml/excel-xml-worksheet.ts +43 -43
- package/docs/core-classes.md +0 -541
- package/docs/utilities.md +0 -128
- package/tests/excel-cell.spec.ts +0 -393
- package/tests/excel-col.spec.ts +0 -81
- package/tests/excel-row.spec.ts +0 -61
- package/tests/excel-workbook.spec.ts +0 -205
- package/tests/excel-worksheet.spec.ts +0 -469
- package/tests/excel-wrapper.spec.ts +0 -273
- package/tests/fixtures/logo.png +0 -0
- package/tests/fixtures//354/264/210/352/270/260/355/231/224.xlsx +0 -0
- package/tests/image-insert.spec.ts +0 -190
- package/tests/utils/excel-utils.spec.ts +0 -198
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# @simplysm/excel
|
|
2
2
|
|
|
3
|
-
Excel file processing library.
|
|
3
|
+
Excel file processing library -- read/write .xlsx files with cell styling, formulas, images, and Zod schema-based typed wrapper.
|
|
4
|
+
|
|
5
|
+
Platform: neutral (Node.js and browser).
|
|
4
6
|
|
|
5
7
|
## Installation
|
|
6
8
|
|
|
@@ -10,92 +12,54 @@ npm install @simplysm/excel
|
|
|
10
12
|
|
|
11
13
|
## API Overview
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
|
16
|
-
|
|
17
|
-
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
| `ExcelXmlStyleData` | interface | Style XML data |
|
|
39
|
-
| `ExcelXmlStyleDataXf` | interface | Cell format definition |
|
|
40
|
-
| `ExcelXmlStyleDataFill` | interface | Fill style definition |
|
|
41
|
-
| `ExcelXmlStyleDataBorder` | interface | Border style definition |
|
|
42
|
-
|
|
43
|
-
-> See [docs/types.md](./docs/types.md) for details.
|
|
44
|
-
|
|
45
|
-
### Utilities
|
|
46
|
-
|
|
47
|
-
| API | Type | Description |
|
|
48
|
-
|-----|------|-------------|
|
|
49
|
-
| `ExcelUtils` | class | Cell address conversion, date/number conversion, number format processing |
|
|
50
|
-
|
|
51
|
-
-> See [docs/utilities.md](./docs/utilities.md) for details.
|
|
52
|
-
|
|
53
|
-
### Core Classes
|
|
54
|
-
|
|
55
|
-
| API | Type | Description |
|
|
56
|
-
|-----|------|-------------|
|
|
57
|
-
| `ExcelWorkbook` | class | Workbook processing with lazy-loading ZIP architecture |
|
|
58
|
-
| `ExcelWorksheet` | class | Worksheet with cell access, copying, data tables, images |
|
|
59
|
-
| `ExcelRow` | class | Row with cell access |
|
|
60
|
-
| `ExcelCol` | class | Column with cell access and width configuration |
|
|
61
|
-
| `ExcelCell` | class | Cell with value, formula, style, and merge operations |
|
|
62
|
-
|
|
63
|
-
-> See [docs/core-classes.md](./docs/core-classes.md) for details.
|
|
64
|
-
|
|
65
|
-
### Wrapper
|
|
66
|
-
|
|
67
|
-
| API | Type | Description |
|
|
68
|
-
|-----|------|-------------|
|
|
69
|
-
| `ExcelWrapper` | class | Zod schema-based type-safe Excel read/write |
|
|
70
|
-
|
|
71
|
-
-> See [docs/wrapper.md](./docs/wrapper.md) for details.
|
|
72
|
-
|
|
73
|
-
## Usage Examples
|
|
74
|
-
|
|
75
|
-
### Create a new workbook
|
|
15
|
+
| Category | Items | Documentation |
|
|
16
|
+
|---|---|---|
|
|
17
|
+
| Types & Utilities | ExcelXmlContentTypeData, ExcelXmlRelationshipData, ExcelRelationshipData, ExcelXmlWorkbookData, ExcelXmlWorksheetData, ExcelRowData, ExcelCellData, ExcelXmlDrawingData, ExcelXmlSharedStringData, ExcelXmlSharedStringDataSi, ExcelXmlSharedStringDataText, ExcelXmlStyleData, ExcelXmlStyleDataXf, ExcelXmlStyleDataFill, ExcelXmlStyleDataBorder, ExcelValueType, ExcelNumberFormat, ExcelCellType, ExcelAddressPoint, ExcelAddressRangePoint, ExcelXml, ExcelBorderPosition, ExcelHorizontalAlign, ExcelVerticalAlign, ExcelStyleOptions, ExcelUtils | [docs/types.md](docs/types.md) |
|
|
18
|
+
| Core Classes | ExcelCell, ExcelRow, ExcelCol, ExcelWorksheet, ExcelWorkbook | [docs/core.md](docs/core.md) |
|
|
19
|
+
| Wrapper | ExcelWrapper | [docs/wrapper.md](docs/wrapper.md) |
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
### Read an existing Excel file
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { ExcelWorkbook } from "@simplysm/excel";
|
|
27
|
+
|
|
28
|
+
await using wb = new ExcelWorkbook(fileBytes);
|
|
29
|
+
const ws = await wb.getWorksheet(0);
|
|
30
|
+
|
|
31
|
+
// Read a single cell
|
|
32
|
+
const value = await ws.cell(0, 0).getValue();
|
|
33
|
+
|
|
34
|
+
// Read as data table (first row = headers)
|
|
35
|
+
const records = await ws.getDataTable();
|
|
36
|
+
// records: Record<string, ExcelValueType>[]
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Create a new Excel file
|
|
76
40
|
|
|
77
41
|
```typescript
|
|
78
42
|
import { ExcelWorkbook } from "@simplysm/excel";
|
|
79
43
|
|
|
80
44
|
await using wb = new ExcelWorkbook();
|
|
81
45
|
const ws = await wb.addWorksheet("Sheet1");
|
|
46
|
+
|
|
82
47
|
await ws.cell(0, 0).setValue("Name");
|
|
83
48
|
await ws.cell(0, 1).setValue("Age");
|
|
84
49
|
await ws.cell(1, 0).setValue("Alice");
|
|
85
50
|
await ws.cell(1, 1).setValue(30);
|
|
86
|
-
const bytes = await wb.toBytes();
|
|
87
|
-
```
|
|
88
51
|
|
|
89
|
-
|
|
52
|
+
// Apply styling
|
|
53
|
+
await ws.cell(0, 0).setStyle({
|
|
54
|
+
background: "00FFFF00",
|
|
55
|
+
border: ["left", "right", "top", "bottom"],
|
|
56
|
+
horizontalAlign: "center",
|
|
57
|
+
});
|
|
90
58
|
|
|
91
|
-
|
|
92
|
-
await using wb = new ExcelWorkbook(fileBytes);
|
|
93
|
-
const ws = await wb.getWorksheet(0);
|
|
94
|
-
const value = await ws.cell(0, 0).getValue();
|
|
95
|
-
const dataTable = await ws.getDataTable();
|
|
59
|
+
const bytes = await wb.toBytes();
|
|
96
60
|
```
|
|
97
61
|
|
|
98
|
-
###
|
|
62
|
+
### Typed read/write with Zod schema
|
|
99
63
|
|
|
100
64
|
```typescript
|
|
101
65
|
import { z } from "zod";
|
|
@@ -104,16 +68,40 @@ import { ExcelWrapper } from "@simplysm/excel";
|
|
|
104
68
|
const schema = z.object({
|
|
105
69
|
name: z.string().describe("Name"),
|
|
106
70
|
age: z.number().describe("Age"),
|
|
71
|
+
active: z.boolean().describe("Active").default(false),
|
|
107
72
|
});
|
|
108
73
|
|
|
109
74
|
const wrapper = new ExcelWrapper(schema);
|
|
110
75
|
|
|
111
|
-
// Read
|
|
76
|
+
// Read with type safety and validation
|
|
112
77
|
const records = await wrapper.read(fileBytes);
|
|
113
78
|
|
|
114
|
-
// Write
|
|
115
|
-
await using wb = await wrapper.write("Sheet1",
|
|
116
|
-
{ name: "Alice", age: 30 },
|
|
117
|
-
]);
|
|
79
|
+
// Write with automatic header/style generation
|
|
80
|
+
await using wb = await wrapper.write("Sheet1", records);
|
|
118
81
|
const bytes = await wb.toBytes();
|
|
119
82
|
```
|
|
83
|
+
|
|
84
|
+
### Insert an image
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
await ws.addImage({
|
|
88
|
+
bytes: imageBytes,
|
|
89
|
+
ext: "png",
|
|
90
|
+
from: { r: 1, c: 1 },
|
|
91
|
+
to: { r: 5, c: 3 },
|
|
92
|
+
});
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Row operations
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
// Copy a row (overwrite)
|
|
99
|
+
await ws.copyRow(0, 5);
|
|
100
|
+
|
|
101
|
+
// Insert-copy a row (shifts existing rows down)
|
|
102
|
+
await ws.insertCopyRow(0, 3);
|
|
103
|
+
|
|
104
|
+
// Freeze header row and set zoom
|
|
105
|
+
await ws.freezeAt({ r: 0 });
|
|
106
|
+
await ws.setZoom(85);
|
|
107
|
+
```
|
package/dist/excel-cell.d.ts
CHANGED
|
@@ -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
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Excel 셀을 나타내는 클래스.
|
|
5
|
+
* 값 읽기/쓰기, 수식, 스타일, 셀 병합 기능을 제공한다.
|
|
6
6
|
*
|
|
7
7
|
* @remarks
|
|
8
|
-
* ##
|
|
8
|
+
* ## 비동기 메서드 설계
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
* -
|
|
12
|
-
* -
|
|
13
|
-
* -
|
|
14
|
-
* -
|
|
10
|
+
* `getValue()`, `setValue()` 등 모든 셀 메서드가 `async`인 이유:
|
|
11
|
+
* - 셀 타입에 필요한 XML만 선택적으로 로드함
|
|
12
|
+
* - 문자열 셀: SharedStrings.xml 로드
|
|
13
|
+
* - 숫자 셀: SharedStrings 로드하지 않음
|
|
14
|
+
* - 스타일 적용 셀: Styles.xml 로드
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
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
|
-
/**
|
|
24
|
+
/** 셀 주소 (0 기반 행/열 인덱스) */
|
|
25
25
|
readonly addr: ExcelAddressPoint;
|
|
26
26
|
constructor(_zipCache: ZipCache, _targetFileName: string, _r: number, _c: number);
|
|
27
|
-
/**
|
|
27
|
+
/** 셀에 수식 설정 (undefined: 수식 제거) */
|
|
28
28
|
setFormula(val: string | undefined): Promise<void>;
|
|
29
|
-
/**
|
|
29
|
+
/** 셀 수식 반환 */
|
|
30
30
|
getFormula(): Promise<string | undefined>;
|
|
31
|
-
/**
|
|
31
|
+
/** 셀 값 설정 (undefined: 셀 삭제) */
|
|
32
32
|
setValue(val: ExcelValueType): Promise<void>;
|
|
33
|
-
/**
|
|
33
|
+
/** 셀 값 반환 */
|
|
34
34
|
getValue(): Promise<ExcelValueType>;
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
37
|
-
* @param r
|
|
38
|
-
* @param c
|
|
36
|
+
* 현재 셀에서 지정된 끝 좌표까지 셀 병합
|
|
37
|
+
* @param r 병합 끝 행 인덱스 (0 기반)
|
|
38
|
+
* @param c 병합 끝 열 인덱스 (0 기반)
|
|
39
39
|
* @example
|
|
40
|
-
* //
|
|
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
|
-
/**
|
|
44
|
+
/** 셀 스타일 ID 반환 */
|
|
45
45
|
getStyleId(): Promise<string | undefined>;
|
|
46
|
-
/**
|
|
46
|
+
/** 셀 스타일 ID 설정 */
|
|
47
47
|
setStyleId(styleId: string | undefined): Promise<void>;
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
50
|
-
* @param opts
|
|
51
|
-
* @param opts.background
|
|
52
|
-
* @param opts.border
|
|
53
|
-
* @param opts.horizontalAlign
|
|
54
|
-
* @param opts.verticalAlign
|
|
55
|
-
* @param opts.numberFormat
|
|
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;
|
package/dist/excel-cell.d.ts.map
CHANGED
|
@@ -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,
|
|
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"}
|