text_wrap在xlswriter中不起作用

时间:2018-06-22 13:20:23

标签: python pandas xlsxwriter

我正在尝试使用ExcelWriter中的pandas函数将数据写入excel工作簿。但是问题在于,尽管包含了'text_wrap': True参数,但文本却没有出现:

writer = pd.ExcelWriter(fname, engine='xlsxwriter')
df1.to_excel(writer, sheet_name='QSMUST Summary', index = False)
workbook = writer.book
cellFormat = workbook.add_format({'text_wrap': True,
                                  'valign': 'vcenter',
                                  'align': 'center'})  

worksheet = writer.sheets['QSMUST Summary']
worksheet.set_row(0, 450, cellFormat)
worksheet.set_column(0, 31, 15, cellFormat)
writer.save()

0 个答案:

没有答案