import os
import win32com.client
# 拆分多个表成独立文件
file = r'd:\Documents\新建 XLSX 工作表.xlsx'
et = win32com.client.Dispatch('ket.Application')
et.Visible = False
wb = et.Workbooks.Open(file)
worksheet = wb.Sheets
for i in worksheet: # 遍历工作簿中所有工作表
name = i.Name
i.Copy()
new_file = f'{os.path.dirname(file)}\\{name}.xlsx'
et.ActiveWorkbook.SaveAs(new_file)
et.ActiveWorkbook.Close()
wb.Close()
et.Quit()
暂时还有个问题就是拆分后的表格颜色发生改变