Nov-07-2023, 11:11 PM
Hi,
I have a utility running on a Raspberry Pi which is powered from battery and is powered off and on through a 24 hour period to run this utility before a limited number of tasks are performed, then before closing creates log entries into a .xlsx sheet, due to the nature of the setup i have to run the following code to sequentially store the log entries,
"last row" to 101 as the alignment above is in rows 1 thru 100
Is there a way to allow me to still format the .xlsx sheet and keep the REAL last line so the sheet.append(row) still work and possibly does the alignment at the same time? is it possible to add the alignment to the following line for example?
JohnW
I have a utility running on a Raspberry Pi which is powered from battery and is powered off and on through a 24 hour period to run this utility before a limited number of tasks are performed, then before closing creates log entries into a .xlsx sheet, due to the nature of the setup i have to run the following code to sequentially store the log entries,
sheet = wb['Sheet1'] sheet.ins_row = str(len(sheet['A']) + 1 ) print(sheet.ins_row) if (drywet)=="Wet": row = (cdate,ctime,drywet,"N/A","N/A") else: row = (cdate,ctime,drywet,opentime1,valveonoff) sheet.append(row) wb.save(fpath)sheet = wb['Sheet1'] sheet.ins_row = str(len(sheet['A']) + 1 )Then to ensure that the cells are in an orderly format i run the following.
sheet = wb['Sheet1'] rows=range(1,100) columns=range(1,10) for row in rows: for col in columns: sheet.cell(row,col).alignment=Alignment(horizontal='center',vertical='center',wrap_text=True)The very first time i do this the first lines of code work OK but the second time i run it they fail as the code in the second code snippet have reset the
"last row" to 101 as the alignment above is in rows 1 thru 100
Is there a way to allow me to still format the .xlsx sheet and keep the REAL last line so the sheet.append(row) still work and possibly does the alignment at the same time? is it possible to add the alignment to the following line for example?
row = (cdate,ctime,drywet,"N/A","N/A")Thank You
JohnW