from fast_excel_to_bill.bill_doc.docx_builder import DOCFileBuilder from fast_excel_to_bill import config_for_custom_bills from tool_lib import datetime_functions current_month_year= datetime_functions.get_current_month_year_as_str() docx_output_path = config_for_custom_bills.docx_output_dir_path+ r'\bill_{}.docx'.format(current_month_year) def main(): # Get Data which is necessary for the docx data_from_excel = ... burden_date = ... data_from_excel.append(burden_date) # Create a doc file which is based on a docx template builder_obj = DOCFileBuilder(config_for_custom_bills.docx_input_path, docx_output_path) place_holders = config_for_custom_bills.list_of_place_holders for place_holder in place_holders: builder_obj.replace_custom_placeholder_in_doc(place_holder, data_from_excel) builder_obj.replace_dates_string_in_standard_text('03.11.2022') builder_obj.replace_dates_string_in_all_tables('03.11.2022') keys = ['KW', 'Leistung', 'Zeit in Stunden', 'Betrag in Euro'] example_tuple = [(123123, 213123, 12312312, 445235)] key_table = builder_obj.search_table_with_key_columns(keys) builder_obj.replace_rows(key_table, example_tuple) builder_obj.delete_empty_rows_in_table(key_table, 4) builder_obj.document.add_page_break() key_table = builder_obj.search_table_with_key_columns(['KW', 'Leistungsübersicht']) builder_obj.delete_empty_rows_in_table(key_table, 2) data_to_bill_doc = ... # Transform the doc file to a pdf file doc_to_pdf = ... if __name__ == '__main__': main()