0

Morning, I would like that when cells are added, they adjust to the width of the text, any ideas?

def excel():# Writing on a EXCEL FILE
                filename = (f"{myPath}/{day}.{month}.{year}.xlsx")
                try:
                    wb = load_workbook(filename)
                    ws = wb.worksheets[0]  # select first worksheet
                except FileNotFoundError:
                    headers_row = ['Name','Pers. Nummer','Kürse','Funktion','Dienstbeginn','Dienstende','Schitdauer','Bezahlte Zeit','Kommentar']
                    wb = Workbook()
                    ws = wb.active
                    ws.append(headers_row)              
                wb.save(filename)
                ws.append([userfinder,tagesinfo,emptycell,emptycell,emptycell,emptycell,emptycell,emptycell])
                for cols in ws.iter_cols(  ):
                     if cols[-1].value:
                        cols[-1].fill=(PatternFill(fgColor="D5D5D5", fill_type='solid'))
                        cols[-1].border = Border(left=Side(style='thin'),right=Side(style='thin'),top=Side(style='thin'),bottom=Side(style='thin'))                
                wb.save(filename)
                wb.close()
                print(f'{userfinder}-{ivunumber} - {tagesinfo} OK')
            excel()
TUX One
  • 107
  • 3
  • 11

0 Answers0