这是我的代码。...
import openpyxl as xl
from openpyxl.chart import BarChart,Reference
def spread_sheet(filename,sheetname):
wb = xl.load_workbook(f'{filename}') > i have to use these wb and sheet variables to all these functions down
sheet= wb[f'{sheetname}']
def total_horizontaly(row_start,row_end,col_start,col_end,Destination):
tot=0
for row in range(row_start,row_end+1):
for col in range(col_start,col_end+1):
cell =sheet.cell(row, col)
tot += cell.value
tot_marks =sheet.cell(row,f'{Destination}')
tot_marks.value = tot
def average_horizontaly(row_start,row_end,col_start,col_end,Desination):
tot=0
for row in range(row_start, row_end):
for col in range(col_start, col_end):
cell =sheet.cell(row, col)
tot += cell.value
avg=tot/(col_end+1-col_start)
avg_marks=sheet.cell(row,f'{Desination}')
avg_marks.value=avg
def Save(filename):
wb.save(f'{filename}')
我曾经尝试过使用类“,”,它虽然有效,但不能满足我的结果