df = pd.DataFrame(data=valuesDict,index=[0])
# Create a Pandas Excel writer using XlsxWriter as the engine.
writer = pd.ExcelWriter(os.path.join(ios_inspection_excel_file, file[:-4]) + '.xlsx', engine='xlsxwriter')
# Convert the dataframe to an XlsxWriter Excel object.
df.to_excel(writer, sheet_name='Sheet1')
# Get the xlsxwriter worksheet object.
worksheet = writer.sheets['Sheet1']
# Set the column width and format.
worksheet.set_column("B:Z", 25) # 在这里更改宽度值
# Close the Pandas Excel writer and output the Excel file.
writer.save()
pandas更改excel的column宽度
于 2023-10-31 10:44:47 首次发布