openpyxl
def out_xls(request,name):
template_file_name = os.path.join(base_path,'_webodt','templates','graduaction.xlsx')
out_file_name = os.path.join(base_path,'_webodt','outputs','graduaction.xls')
wb = load_workbook(template_file_name)
sheet = wb.active
sheet_head = sheet['A1']
sheet_head_template = unicode(sheet_head.value)
sheet['A1'] = sheet_head_template.format(term='2016', college=u'经济管理学院')
for index in range(4,101):
cell_mark = 'A'+str(index)
cell = sheet[cell_mark]
cell.alignment = Alignment(horizontal="center", vertical="center")
side = Side(border_style='thin',color='FF000000')
cell.border = Border(left=side,right=side,top=side,bottom=side)
cell.font = Font(name='SimSun', size=10)
cell.value = index
wb.save(out_file_name)
return down_file(out_file_name)
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于