使用python从多个工作表添加相同的单元格

时间:2013-07-30 19:09:55

标签: python sum xlrd worksheet xlwt

到目前为止,我有一个Python程序,但是......我需要在52个不同的工作表中总结所有相同的单元格位置。

For example:   I have 52 sheets and need to sum cell D75 across all the sheets in my coversheet.

请注意,封面已经制作好了,我没有任何问题,我只需要确定如何将总和纳入我的封面。

CHEERS !!!

1 个答案:

答案 0 :(得分:0)

完全未经测试,如果你不能让它工作,请告诉我,我会仔细看看

wb = open_workbook('simple.xls')
values = []
for s in wb.sheets(): #iterate over the sheets
    cell = sheet.cell(3,74) #D=3, need to offset 75 by 1 hence 74
    values.append(float(cell.value))
print sum(values)

另外,这是一个非常好的教程http://www.simplistix.co.uk/presentations/python-excel.pdf