1
目前,我有一个xlPicture从通话(通过win32com)保存在我的剪贴板:Python的保存xlPicture从剪贴板
ws.Range(ws.Cells(1,1),ws.Cells(8+rows,total_length)).CopyPicture() #Copies xlPicture to clipboard
现在我想将图像保存在我的剪贴板到一个文件中,所以我尝试使用PIL:
from PIL import ImageGrab
img = ImageGrab.grabclipboard()
img.save(os.path.join(r'C:\Windows\Temp\WS_Template_Images','test.png'),'PNG')
但ImageGrab.grabclipboard()
没有回报,我认为xlPicture是有点不兼容的类型呼叫。有什么我可以改变使用ImageGrab或有一个完全替代解决方案来保存xlPicture?谢谢!
一个警告:Excel不会将大图像复制到系统剪贴板。它们将出现在Office剪贴板上,但您无法为它们使用ImageGrab.grabclipboard()。 – Vijchti