Python读取excel中图片的案例-创新互联
这篇文章主要介绍了Python读取excel中图片的案例,具有一定借鉴价值,需要的朋友可以参考下。希望大家阅读完这篇文章后大有收获。下面让小编带着大家一起了解一下。
环境准备:
python3
pillow
pip install pillow
pypiwin32
pip install pypiwin32
代码
from PIL import ImageGrab import win32com.client as win32 excel = win32.gencache.EnsureDispatch('Excel.Application') workbook = excel.Workbooks.Open(r'C:\Users\file.xlsx') for sheet in workbook.Worksheets: for i, shape in enumerate(sheet.Shapes): if shape.Name.startswith('Picture'): shape.Copy() image = ImageGrab.grabclipboard() image.save('{}.jpg'.format(i+1), 'jpeg') excel.Quit()
注意事项
有些xlsx文件可能读取不了,试试换成xls格式
程序运行前不可以有其他程序打开excel文件
感谢你能够认真阅读完这篇文章,希望小编分享Python读取excel中图片的案例内容对大家有帮助,同时也希望大家多多支持创新互联,关注创新互联网站设计公司行业资讯频道,遇到问题就找创新互联,详细的解决方法等着你来学习!
网页名称:Python读取excel中图片的案例-创新互联
转载来源:http://ybzwz.com/article/hsgpc.html