# -*- coding:utf-8 -*-__author__ = yangxin_ryanfrom win32com.client import Dispatch, DispatchEximport pythoncomfrom PIL import ImageGrab""" 对excel的表格区域进行截图——用例: excel_catch_screen(u"D:\Desktop\到期预测日报 0521.xlsx", u"到期预测日报", u"到期预测日报", "A1:O96")"""class ExcelToImageWindow(object):def excel_catch_screen(self, filename, sheet_name, screen_area, pic_name, img_name=False):pythoncom.CoInitialize()excel = DispatchEx("Excel.Application")excel.Visible = Trueexcel.DisplayAlerts = Falseworkbook = excel.Workbooks.Open(filename)worksheet = workbook.Sheets(sheet_name)worksheet.Range(screen_area).CopyPicture()worksheet.Paste()excel.Selection.ShapeRange.Name = pic_nameworksheet.Shapes(pic_name).Copy()img = ImageG
1200字范文,内容丰富有趣,写作的好帮手!