2

I am using docxtpl to generate word documents. I am inserting multiple tables to a Word document and wondering how I can change the size of the specific column in the code.

Here is the table in my template.docx:

template table screenshot

The table looks in the report like in the image:

resulting table screenshot

Here is a glance how I insert the table to the docx:

    ## Create panda data frame from the dict
    df_bauwerke = pd.DataFrame.from_dict(outDict['Bauwerke']['Schlüsselbauwerke'], orient='index')
    

    ## Convert panda df to DocxTemplate table format
    table_bauwerke = {
        "bauwerke_col_labels": list(df_bauwerke.columns.values),
        "bauwerke_tbl_contents": [{"cols": rows} for rows in df_bauwerke.values.tolist()]}

    context_to_load.update(table_bauwerke)

I would like to change the width of column 'Jahr' & 'Name' (Name is larger and Jahr is narrower) and the rest stay as they are. Can I influence that in my script?

p_sutherland
  • 471
  • 1
  • 11
  • 21
Nil
  • 201
  • 3
  • 12

0 Answers0