def data():
wb=openpyxl.load_workbook('学期上课记录表.xlsx',data_only=True)
dict_student_sign={}
for each_wsname in wb.sheetnames:
if each_wsname=='课时':
continue
ws=wb[each_wsname]
for wsrow in range(4,ws.max_row):
if not ws.cell(wsrow,2).value in [None,'\n','\r',''] and not ws.cell(wsrow,2).value in list(dict_student_sign.keys()):
dict_student_sign[ws.cell(wsrow,2).value]={}
dict_student_sign[ws.cell(wsrow,2).value]['考勤']=[]
for each_wsname in wb.sheetnames:
ws=wb[each_wsname]
if each_wsname=='课时':
for wsrow in range(2,ws.max_row+1):
dict_student_sign[ws.cell(wsrow,1).value]['课时']=ws.cell(wsrow,2).value
wscolumn=3
str_=''
while True:
if ws.cell(wsrow,wscolumn).value==None:
break
else:
str_=str_+str(ws.cell(wsrow,wscolumn).value)+'+'
wscolumn=wscolumn+1
dict_student_sign[ws.cell(wsrow,1).value]['考勤'].append('总课时:'+str_[:-1])
continue
for wsrow in range(4,ws.max_row+1):
if ws.cell(wsrow,2).value in list(dict_student_sign.keys()):
for wscolumn in range(3,33):
if ws.cell(wsrow,wscolumn).value in ['出勤','未出勤','补课']:
x=3
while True:
if wsrow-x>7:
x=x+7
else:
break
if ws.cell(wsrow-(wsrow-x),wscolumn).value in [None,'\n','\r','']:
title=''
else:
title=ws.cell(wsrow-(wsrow-x),wscolumn).value
if ws.cell(wsrow,wscolumn).value in ['未出勤']:
dict_student_sign[ws.cell(wsrow,2).value]['考勤'].append(each_wsname+str(ws.cell(1,wscolumn).value)+'日\n'+ws.cell(wsrow,wscolumn).value+title+'☆余'+str(dict_student_sign[ws.cell(wsrow,2).value]['课时']-0)+'课时')
else:
dict_student_sign[ws.cell(wsrow,2).value]['考勤'].append(each_wsname+str(ws.cell(1,wscolumn).value)+'日\n'+ws.cell(wsrow,wscolumn).value+title+'★余'+str(dict_student_sign[ws.cell(wsrow,2).value]['课时']-2)+'课时')
dict_student_sign[ws.cell(wsrow,2).value]['课时']=dict_student_sign[ws.cell(wsrow,2).value]['课时']-2
#print(dict_student_sign)
return dict_student_sign