def export_excel(self): try: # create excel office = modOffice.modOffice() office.create_excel_app() office.create_excel_workbook() office.create_excel_sheets() # set row and col row = 1 col = 1 for i in range(self.maxd): # day number # set excel title if i + 1 == self.maxd and self.flag == True: office.sheet.Cells(row, col).Value = "********" office.sheet.Cells(row, col + 1).Value = "********" else: v = re.sub(r"\d", "", str(self.userinfo.field[0].date[i])) if v.strip() != "": office.sheet.Cells(row, col).Value = self.userinfo.field[0].date[i] office.sheet.Cells(row, col + 1).Value = self.userinfo.field[0].name row += 1 # set excel value for k in range(self.userinfo.count + 1): # round number v = re.sub(r"\d", "", str(self.userinfo.field[0].teamA[i][k])) if v != "": if k < 3: office.sheet.Cells(row, col).Value = "0" + str(k + 7) + ":30" else: office.sheet.Cells(row, col).Value = str(k + 7) + ":30" office.sheet.Cells(row, col + 1).Value = self.userinfo.field[0].teamA[i][k] office.sheet.Cells(row, col + 2).Value = self.userinfo.field[0].teamB[i][k] row += 1 except: raise
import modOffice import modPublic import modString #load string handle module string=modString.modString() string.Number2ABC(26) #load template and base data userinfo=modUserInfo.modUserInfo() userinfo.loadbaseinfo(5) userinfo.loadtemplate() #create excel office=modOffice.modOffice() office.create_excel_app() office.create_excel_workbook() office.create_excel_sheets() #set contest title for i in range(userinfo.team_count): office.sheet.Cells(i+2, 1).Value=userinfo.team[i].name office.sheet.Cells(1, i+2).Value=userinfo.team[i].name office.sheet.Cells(i+2, i+2).Value="X" office.sheet.Cells(userinfo.team_count+3, i+2).Value=userinfo.team[i].name #set record title office.sheet.Cells(userinfo.team_count+4, 1).Value="應賽".encode("big5") office.sheet.Cells(userinfo.team_count+5, 1).Value="已賽".encode("big5")