fix layout recovery error: list index out of range (#12541)
parent
49a388db0a
commit
56fc05e604
|
@ -249,6 +249,9 @@ class HtmlToDocx(HTMLParser):
|
|||
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 @@ class HtmlToDocx(HTMLParser):
|
|||
if col.name == "th":
|
||||
cell_html = "<b>%s</b>" % 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
|
||||
|
|
Loading…
Reference in New Issue