有谁知道任何
Python – > Excel库包含一个方法来自动确定给定Excel文件名的工作表中的所有列? 最佳答案 您可以使用
pywin32库:
from win32com.client import Dispatch
excel = Dispatch('Excel.Application')
wb = excel.Workbooks.Open("D:\\output.xlsx")
#Activate second sheet
excel.Worksheets(2).Activate()
#Autofit column in active sheet
excel.ActiveSheet.Columns.AutoFit()
#Save changes in a new file
wb.SaveAs("D:\\output_fit.xlsx")
#Or simply save changes in a current file
#wb.Save()
wb.Close()