通过流
output = StringIO.StringIO()
workbook = Workbook(output, {'in_memory': True})
sheet
worksheet = workbook.add_worksheet(options['sheet_name'] if 'sheet_name' in options else None)
合并单元格
worksheet.merge_range(line_index, 0, line_index, column_num - 1, data=options['introduction'], cell_format=introduction_format)
普通写入string(还有write_blank, write_number等等)
worksheet.write_string(line_index, index, column)
一个单元格多种format
required_format = workbook.add_format({'font_color': 'red'})
worksheet.write_rich_string(0, index, column[:-1], required_format, '*')
write_column, write_row参数是list。set_column, set_row设置样式。
worksheet.write_row(line_index, 0, data_list)
网友评论