标签:off 表格 coding 9.1 设置 for return pat 导出
sheet.row(2).set_style(xlwt.easyxf('font:height 440;'))
13.5(220)是默认行高,13.5=220,27=440
sheet.col(2).width = 256*8
8.43(2343,256*9.15)是默认列宽,8.29=256*9,10.29=256*11
style = xlwt.easyxf("""
font:
height 220,
name SimSun,
colour_index black,
bold off;
align:
wrap on,
vert centre,
horiz center;
borders:
left thin,
right thin,
top thin,
bottom thin
""")
sheet.write_merge(0, 0, 0, 21, '哈哈哈', style)
sheet.write(2, 3, '哈哈哈', style)
response = HttpResponse(content_type='application/vnd.ms-excel')
response['Content-Disposition'] = u'attachment;filename=dami.xls'
wb = xlwt.Workbook(encoding='utf8')
sheet = wb.add_sheet(u'商品库存', cell_overwrite_ok=True)
output = BytesIO()
wb.save(output)
output.seek(0)
response.write(output.getvalue())
return response
sheet.write(行,列,标签,样式)
sheet.write_merge(上,下,左,右,标签,样式)
xlwt模块:
style = xlwt.easyxf("""
font:
name Arial,
colour_index white,
bold on,
height 0xA0;
align:
wrap off,
vert center,
horiz center;
pattern:
pattern solid,
fore-colour 0x19;
borders:
left thin,
right thin,
top thin,
bottom thin;
""")
style2 = xlwt.easyxf("""
font:
height 220,
name SimSun,
colour_index black,
bold off;
align:
wrap on,
vert centre,
horiz center;
borders:
left thin,
right thin,
top thin,
bottom thin
""")
写入时设置样式改变字体属性,改变边框属性,改变底色属性,改变行高(起码显示上改变),但没改变行宽。
行高行宽可以自行设置。
标签:off 表格 coding 9.1 设置 for return pat 导出
原文地址:https://www.cnblogs.com/bqwzx/p/10658322.html