From ba9b3b4e58f63a299c2ec3bd18e23d6059e9aea7 Mon Sep 17 00:00:00 2001 From: Alexander Golodkov <55749660+alexander1999-hub@users.noreply.github.com> Date: Mon, 5 Aug 2024 17:47:19 +0300 Subject: [PATCH] TLDR-773 docx table bug fix (#480) Co-authored-by: Alexander Golodkov --- dedoc/readers/docx_reader/data_structures/table.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/dedoc/readers/docx_reader/data_structures/table.py b/dedoc/readers/docx_reader/data_structures/table.py index 1f11fdac..a92b1bed 100644 --- a/dedoc/readers/docx_reader/data_structures/table.py +++ b/dedoc/readers/docx_reader/data_structures/table.py @@ -54,11 +54,14 @@ def to_table(self) -> Table: if cell.vMerge: value = cell.vMerge.get("w:val", "continue") if value == "continue": - cell_lines = cell_list[-1][cell_ind].lines - cell_row_list.append(CellWithMeta(lines=cell_lines, colspan=1, rowspan=1, invisible=True)) - last_cell_rowspan = cell_list[rowspan_start_info[cell_ind]][cell_ind] - last_cell_rowspan.rowspan += 1 - cell_list[rowspan_start_info[cell_ind]][cell_ind] = last_cell_rowspan + if cell_ind in rowspan_start_info: + cell_lines = cell_list[-1][cell_ind].lines + cell_row_list.append(CellWithMeta(lines=cell_lines, colspan=1, rowspan=1, invisible=True)) + last_cell_rowspan = cell_list[rowspan_start_info[cell_ind]][cell_ind] + last_cell_rowspan.rowspan += 1 + cell_list[rowspan_start_info[cell_ind]][cell_ind] = last_cell_rowspan + else: + cell_row_list.append(CellWithMeta(lines=cell_lines, colspan=grid_span, rowspan=1, invisible=False)) elif value == "restart": rowspan_start_info[cell_ind] = row_index cell_row_list.append(CellWithMeta(lines=cell_lines, colspan=grid_span, rowspan=1, invisible=False))