恳请各位大神帮忙解决一下
# 导入模块from openpyxl import load_workbook
# 获取数据
wb= load_workbook('./material/江宇工资信息表.xlsx')
ws = wb['Sheet1']
ws['H1'].value = '总工资'
for row in ws.iter_rows(min_row=2,max_row=11 ,values_only=True):
performance = row
bonus = row
base = row
# 使用数据
salary = performance + bonus + base
# 输出结果
wb.save('./material/江宇工资信息表.xlsx')
我该怎么样利用循环把所有人总工资都自动填入表格呀(具体是该怎么样赋值呢?) 本帖最后由 txxcat 于 2021-4-26 22:19 编辑
# 导入模块
from openpyxl import load_workbook
# 获取数据
wb= load_workbook('./material/江宇工资信息表.xlsx')
ws = wb['Sheet1']
ws['H1'].value = '总工资'
# for row in ws.iter_rows(min_row=2,max_row=11 ,values_only=True):
# performance = row
# bonus = row
# base = row
for row in range(2,12):
performance = ws['E'+str(row)].value
bonus = ws['F'+str(row)].value
base = ws['G'+str(row)].value
salary = performance + bonus + base
ws['H'+str(row)] = salary
# 输出结果
wb.save('./material/江宇工资信息表.xlsx')
txxcat 发表于 2021-4-26 22:17
谢谢,已经很好了,给我提供了很好的思路{:5_109:}
页:
[1]