赞
踩
一:python将xls文件转换xlsx
- import os
-
- import win32com.client as win32
-
- file_path = r"E:\download\table"
-
- def to_xlsx(file):
- excel = win32.gencache.EnsureDispatch('Excel.Application')
- wb = excel.Workbooks.Open(file)
- wb.SaveAs(file+'x', FileFormat = 51) #FileFormat = 51 is for .xlsx extension
- wb.Close() #FileFormat = 56 is for .xls extension
- excel.Application.Quit()
- if __name__ == '__main__':
- os_listdir = os.listdir(file_path)
- for i in os_listdir:
- file=os.path.join(file_path,i)
- to_xlsx(file)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。