import xlrd, xlwt
import os
assert os.path.isfile('source_excel.xls'),"There is no timesheet exist. Exit..."
book = xlrd.open_workbook('source_excel.xls')
sheet=book.sheet_by_index(0)
for rows in range(sheet.nrows):
value = sheet.cell(rows,0).value wbk = xlwt.Workbook(encoding='utf-8')
sheet_w = wbk.add_sheet('write_after', cell_overwrite_ok=True)
sheet_w.col(3).width = 5000
tittle_style = xlwt.easyxf('font: height 300, name SimSun, colour_index red, bold on; align: wrap on, vert centre, horiz center;')
sheet_w.write_merge(0,2,0,8,u'这是标题',tittle_style) check_num = 0 def check_data(sheet): global check_num check_num=check_num+1
date_arr = []
date=sheet.cell(row,2).value.rsplit('/')[-1]
if date not in date_arr:
date_arr.append(date)
sheet_w.write_merge(row2,row2,6,6,date_num, normal_style)
sheet_w.write_merge(row2,row2,7,7,','.join(date_arr), normal_style) from datetime import date,datetime
from xlrd import xldate_as_tuple
if (sheet.cell(rows,3).ctype == 3):
num=num+1
date_value = xldate_as_tuple(sheet.cell_value(rows,3),book.datemode)
date_tmp = date(*date_value[:3]).strftime("%d") 更多python使用xlrd与xlwt对excel的读写和格式设定相关文章请关注PHP中文网!
查看更多关于python使用xlrd与xlwt对excel的读写和格式设定的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did86047