xlwings显示某个打开的Excel工作簿
作者:互联网
使用xw.books就可以显示现在打开的所有Excel表
xw.books
# Books([<Book [Book1]>, <Book [Book2]>])
xw.apps[10559].books # specific app, get the PIDs via xw.apps.keys()
# Books([<Book [Book1]>, <Book [Book2]>])
activate可以切换操作焦点到Excel上,steal_focus默认为False,这样只会激活不会把其移到最上层窗口。
Book.fullname可以获得完整路径
filepath = sorted([i.fullname for i in xw.books ])[-1]
wb = xw.Book(filepath)
wb.activate(steal_focus=True)
同理xw.apps可以获得所有打开的Excel App。可以获得PID。
标签:filepath,Excel,xlwings,apps,focus,books,某个,xw 来源: https://blog.csdn.net/weixin_41989712/article/details/121441218