如何在没有提示的情况下删除excel中的工作表?我在win32com.client中使用Dispatch执行此操作。
import time, os.path, os
from win32com.client import Dispatch
path1 = 'C:\\example.xlsx'
path2 = 'C:\\Todolist2.xlsx'
xl = Dispatch("Excel.Application")
xl.Visible = True
wb1= xl.Workbooks.Open(Filename=path1)
wb2= xl.Workbooks.Open(Filename=path2)
ws1 = wb1.Worksheets(1)
ws2 = xl.ActiveSheet
ws1.Copy(Before=wb2.Worksheets(1))
ws2 = xl.ActiveSheet
ws2.Delete()