from openpyxl import load_workbook
import os.path
def createfile(self):
a=0
path1=os.path.split(os.path.realpath(__file__))[0] #获得当前路径
if os.path.isdir(path1+'\Infor') != True: #'Infor'不存在
os.makedirs('Infor') #创建路径
a=1
else :
if os.path.isfile(path1+'\Infor\ErrorInfors.xls') !=True: #文是否存在
a=1
else:
#打开文件
self.Errorinforfile = xlrd.open_workbook(path1+
'\Infor\ErrorInfors.xls')
if a == 1:
self.Errorinforfile = xlwt.Workbook(encoding='utf-8') #创建Excel表
sheet = self.Errorinforfile.add_sheet('Errorinfor')
sheet.write(0, 0, 'ErrorInfor')
sheet.write(0, 1, 'Calendar')
sheet.write(0, 2, 'Description')
self.Errorinforfile.save(path1+'\Infor\ErrorInfors.xls') #存文件