新建一个excel,分别插入三张图片,顺序:1,2,3
输出的图片顺序如图1
当我改变图片的插入顺序为:3,2,1(excel插入顺序图1),
同样excel插入的顺序我改成:2,3,1(excel插入顺序图2)
抓取的图片的顺序如图4
由此可见,Python提取的图片顺序和插入图片的顺序一致。
from win32com.client import Dispatch, DispatchEx
import pythoncom
from PIL import ImageGrab, Image
import uuid
def excel_catch_screen(filename, sheetname, screen_area, img_name=False):
""" 对excel的表格区域进行截图——用例:excel_catch_screen(ur"D:\Desktop\123.xlsx", "Sheet1", "A1:J10")"""
pythoncom.CoInitialize() # excel多线程相关
if name == ' main ':
excel_catch_screen(r"C:\Users\huangat\Downloads\2019-04-08_2019-04-21_yunying.xlsx", "Sheet", "A1:J6")
Python和VBA都用不上,把Excel文件的扩展名改成.rar或者.zip,然后解压,在解压后的文件夹里就可以看到你要找的图片了。当然,如果你愿意,可以用Python来做这件事。