@@ -893,16 +893,16 @@ def _pack_table(
893893
894894 if tbl .layout == "autofit" :
895895 docx_table .autofit = True
896- else :
896+ elif tbl . layout == "fixed" or tbl . column_widths is not None :
897897 # column_widths or layout="fixed" both imply fixed layout
898- if tbl .layout == "fixed" or tbl .column_widths is not None :
899- docx_table .autofit = False
900- if tbl .column_widths is not None :
901- _apply_column_widths (docx_table , tbl .column_widths , num_cols )
898+ docx_table .autofit = False
902899
903900 for row_idx , row in enumerate (filtered_rows ):
904901 _pack_table_row (docx_doc , docx_table .rows [row_idx ], row , default_comment_author ) # ty:ignore[invalid-argument-type] already awaited.
905902
903+ if tbl .layout != "autofit" and tbl .column_widths is not None :
904+ _apply_column_widths (docx_table , tbl .column_widths , num_cols )
905+
906906
907907def _apply_column_widths (
908908 tbl : docx_table .Table ,
@@ -925,8 +925,9 @@ def _apply_column_widths(
925925 f"must match number of columns ({ num_cols } )"
926926 )
927927 raise ValueError (msg )
928- for i , width in enumerate (column_widths ):
929- tbl .columns [i ].width = shared .Twips (width )
928+
929+ for index , width in enumerate (column_widths ):
930+ tbl .columns [index ].width = shared .Twips (width )
930931
931932
932933def _pack_table_row (
0 commit comments