Ale*_*lex 3 python excel image openpyxl
我正在循环遍历工作簿中的每个单元格。由于某种原因,当 openpyxl 迭代包含图像的工作表时,该图像将被删除。如何解决这个问题?
我正在寻找一种方法来传递具有图像的单元格。
我没有进入read_only模式,也不想进入模式,因为我正在修改工作表。
像这样的东西对我来说最有用:
if cell is image:
pass
Run Code Online (Sandbox Code Playgroud)
小智 7
https://pypi.org/project/openpyxl-image-loader/
from openpyxl import load_workbook
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!")
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11425 次 |
| 最近记录: |