繁体   English   中英

将图表从 excel 导出到图像

[英]Export charts from excel to image

我一直在使用openpyxl在 linux 和 windows 平台上处理 xlsx 文件。 但此时我需要阅读工作簿并将工作表中的图表导出为图像。 我浏览了文档,但找不到任何方法来完成它。

问题:我可以使用或做些什么来使用 python(最好是 openpyxl)将图表导出为图像?

我在阅读一些文档时发现了这一点https://pypi.org/project/openpyxl-image-loader/

如果你知道图片在哪里,你可以做

from openpyxl_image_loader import SheetImageLoader

# Load your workbook and sheet as you want, for example
wb = load_workbook('path_to_file.xlsx')
sheet = wb['required_sheet']

# Put your sheet in the loader
image_loader = SheetImageLoader(sheet)

# And get image from specified cell
image = image_loader.get('A3')

# Image now is a Pillow image, so you can do the following
image.show()

# Ask if there's an image in a cell
if image_loader.image_in('A4):
    print("Got it!")

如果您不确定图像在工作簿中的位置,您可以尝试遍历单元格,直到找到图像。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM