hereworkbook = xlsxwriter.Workbook(<filename>)
worksheet = workbook.add_worksheet()
worksheet.set_header("&A" + str(<text>))
所以我试着设定它,但结果却没有任何结果。
答案 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中页面布局模式的输出: