#!usr/bin/dev python#utf-8 from openpyxl import load_workbookimport osimport os.pathfile_path = ‘C:/Users/Hugo Lester/Desktop/statics.xlsx‘ws = load_workbook(file_path)sheet = ws.get_sheet_by_name(‘Sheet1‘)for i in range(1,10): clo = str(int(i)) #sheet[‘G‘+clo] = sheet.cell[‘A‘+clo].value +sheet.cell[‘B‘+clo].value+sheet.cell[‘C‘+clo].value+sheet.cell[‘D‘+clo].value+sheet.cell[‘E‘+clo].value+sheet.cell[‘F‘+clo].value #+ sheet[‘B‘+clo]+ sheet[‘C‘+clo]+ sheet[‘D‘+clo]+ sheet[‘E‘+clo]+ sheet[‘F‘+clo] #sheet[‘A‘ + clo].value + sheet[‘B‘ + clo].value + sheet[‘C‘ + clo].value +sheet[‘D‘+clo].value+sheet[‘E‘+clo].value+sheet[‘F‘+clo].value sheet[‘G‘ + clo] = 0 for row in range(0,6): rownum = chr(ord(‘A‘)+ row) position = rownum + clo print sheet[position].value #print rownum if not sheet[position].value is None: sheet[‘G‘ + clo] = sheet[‘G‘ + clo].value +sheet[position].value #print rownum #print type(row) #print type(sheet[‘G‘ + clo].value) #print rownumws.save(file_path)
时间: 2024-10-05 17:38:39