xlwings模块工作表的activate()方法不可用时使用select()方法
当激活工作表方法activate()不可以用时,可以试一试select()方法。
with xw.App(visible=False, add_book=False) as xlapp:
wbook = xlapp.books.open(xl_file)
wsheet = wbook.sheets['数据透视表']
tab_rng = wsheet.range('A4').expand('table')
tab_rng.copy_picture(appearance='screen', format='picture')
dest_sht = wbook.sheets['图表']
for pic in list(dest_sht.pictures):
pic.delete()
dest_sht.select()
# dest_sht.activate() 报异常!!!