我正在尝试将名称设置为 Excel 表(我使用下面的代码创建)以替换默认表
with pd.ExcelWriter('pandas_table.xlsx', engine='xlsxwriter') as writer:
df.to_excel(writer, sheet_name='StgFull', startrow=1, header=False, index=False)
workbook = writer.book
worksheet = writer.sheets['StgFull']
(max_row, max_col) = df.shape
tabname = 'abcd'
column_settings = [{'header': column} for column in df.columns]
worksheet.add_table(0, 0, max_row, max_col - 1
, {'columns': column_settings}
)
worksheet.set_column(0, max_col - 1, 12)
writer.save()