|
@@ -28,49 +28,53 @@ def GeneratePasswdToXls(FILE):
|
|
|
data = xlrd.open_workbook(xlsname)
|
|
|
table = data.sheet_by_index(0)
|
|
|
head = table.row_values(0)
|
|
|
- assert len(head)==6
|
|
|
+ assert len(head)==7
|
|
|
assert head[0].strip()==u'\u5b66\u53f7'
|
|
|
- assert head[1].strip()==u'\u59d3\u540d'
|
|
|
- assert head[2].strip()==u'\u6027\u522b'
|
|
|
- assert head[3].strip()==u'\u5bc6\u7801'
|
|
|
- assert head[4].strip()==u'\u5206\u7ec4\u53f7'
|
|
|
- assert head[5].strip()==u'\u751f\u65e5'
|
|
|
+ assert head[1].strip()==u'\u7528\u6237\u540d'
|
|
|
+ assert head[2].strip()==u'\u59d3\u540d'
|
|
|
+ assert head[3].strip()==u'\u6027\u522b'
|
|
|
+ assert head[4].strip()==u'\u5bc6\u7801'
|
|
|
+ assert head[5].strip()==u'\u5206\u7ec4\u53f7'
|
|
|
+ assert head[6].strip()==u'\u751f\u65e5'
|
|
|
|
|
|
|
|
|
rwb = xlwt.Workbook(encoding='utf-8')
|
|
|
rsh = rwb.add_sheet('Sheet1')
|
|
|
|
|
|
rsh.write(0,0,u'\u5b66\u53f7')
|
|
|
- rsh.write(0,1,u'\u59d3\u540d')
|
|
|
- rsh.write(0,2,u'\u6027\u522b')
|
|
|
- rsh.write(0,3,u'\u5bc6\u7801')
|
|
|
- rsh.write(0,4,u'\u5206\u7ec4\u53f7')
|
|
|
- rsh.write(0,5,u'\u751f\u65e5')
|
|
|
+ rsh.write(0,1,u'\u7528\u6237\u540d')
|
|
|
+ rsh.write(0,2,u'\u59d3\u540d')
|
|
|
+ rsh.write(0,3,u'\u6027\u522b')
|
|
|
+ rsh.write(0,4,u'\u5bc6\u7801')
|
|
|
+ rsh.write(0,5,u'\u5206\u7ec4\u53f7')
|
|
|
+ rsh.write(0,6,u'\u751f\u65e5')
|
|
|
for i in range(table.nrows-1):
|
|
|
col = table.row_values(i+1)
|
|
|
+ username=col[1]
|
|
|
sid=str(int(col[0]))
|
|
|
- name=process_cell(table,i+1,1)
|
|
|
- sex=col[2]
|
|
|
+ name=process_cell(table,i+1,2)
|
|
|
+ sex=col[3]
|
|
|
password=randompass()
|
|
|
- cid=str(int(col[4]))
|
|
|
+ cid=str(int(col[5]))
|
|
|
|
|
|
- if table.cell(i+1,5).ctype==3:
|
|
|
- birthday = datetime.date(*xlrd.xldate_as_tuple(table.cell(i+1,5).value,data.datemode)[:3])
|
|
|
+ if table.cell(i+1,6).ctype==3:
|
|
|
+ birthday = datetime.date(*xlrd.xldate_as_tuple(table.cell(i+1,6).value,data.datemode)[:3])
|
|
|
else:
|
|
|
try:
|
|
|
- birthday = datetime.datetime.strptime(process_cell(table,i+1,5), "%Y-%m-%d").date()
|
|
|
+ birthday = datetime.datetime.strptime(process_cell(table,i+1,6), "%Y-%m-%d").date()
|
|
|
except:
|
|
|
try:
|
|
|
- birthday = datetime.datetime.strptime(process_cell(table,i+1,5), "%Y%m%d").date()
|
|
|
+ birthday = datetime.datetime.strptime(process_cell(table,i+1,6), "%Y%m%d").date()
|
|
|
except:
|
|
|
pass
|
|
|
|
|
|
rsh.write(i+1,0,sid)
|
|
|
- rsh.write(i+1,1,name)
|
|
|
- rsh.write(i+1,2,sex)
|
|
|
- rsh.write(i+1,3,password)
|
|
|
- rsh.write(i+1,4,cid)
|
|
|
- rsh.write(i+1,5,birthday.strftime('%Y%m%d'))
|
|
|
+ rsh.write(i+1,1,username)
|
|
|
+ rsh.write(i+1,2,name)
|
|
|
+ rsh.write(i+1,3,sex)
|
|
|
+ rsh.write(i+1,4,password)
|
|
|
+ rsh.write(i+1,5,cid)
|
|
|
+ rsh.write(i+1,6,birthday.strftime('%Y%m%d'))
|
|
|
rwb.save(wrxlspath)
|
|
|
return wrxlsname
|
|
|
|