XLS with formula in more than one cells within a column with Python
Question: After a long day playing with lots of variants I was left with this code:

    
    
    from xlrd import open_workbook
    from xlwt import Workbook, Formula
    from xlutils.copy import copy
    
    rb = open_workbook("test.xls")
    wb = copy(rb)
    
    s = wb.get_sheet(0)
    s.write(2,4, Formula('D3-B3') )
    wb.save('test.xls')
    

This works to edit a XLSfile and allowed me to enter a formula in a cell. Now
I'm stuck on how can I edit a column to put a formula in the more than one
cell that would continue to each cell in the column with the data from the
cells in that row, like I did with D3-B3 the row number would change each cell
to match that row.


Answer: With a simple loop:

    
    
    s = wb.get_sheet(0)
    last_row = 10  # change to your last required row
    for i in range(4, last_row + 1): 
        s.write(2, i, Formula('D{row}-B{row}'.format(row=i-1)))
    wb.save('test.xls')
    

