@@ -19,16 +19,16 @@ new TemplateMemory(files: Record<string, Buffer>)
1919
2020---
2121
22- ### 📄 Properties
22+ ## 📄 Properties
2323
2424- ` files: Record<string, Buffer> ` — in-memory map of file contents.
2525- ` destroyed: boolean ` — indicates whether the instance has been destroyed (read-only).
2626
2727---
2828
29- ### 📚 Methods
29+ ## 📚 Methods
3030
31- #### ` copySheet(sourceName: string, newName: string): Promise<void> `
31+ ### ` copySheet(sourceName: string, newName: string): Promise<void> `
3232
3333Creates a copy of an existing worksheet with a new name.
3434
@@ -40,7 +40,7 @@ Creates a copy of an existing worksheet with a new name.
4040
4141---
4242
43- #### ` substitute(sheetName: string, replacements: Record<string, unknown>): Promise<void> `
43+ ### ` substitute(sheetName: string, replacements: Record<string, unknown>): Promise<void> `
4444
4545Replaces placeholders of the form ` ${key} ` with values from the ` replacements ` object. For arrays, use placeholders with key ` ${table:key} ` .
4646
@@ -49,7 +49,7 @@ Replaces placeholders of the form `${key}` with values from the `replacements` o
4949
5050---
5151
52- #### ` insertRows(data: { sheetName: string; startRowNumber?: number; rows: unknown[][] }): Promise<void> `
52+ ### ` insertRows(data: { sheetName: string; startRowNumber?: number; rows: unknown[][] }): Promise<void> `
5353
5454Inserts rows into a specified worksheet.
5555
@@ -63,7 +63,7 @@ Inserts rows into a specified worksheet.
6363
6464---
6565
66- #### ` insertRowsStream(data: { sheetName: string; startRowNumber?: number; rows: AsyncIterable<unknown[]> }): Promise<void> `
66+ ### ` insertRowsStream(data: { sheetName: string; startRowNumber?: number; rows: AsyncIterable<unknown[]> }): Promise<void> `
6767
6868Streams and inserts rows into a worksheet, useful for handling large datasets.
6969
@@ -74,7 +74,7 @@ Streams and inserts rows into a worksheet, useful for handling large datasets.
7474
7575---
7676
77- #### ` save(): Promise<Buffer> `
77+ ### ` save(): Promise<Buffer> `
7878
7979Generates a new Excel file and returns it as a ` Buffer ` .
8080
@@ -85,7 +85,7 @@ Generates a new Excel file and returns it as a `Buffer`.
8585
8686---
8787
88- #### ` set(key: string, content: Buffer): Promise<void> `
88+ ### ` set(key: string, content: Buffer): Promise<void> `
8989
9090Replaces the content of a specific file in the template.
9191
@@ -97,9 +97,39 @@ Replaces the content of a specific file in the template.
9797
9898---
9999
100- ### 💡 Usage Examples
100+ ### ` mergeSheets(data: { additions: { sheetIndexes?: number[]; sheetNames?: string[] }; baseSheetIndex?: number; baseSheetName?: string; gap?: number }): void `
101101
102- #### Create from File and Modify
102+ Merges multiple worksheets into a single base worksheet.
103+
104+ - ` additions ` — defines the sheets to merge:
105+ - ` sheetIndexes ` — array of 1-based sheet indexes to merge.
106+ - ` sheetNames ` — array of sheet names to merge.
107+ - ` baseSheetIndex ` — 1-based index of the base sheet to merge into (optional, default is 1).
108+ - ` baseSheetName ` — name of the base sheet to merge into (optional).
109+ - ` gap ` — number of empty rows to insert between merged sections (default: ` 0 ` ).
110+ - Throws if:
111+ - The instance is destroyed.
112+ - Invalid sheet names or indexes are provided.
113+ - Both ` baseSheetIndex ` and ` baseSheetName ` are undefined.
114+
115+ ---
116+
117+ ### ` removeSheets(data: { sheetNames?: string[]; sheetIndexes?: number[] }): void `
118+
119+ Removes worksheets from the workbook.
120+
121+ - ` sheetNames ` — array of sheet names to remove.
122+ - ` sheetIndexes ` — array of 1-based sheet indexes to remove.
123+ - Throws if:
124+ - The instance is destroyed.
125+ - Sheet names or indexes do not exist.
126+ - Neither ` sheetNames ` nor ` sheetIndexes ` are provided.
127+
128+ ---
129+
130+ ## 💡 Usage Examples
131+
132+ ### Create from File and Modify
103133
104134``` ts
105135const template = await TemplateMemory .from ({
@@ -113,7 +143,7 @@ const modifiedExcel = await template.save();
113143fs .writeFileSync (" output.xlsx" , modifiedExcel );
114144```
115145
116- #### Insert Rows from a Stream
146+ ### Insert Rows from a Stream
117147
118148``` ts
119149async function * generateData() {
@@ -134,7 +164,7 @@ await template.insertRowsStream({
134164fs .writeFileSync (" large-output.xlsx" , await template .save ());
135165```
136166
137- #### Replace Internal File Content
167+ ### Replace Internal File Content
138168
139169``` ts
140170const template = await TemplateMemory .from ({
@@ -150,7 +180,7 @@ await template.set(
150180
151181---
152182
153- ### 🛑 Internal Checks
183+ ## 🛑 Internal Checks
154184
155185Methods perform validation:
156186
0 commit comments