标签:path sheet for open range work port book xls
#!usr/bin/dev python
#utf-8
from openpyxl import load_workbook
import os
import os.path
file_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 rownum
ws.save(file_path)
标签:path sheet for open range work port book xls
原文地址:http://www.cnblogs.com/HugoLester/p/7535280.html