In my Excel spreadsheet I need to enter excel formula on a bottom that will summarize values. Number of rows can be different. But not columns.
So in cell B10 should be =SUM(B2:B7)
in cell C10 should be =SUM(C2:C7)
in cell D10 should be =SUM(D2:D7)
and so on...
import openpyxl
wb = openpyxl.load_workbook("C:\\Users\\my\\Test.xlsx")
# open sheet to write into.
ws = wb.active
#Get the number of rows to make it easier to add our Excel formulas a little later
last_row = ws.max_row
for col in ws.iter_cols(min_row=last_row+2, min_col=14, max_row=last_row+2, max_col=28):
for cell in col:
cell.value = '=SUM(A2:B2)' # hou to make formula dynamic?