12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- from ctypes import *
- import time
- import win32com.client as win32
- import os
- cur_dir=os.getcwd()
- BSFile = [
- 'Monster',
- 'MonsterDynamicProp',
- 'SkillData',
- 'NpcData',
- 'BUFF',
- 'BattleServerConfig',
- 'BuffData'
- ]
- def get_dir(*pathes):
- if pathes:
- return os.path.join(cur_dir, *pathes)
- return cur_dir
- def has_dir(path):
- return True if os.path.isdir(path) else False
- def transform(parent_path,out_path):
- print("====parent_path=-====" + parent_path)
- for path, d, fileList in os.walk(parent_path):
- num = len(fileList)
- for i in range(num):
- file_Name = os.path.splitext(fileList[i])
- if file_Name[0] in BSFile and file_Name[1] == '.xml':
- transfile1 = path+'\\' +fileList[i]
- transfile2 = out_path+'\\'+file_Name[0]
- excel=win32.gencache.EnsureDispatch('excel.application')
- pro=excel.Workbooks.Open(transfile1)
- pro.SaveAs(transfile2+".xlsx", FileFormat=56)
- pro.Close()
- excel.Application.Quit()
- if __name__=='__main__':
- path1=get_dir("./")
- path2=get_dir("../date_config")
- if not has_dir(path2):
- os.makedirs(path2)
- transform(path1, path2)
|