Inserting cells into an existing workbook, or into a workbook on the fly
as you create it?
In the latter case, you need know only about xlwt (which creates XLS
files, including the formula functionality). In the former case you also
need to know about xlrd (reads XLS files) and xlutils (whose utilities
including copying/filtering XLS files).
See the tutorial that you can access via http://www.python-excel.org.
The formula examples in the tutorial don't cover the "copy down"
scenario. Here's an example with numbers in col A and you want a running
total in col B:
[preliminaries omitted; rows and columns are enumerated starting from
zero (A1 is (rowx=0, colx=0)); see tutorial]
sheet.write(1, 1, Formula('A2'), a_style)
cum_fmla_fmt = 'B%d + A%d'
for row_index in xrange(2, whatever):
fmla = Formula(cum_fmla_fmt % (row_index, row_index + 1))
sheet.write(row_index, 1, fmla, a_style)
Cheers,
John