diff --git a/src/models.ts b/src/models.ts index 3f50ea52..c2373e04 100644 --- a/src/models.ts +++ b/src/models.ts @@ -93,17 +93,27 @@ export class Table { } getHeadHeight(columns: Column[]) { - return this.head.reduce( - (acc, row) => acc + row.getMaxCellHeight(columns), - 0, - ) + var rowSpan = 1 + return this.head.reduce((acc, row) => { + if(rowSpan === 1){ + rowSpan = row.getMaxRowSpan(columns) + return acc + row.getMaxCellHeight(columns) + } + rowSpan-- + return acc + }, 0) } getFootHeight(columns: Column[]) { - return this.foot.reduce( - (acc, row) => acc + row.getMaxCellHeight(columns), - 0, - ) + var rowSpan = 1 + return this.foot.reduce((acc, row) => { + if(rowSpan === 1){ + rowSpan = row.getMaxRowSpan(columns) + return acc + row.getMaxCellHeight(columns) + } + rowSpan-- + return acc + }, 0) } allRows() { @@ -193,6 +203,13 @@ export class Row { ) } + getMaxRowSpan(columns: Column[]) { + return columns.reduce( + (acc, column) => Math.max(acc, this.cells[column.index]?.rowSpan || 0), + 0, + ) + } + hasRowSpan(columns: Column[]) { return ( columns.filter((column: Column) => {