无法设置工作表标题(xlsxwriter Python)

时间:2016-12-21 10:32:30

标签: python file worksheet xlsxwriter

hereworkbook = xlsxwriter.Workbook(<filename>)
worksheet = workbook.add_worksheet()
worksheet.set_header("&A" + str(<text>))

所以我试着设定它,但结果却没有任何结果。

1 个答案:

答案 0 :(得分:0)

它应该工作。以下是基于您的代码段的工作示例:

import xlsxwriter

workbook = xlsxwriter.Workbook('header.xlsx')
preview = 'Select Print Preview or Page Layout to view header'

worksheet = workbook.add_worksheet('My Worksheet')

worksheet.set_header("&A" + " - Some text")

worksheet.set_column('A:A', 50)
worksheet.write('A1', preview)

workbook.close()

以下是Excel中页面布局模式的输出:

enter image description here