@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.
- 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 +2 -2
- package/dist/xml/excel-xml-workbook.js +87 -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/package.json +5 -7
- 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 +11 -11
- package/src/xml/excel-xml-unknown.ts +2 -2
- package/src/xml/excel-xml-workbook.ts +5 -5
- package/src/xml/excel-xml-worksheet.ts +43 -43
- package/README.md +0 -119
- package/docs/core-classes.md +0 -541
- package/docs/types.md +0 -297
- package/docs/utilities.md +0 -128
- package/docs/wrapper.md +0 -100
- 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
|
@@ -16,8 +16,8 @@ interface RowInfo {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
19
|
+
* xl/worksheets/sheet*.xml 파일을 관리하는 클래스.
|
|
20
|
+
* 셀 데이터, 병합, 열 너비, 행 높이 등을 처리한다.
|
|
21
21
|
*/
|
|
22
22
|
export class ExcelXmlWorksheet implements ExcelXml {
|
|
23
23
|
data: ExcelXmlWorksheetData;
|
|
@@ -131,21 +131,21 @@ export class ExcelXmlWorksheet implements ExcelXml {
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
deleteCell(addr: { r: number; c: number }): void {
|
|
134
|
-
//
|
|
134
|
+
// 행이 존재하지 않으면 아무 작업도 하지 않음
|
|
135
135
|
const rowInfo = this._dataMap.get(addr.r);
|
|
136
136
|
if (rowInfo == null) return;
|
|
137
137
|
|
|
138
|
-
//
|
|
138
|
+
// 셀이 존재하지 않으면 아무 작업도 하지 않음
|
|
139
139
|
const cellData = rowInfo.cellMap.get(addr.c);
|
|
140
140
|
if (cellData == null) return;
|
|
141
141
|
|
|
142
|
-
//
|
|
142
|
+
// 셀 삭제
|
|
143
143
|
const cellsData = rowInfo.data.c!;
|
|
144
144
|
const cellIndex = cellsData.indexOf(cellData);
|
|
145
145
|
if (cellIndex !== -1) cellsData.splice(cellIndex, 1);
|
|
146
146
|
rowInfo.cellMap.delete(addr.c);
|
|
147
147
|
|
|
148
|
-
//
|
|
148
|
+
// 마지막 셀이었으면 행도 삭제
|
|
149
149
|
if (rowInfo.cellMap.size === 0) {
|
|
150
150
|
this._deleteRow(addr.r);
|
|
151
151
|
}
|
|
@@ -161,7 +161,7 @@ export class ExcelXmlWorksheet implements ExcelXml {
|
|
|
161
161
|
|
|
162
162
|
const newRange = { s: startAddr, e: endAddr };
|
|
163
163
|
|
|
164
|
-
//
|
|
164
|
+
// 병합 겹침 검사
|
|
165
165
|
const existingMergeCells = mergeCells[0].mergeCell;
|
|
166
166
|
for (const mergeCell of existingMergeCells) {
|
|
167
167
|
const existingRange = ExcelUtils.parseRangeAddr(mergeCell.$.ref);
|
|
@@ -173,7 +173,7 @@ export class ExcelXmlWorksheet implements ExcelXml {
|
|
|
173
173
|
newRange.e.c >= existingRange.s.c
|
|
174
174
|
) {
|
|
175
175
|
throw new Error(
|
|
176
|
-
|
|
176
|
+
`셀 병합이 기존 병합 범위와 겹칩니다 (${mergeCell.$.ref}): ${ExcelUtils.stringifyRangeAddr(newRange)}`,
|
|
177
177
|
);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
@@ -181,7 +181,7 @@ export class ExcelXmlWorksheet implements ExcelXml {
|
|
|
181
181
|
mergeCells[0].mergeCell.push({ $: { ref: ExcelUtils.stringifyRangeAddr(newRange) } });
|
|
182
182
|
mergeCells[0].$.count = mergeCells[0].mergeCell.length.toString();
|
|
183
183
|
|
|
184
|
-
//
|
|
184
|
+
// 시작 셀을 제외한 모든 셀 삭제
|
|
185
185
|
for (let r = startAddr.r; r <= endAddr.r; r++) {
|
|
186
186
|
for (let c = startAddr.c; c <= endAddr.c; c++) {
|
|
187
187
|
const currentAddr = { r, c };
|
|
@@ -240,23 +240,23 @@ export class ExcelXmlWorksheet implements ExcelXml {
|
|
|
240
240
|
}
|
|
241
241
|
|
|
242
242
|
/**
|
|
243
|
-
*
|
|
243
|
+
* 특정 열의 너비를 설정한다.
|
|
244
244
|
*
|
|
245
245
|
* @internal
|
|
246
|
-
*
|
|
246
|
+
* 외부에서는 ExcelCol.setWidth()를 사용할 것.
|
|
247
247
|
*
|
|
248
|
-
* @param colIndex
|
|
249
|
-
* @param width
|
|
248
|
+
* @param colIndex 열 인덱스 (1 기반, 문자열)
|
|
249
|
+
* @param width 설정할 너비
|
|
250
250
|
*/
|
|
251
251
|
setColWidth(colIndex: string, width: string): void {
|
|
252
252
|
const colIndexNumber = num.parseInt(colIndex);
|
|
253
253
|
if (colIndexNumber == null) {
|
|
254
|
-
throw new Error(
|
|
254
|
+
throw new Error(`잘못된 열 인덱스: ${colIndex}`);
|
|
255
255
|
}
|
|
256
256
|
|
|
257
257
|
const cols = this.data.worksheet.cols?.[0];
|
|
258
258
|
|
|
259
|
-
//
|
|
259
|
+
// 대상 열을 포함하는 기존 범위 찾기
|
|
260
260
|
const col = cols
|
|
261
261
|
? cols.col.single(
|
|
262
262
|
(item) =>
|
|
@@ -267,20 +267,20 @@ export class ExcelXmlWorksheet implements ExcelXml {
|
|
|
267
267
|
|
|
268
268
|
if (col != null && cols != null) {
|
|
269
269
|
if (col.$.min === col.$.max) {
|
|
270
|
-
//
|
|
270
|
+
// 단일 열 범위: 해당 열의 속성만 갱신
|
|
271
271
|
col.$.bestFit = "1";
|
|
272
272
|
col.$.customWidth = "1";
|
|
273
273
|
col.$.width = width;
|
|
274
274
|
} else {
|
|
275
|
-
//
|
|
276
|
-
//
|
|
275
|
+
// 다중 열 범위: 범위를 분할하고 대상 열에만 새 너비 적용
|
|
276
|
+
// 예: 기존 [1~5, width=10], 대상=3, 새 너비=20
|
|
277
277
|
// -> [1~2, width=10], [3, width=20], [4~5, width=10]
|
|
278
278
|
const minNumber = num.parseInt(col.$.min) ?? 0;
|
|
279
279
|
const maxNumber = num.parseInt(col.$.max) ?? 0;
|
|
280
280
|
|
|
281
281
|
let insertIndex = cols.col.indexOf(col);
|
|
282
282
|
|
|
283
|
-
//
|
|
283
|
+
// 앞쪽 범위 생성 (min ~ colIndex-1): 원래 속성 유지
|
|
284
284
|
if (minNumber < colIndexNumber) {
|
|
285
285
|
cols.col.splice(insertIndex, 0, {
|
|
286
286
|
$: {
|
|
@@ -292,7 +292,7 @@ export class ExcelXmlWorksheet implements ExcelXml {
|
|
|
292
292
|
insertIndex++;
|
|
293
293
|
}
|
|
294
294
|
|
|
295
|
-
//
|
|
295
|
+
// 대상 열 생성 (colIndex): 새 너비 적용
|
|
296
296
|
cols.col.splice(insertIndex, 0, {
|
|
297
297
|
$: {
|
|
298
298
|
min: colIndex,
|
|
@@ -304,7 +304,7 @@ export class ExcelXmlWorksheet implements ExcelXml {
|
|
|
304
304
|
});
|
|
305
305
|
insertIndex++;
|
|
306
306
|
|
|
307
|
-
//
|
|
307
|
+
// 뒤쪽 범위 생성 (colIndex+1 ~ max): 원래 속성 유지
|
|
308
308
|
if (maxNumber > colIndexNumber) {
|
|
309
309
|
cols.col.splice(insertIndex, 0, {
|
|
310
310
|
$: {
|
|
@@ -315,12 +315,12 @@ export class ExcelXmlWorksheet implements ExcelXml {
|
|
|
315
315
|
});
|
|
316
316
|
}
|
|
317
317
|
|
|
318
|
-
//
|
|
318
|
+
// 원래 범위 삭제
|
|
319
319
|
const colIndex2 = cols.col.indexOf(col);
|
|
320
320
|
if (colIndex2 !== -1) cols.col.splice(colIndex2, 1);
|
|
321
321
|
}
|
|
322
322
|
} else {
|
|
323
|
-
//
|
|
323
|
+
// 기존 범위 없음: 새 범위 생성
|
|
324
324
|
this.data.worksheet.cols = this.data.worksheet.cols ?? [{ col: [] }];
|
|
325
325
|
this.data.worksheet.cols[0].col.push({
|
|
326
326
|
$: {
|
|
@@ -372,17 +372,17 @@ export class ExcelXmlWorksheet implements ExcelXml {
|
|
|
372
372
|
}
|
|
373
373
|
|
|
374
374
|
copyRow(sourceR: number, targetR: number, options?: { skipMerge?: boolean }): void {
|
|
375
|
-
//
|
|
375
|
+
// 원본 행 데이터 복제
|
|
376
376
|
const sourceRowInfo = this._dataMap.get(sourceR);
|
|
377
377
|
|
|
378
378
|
if (sourceRowInfo != null) {
|
|
379
|
-
//
|
|
379
|
+
// 행 데이터 복제
|
|
380
380
|
const newRowData: ExcelRowData = obj.clone(sourceRowInfo.data);
|
|
381
381
|
|
|
382
|
-
//
|
|
382
|
+
// 행 주소 갱신
|
|
383
383
|
newRowData.$.r = ExcelUtils.stringifyRowAddr(targetR);
|
|
384
384
|
|
|
385
|
-
//
|
|
385
|
+
// 각 셀 주소 갱신
|
|
386
386
|
if (newRowData.c != null) {
|
|
387
387
|
for (const cellData of newRowData.c) {
|
|
388
388
|
const colAddr = ExcelUtils.parseColAddr(cellData.$.r);
|
|
@@ -395,26 +395,26 @@ export class ExcelXmlWorksheet implements ExcelXml {
|
|
|
395
395
|
this._deleteRow(targetR);
|
|
396
396
|
}
|
|
397
397
|
|
|
398
|
-
//
|
|
398
|
+
// skipMerge 옵션이 true이면 병합 처리 건너뛰기
|
|
399
399
|
if (options?.skipMerge === true) {
|
|
400
400
|
return;
|
|
401
401
|
}
|
|
402
402
|
|
|
403
403
|
const allMergeCells = this.getMergeCells();
|
|
404
404
|
|
|
405
|
-
//
|
|
405
|
+
// 원본 행의 병합 셀 정보를 먼저 복사하여 저장
|
|
406
406
|
const sourceMergeCells = allMergeCells
|
|
407
407
|
.filter((mc) => mc.s.r <= sourceR && mc.e.r >= sourceR)
|
|
408
408
|
.map((mc) => ({ s: { ...mc.s }, e: { ...mc.e } }));
|
|
409
409
|
|
|
410
|
-
//
|
|
410
|
+
// 대상 행의 기존 병합 셀 제거
|
|
411
411
|
for (const mergeCell of allMergeCells) {
|
|
412
412
|
if (mergeCell.s.r <= targetR && mergeCell.e.r >= targetR) {
|
|
413
413
|
this.removeMergeCells(mergeCell.s, mergeCell.e);
|
|
414
414
|
}
|
|
415
415
|
}
|
|
416
416
|
|
|
417
|
-
//
|
|
417
|
+
// 저장된 원본 병합 정보를 대상에 복사
|
|
418
418
|
for (const mergeCell of sourceMergeCells) {
|
|
419
419
|
const rowDiff = targetR - sourceR;
|
|
420
420
|
const newStartAddr = { r: mergeCell.s.r + rowDiff, c: mergeCell.s.c };
|
|
@@ -438,7 +438,7 @@ export class ExcelXmlWorksheet implements ExcelXml {
|
|
|
438
438
|
cleanup(): void {
|
|
439
439
|
const result = {} as ExcelXmlWorksheetData["worksheet"];
|
|
440
440
|
|
|
441
|
-
//
|
|
441
|
+
// 정렬 순서 ("sheetData" 기준, 나머지는 원래 위치 유지)
|
|
442
442
|
|
|
443
443
|
for (const key of Object.keys(this.data.worksheet)) {
|
|
444
444
|
if (key === "mergeCells") continue;
|
|
@@ -468,11 +468,11 @@ export class ExcelXmlWorksheet implements ExcelXml {
|
|
|
468
468
|
}
|
|
469
469
|
}
|
|
470
470
|
|
|
471
|
-
//
|
|
471
|
+
// 행 정렬
|
|
472
472
|
const rowsData = (result.sheetData[0].row = result.sheetData[0].row ?? []);
|
|
473
473
|
rowsData.sort((a, b) => (num.parseInt(a.$.r) ?? 0) - (num.parseInt(b.$.r) ?? 0));
|
|
474
474
|
|
|
475
|
-
//
|
|
475
|
+
// 셀 정렬
|
|
476
476
|
for (const rowData of rowsData) {
|
|
477
477
|
const cellsData = rowData.c;
|
|
478
478
|
if (cellsData == null) continue;
|
|
@@ -481,7 +481,7 @@ export class ExcelXmlWorksheet implements ExcelXml {
|
|
|
481
481
|
);
|
|
482
482
|
}
|
|
483
483
|
|
|
484
|
-
//
|
|
484
|
+
// dimension 값 적용
|
|
485
485
|
if (result.dimension != null) {
|
|
486
486
|
result.dimension[0].$.ref = ExcelUtils.stringifyRangeAddr(this.range);
|
|
487
487
|
} else {
|
|
@@ -496,10 +496,10 @@ export class ExcelXmlWorksheet implements ExcelXml {
|
|
|
496
496
|
}
|
|
497
497
|
|
|
498
498
|
private _getOrCreateCellData(addr: { r: number; c: number }): ExcelCellData {
|
|
499
|
-
//
|
|
499
|
+
// 행이 존재하지 않으면 생성
|
|
500
500
|
const rowInfo = this._getOrCreateRowInfo(addr.r);
|
|
501
501
|
|
|
502
|
-
//
|
|
502
|
+
// 셀이 존재하지 않으면 생성
|
|
503
503
|
let cellData = rowInfo.cellMap.get(addr.c);
|
|
504
504
|
if (cellData === undefined) {
|
|
505
505
|
rowInfo.data.c = rowInfo.data.c ?? [];
|
|
@@ -523,11 +523,11 @@ export class ExcelXmlWorksheet implements ExcelXml {
|
|
|
523
523
|
private _replaceRowData(r: number, rowData: ExcelRowData): RowInfo {
|
|
524
524
|
this._deleteRow(r);
|
|
525
525
|
|
|
526
|
-
//
|
|
526
|
+
// 시트에 쓰기
|
|
527
527
|
this.data.worksheet.sheetData[0].row = this.data.worksheet.sheetData[0].row ?? [];
|
|
528
528
|
this.data.worksheet.sheetData[0].row.push(rowData);
|
|
529
529
|
|
|
530
|
-
//
|
|
530
|
+
// 캐시에 쓰기
|
|
531
531
|
const rowInfo = {
|
|
532
532
|
data: rowData,
|
|
533
533
|
cellMap: (rowData.c ?? []).toMap(
|
|
@@ -543,14 +543,14 @@ export class ExcelXmlWorksheet implements ExcelXml {
|
|
|
543
543
|
private _replaceCellData(addr: { r: number; c: number }, cellData: ExcelCellData): void {
|
|
544
544
|
this.deleteCell(addr);
|
|
545
545
|
|
|
546
|
-
//
|
|
546
|
+
// 행
|
|
547
547
|
const targetRowInfo = this._getOrCreateRowInfo(addr.r);
|
|
548
548
|
|
|
549
|
-
//
|
|
549
|
+
// 시트에 쓰기
|
|
550
550
|
targetRowInfo.data.c = targetRowInfo.data.c ?? [];
|
|
551
551
|
targetRowInfo.data.c.push(cellData);
|
|
552
552
|
|
|
553
|
-
//
|
|
553
|
+
// 캐시에 쓰기
|
|
554
554
|
targetRowInfo.cellMap.set(addr.c, cellData);
|
|
555
555
|
}
|
|
556
556
|
|
|
@@ -565,7 +565,7 @@ export class ExcelXmlWorksheet implements ExcelXml {
|
|
|
565
565
|
}
|
|
566
566
|
this._dataMap.delete(r);
|
|
567
567
|
|
|
568
|
-
//
|
|
568
|
+
// 행이 남아있지 않으면 XML에서 행 섹션 삭제
|
|
569
569
|
if (this.data.worksheet.sheetData[0].row?.length === 0) {
|
|
570
570
|
delete this.data.worksheet.sheetData[0].row;
|
|
571
571
|
}
|
package/README.md
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
# @simplysm/excel
|
|
2
|
-
|
|
3
|
-
Excel file processing library. Platform-neutral (works in both browser and Node.js).
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @simplysm/excel
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## API Overview
|
|
12
|
-
|
|
13
|
-
### Types
|
|
14
|
-
|
|
15
|
-
| API | Type | Description |
|
|
16
|
-
|-----|------|-------------|
|
|
17
|
-
| `ExcelValueType` | type | Union of supported cell value types (`number`, `string`, `DateOnly`, `DateTime`, `Time`, `boolean`, `undefined`) |
|
|
18
|
-
| `ExcelNumberFormat` | type | Number format name (`"number"`, `"string"`, `"DateOnly"`, `"DateTime"`, `"Time"`) |
|
|
19
|
-
| `ExcelCellType` | type | Cell type identifier (`"s"`, `"b"`, `"str"`, `"n"`, `"inlineStr"`, `"e"`) |
|
|
20
|
-
| `ExcelAddressPoint` | interface | Cell coordinate (`r`, `c`, 0-based) |
|
|
21
|
-
| `ExcelAddressRangePoint` | interface | Range of cell coordinates (`s`, `e`) |
|
|
22
|
-
| `ExcelBorderPosition` | type | Border position (`"left"`, `"right"`, `"top"`, `"bottom"`) |
|
|
23
|
-
| `ExcelHorizontalAlign` | type | Horizontal alignment (`"center"`, `"left"`, `"right"`) |
|
|
24
|
-
| `ExcelVerticalAlign` | type | Vertical alignment (`"center"`, `"top"`, `"bottom"`) |
|
|
25
|
-
| `ExcelStyleOptions` | interface | Cell style options (`background`, `border`, `horizontalAlign`, `verticalAlign`, `numberFormat`) |
|
|
26
|
-
| `ExcelXml` | interface | Excel XML interface (`data`, `cleanup()`) |
|
|
27
|
-
| `ExcelXmlContentTypeData` | interface | Content type XML data |
|
|
28
|
-
| `ExcelXmlRelationshipData` | interface | Relationship XML data |
|
|
29
|
-
| `ExcelRelationshipData` | interface | Single relationship data |
|
|
30
|
-
| `ExcelXmlWorkbookData` | interface | Workbook XML data |
|
|
31
|
-
| `ExcelXmlWorksheetData` | interface | Worksheet XML data |
|
|
32
|
-
| `ExcelRowData` | interface | Row XML data |
|
|
33
|
-
| `ExcelCellData` | interface | Cell XML data |
|
|
34
|
-
| `ExcelXmlDrawingData` | interface | Drawing XML data |
|
|
35
|
-
| `ExcelXmlSharedStringData` | interface | Shared strings XML data |
|
|
36
|
-
| `ExcelXmlSharedStringDataSi` | type | Shared string item |
|
|
37
|
-
| `ExcelXmlSharedStringDataText` | type | Shared string text |
|
|
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
|
|
76
|
-
|
|
77
|
-
```typescript
|
|
78
|
-
import { ExcelWorkbook } from "@simplysm/excel";
|
|
79
|
-
|
|
80
|
-
await using wb = new ExcelWorkbook();
|
|
81
|
-
const ws = await wb.addWorksheet("Sheet1");
|
|
82
|
-
await ws.cell(0, 0).setValue("Name");
|
|
83
|
-
await ws.cell(0, 1).setValue("Age");
|
|
84
|
-
await ws.cell(1, 0).setValue("Alice");
|
|
85
|
-
await ws.cell(1, 1).setValue(30);
|
|
86
|
-
const bytes = await wb.toBytes();
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
### Read an existing workbook
|
|
90
|
-
|
|
91
|
-
```typescript
|
|
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();
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
### Type-safe read/write with Zod schema
|
|
99
|
-
|
|
100
|
-
```typescript
|
|
101
|
-
import { z } from "zod";
|
|
102
|
-
import { ExcelWrapper } from "@simplysm/excel";
|
|
103
|
-
|
|
104
|
-
const schema = z.object({
|
|
105
|
-
name: z.string().describe("Name"),
|
|
106
|
-
age: z.number().describe("Age"),
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
const wrapper = new ExcelWrapper(schema);
|
|
110
|
-
|
|
111
|
-
// Read
|
|
112
|
-
const records = await wrapper.read(fileBytes);
|
|
113
|
-
|
|
114
|
-
// Write
|
|
115
|
-
await using wb = await wrapper.write("Sheet1", [
|
|
116
|
-
{ name: "Alice", age: 30 },
|
|
117
|
-
]);
|
|
118
|
-
const bytes = await wb.toBytes();
|
|
119
|
-
```
|