diff --git a/ppstructure/recovery/table_process.py b/ppstructure/recovery/table_process.py index 086461ca61..f5e01e6481 100644 --- a/ppstructure/recovery/table_process.py +++ b/ppstructure/recovery/table_process.py @@ -249,6 +249,9 @@ def handle_table(self, html, doc): table = doc.add_table(len(rows), cols_len) table.style = doc.styles["Table Grid"] + num_rows = len(table.rows) + num_cols = len(table.columns) + cell_row = 0 for index, row in enumerate(rows): cols = get_table_columns(row) @@ -261,6 +264,9 @@ def handle_table(self, html, doc): if col.name == "th": cell_html = "%s" % cell_html + if cell_row >= num_rows or cell_col >= num_cols: + continue + docx_cell = table.cell(cell_row, cell_col) while docx_cell.text != "": # Skip the merged cell