How do I get images of an embedded cell?

162 views
Skip to first unread message

林伟明

unread,
Nov 1, 2024, 2:08:02 AM11/1/24
to openpyxl-users
I want to get images from sheet, but cannot get images that embedded in cell

Mingo Lin (Mingo)

unread,
Nov 3, 2024, 7:59:30 PM11/3/24
to openpyx...@googlegroups.com
when i use sheet._images , only get images which not embedded in cell.how do i get images of an embedded cell?

Michel MARTIN

unread,
Nov 27, 2024, 2:54:02 PM11/27/24
to openpyxl-users
You use the openpyxl_image_loader module

from openpyxl import load_workbook
from openpyxl_image_loader import SheetImageLoader

# Load the workbook and the specific sheet
wb = load_workbook('your_file.xlsx')
ws = wb.active

# Load the images from the sheet
image_loader = SheetImageLoader(ws)

# Check if there is an image in a specific cell
if image_loader.image_in('A1'):
    # Extract the image
    img = image_loader.get('A1')
    img.save('extracted_image.png')
Reply all
Reply to author
Forward
0 new messages