导入
from styleframe import StyleFrame
StyleFrame不同于DataFrame表的df,是不可以预览的。
各列设置宽度
sf = StyleFrame(df)
sf.set_column_width(columns = ["col_1","col_2","col_3"],width=10)
sf.set_column_width_dict(col_width_dict = {"col_1":10,"col_2":20,"col_3":30})
设置宽度的实例
writer = StyleFrame.ExcelWriter('ticker_1224-12.xlsx')
all_info_df = StyleFrame(all_info_df)
all_info_df.set_column_width(columns=all_info_df.columns.tolist(), width=25)
all_info_df.to_excel(
excel_writer=writer,
sheet_name="%s" %
str("sheet_name"))
writer.save()
writer.close()
writer.save()和.close()必须有.不然没用,根本不会写入
writer.save()
writer.close()
这两个很重要