:fix: handle rowSpan by convert between the virtual column index and the root index

This commit is contained in:
wangfengming
2020-06-22 12:25:51 +08:00
parent 11e54b3e2c
commit 8c9b61b37a
4 changed files with 209 additions and 13 deletions

View File

@ -83,16 +83,18 @@ export class Table extends XmlComponent {
// Row Span has to be added in this method and not the constructor because it needs to know information about the column which happens after Table Cell construction
// Row Span of 1 will crash word as it will add RESTART and not a corresponding CONTINUE
if (cell.options.rowSpan && cell.options.rowSpan > 1) {
const columnIndex = row.rootIndexToColumnIndex(cellIndex + 1);
const startRowIndex = rowIndex + 1;
const endRowIndex = rowIndex + (cell.options.rowSpan - 1);
for (let i = rowIndex + 1; i <= endRowIndex; i++) {
rows[i].addCellToIndex(
for (let i = startRowIndex; i <= endRowIndex; i++) {
rows[i].addCellToColumnIndex(
new TableCell({
columnSpan: cell.options.columnSpan,
borders: cell.options.borders,
children: [],
verticalMerge: VerticalMergeType.CONTINUE,
}),
cellIndex,
columnIndex,
);
}
}