windows下python通过win32com读写excel文件
import os import win32com.client filename = 'pidancode.com.xls' filepath = os.path.abspath(filename) # Always make sure you use an absolute path ! # 打开excel文件: excel = win32com.client.Dispatch('Excel.Application') excel.Visible = True workbook = excel.Workbooks.Open(filepath) # 保存CSV文件: xlCSVWindows = 0x17 # from enum XlFileFormat workbook.SaveAs(Filename=filepath+".csv",FileFormat=xlCSVWindows) # 关闭 workbook 和 Excel workbook.Close(SaveChanges=False) excel.Quit()
相关文章