Skip to content

Commit ac9ac33

Browse files
committed
fix(table): insert more than one expand column
1 parent 4ae2c33 commit ac9ac33

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

src/modify/modify-table.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ export class ModifyTable {
2323
this.setRows();
2424
this.setGridCols();
2525

26-
this.sliceRows();
27-
this.sliceCols();
26+
// this.sliceRows();
27+
// this.sliceCols();
2828

2929
return this;
3030
}
@@ -250,14 +250,16 @@ export class ModifyTable {
250250
};
251251

252252
expandColumns = (count: number, colId: number) => {
253-
const rows = this.xml.getElementsByTagName('a:tr');
254-
for (let r = 0; r < rows.length; r++) {
255-
const row = rows.item(r);
256-
const columns = row.getElementsByTagName('a:tc');
257-
const sourceCell = columns.item(colId);
258-
const newCell = this.getExpandCellClone(columns, sourceCell, colId);
259-
260-
XmlHelper.insertAfter(newCell, sourceCell);
253+
for (let cs = 1; cs <= count; cs++) {
254+
const rows = this.xml.getElementsByTagName('a:tr');
255+
for (let r = 0; r < rows.length; r++) {
256+
const row = rows.item(r);
257+
const columns = row.getElementsByTagName('a:tc');
258+
const sourceCell = columns.item(colId);
259+
260+
const newCell = this.getExpandCellClone(columns, sourceCell, colId);
261+
XmlHelper.insertAfter(newCell, sourceCell);
262+
}
261263
}
262264

263265
this.expandGrid(count, colId, 1);

src/types/table-types.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@ export type ModifyTableParams = {
2323
adjustHeight?: boolean;
2424
setHeight?: number;
2525
setWidth?: number;
26-
expand?: {
27-
tag: string;
28-
mode: 'row' | 'column';
29-
count: number;
30-
}[];
26+
expand?: ModifyTableExpand[];
27+
};
28+
29+
export type ModifyTableExpand = {
30+
tag: string;
31+
mode: 'row' | 'column';
32+
count: number;
3133
};
3234

3335
export type TableInfo = {

0 commit comments

Comments
 (0)