Skip to content

Commit 56fc05e

Browse files
authored
fix layout recovery error: list index out of range (#12541)
1 parent 49a388d commit 56fc05e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

ppstructure/recovery/table_process.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,9 @@ def handle_table(self, html, doc):
249249
table = doc.add_table(len(rows), cols_len)
250250
table.style = doc.styles["Table Grid"]
251251

252+
num_rows = len(table.rows)
253+
num_cols = len(table.columns)
254+
252255
cell_row = 0
253256
for index, row in enumerate(rows):
254257
cols = get_table_columns(row)
@@ -261,6 +264,9 @@ def handle_table(self, html, doc):
261264
if col.name == "th":
262265
cell_html = "<b>%s</b>" % cell_html
263266

267+
if cell_row >= num_rows or cell_col >= num_cols:
268+
continue
269+
264270
docx_cell = table.cell(cell_row, cell_col)
265271

266272
while docx_cell.text != "": # Skip the merged cell

0 commit comments

Comments
 (0)