我正在尝试使用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()