jango使用xlwt时单元格控制

合并单元格的写法:

sheet.write_merge(top_row, bottom_row, left_column, right_column, '内容')

普通的单元格写法:

sheet.write(1, 0, 1)

原贴:
https://stackoverflow.com/questions/19672760/how-to-write-a-cell-with-multiple-columns-in-xlwt

设置单元格格式:

	response = HttpResponse(content_type='application/vnd.ms-excel')
	response['Content-Disposition'] = 'attachment;filename=order.xls'
    # 创建一个文件对象
    wb = xlwt.Workbook(encoding='utf8')
    sheet = wb.add_sheet('要求')
    sheet.col(0).width = 256 * 20  # 设置1列列宽
    sheet.col(1).width = 256 * 10  # 设置2列列宽
    tall_style = xlwt.easyxf('font:height 720')  # 行高36pt
    sheet.row(0).set_style(tall_style2) #设置1行行高
发布了11 篇原创文章 · 获赞 0 · 访问量 101

猜你喜欢

转载自blog.csdn.net/xiaotuwai8/article/details/104759330
今日推荐