Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there api to get image's position(range) in Excel? #197

Open
GreenValue opened this issue Nov 1, 2022 · 3 comments
Open

Is there api to get image's position(range) in Excel? #197

GreenValue opened this issue Nov 1, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@GreenValue
Copy link

Images in Excel are very important infomation, such as Product Image and so.
So, is there api to get Image's position in Excel, such as 1.png's position is in cell A3 of SheetA?
Thanks very much.

@chang-zy
Copy link

chang-zy commented Feb 4, 2023

You can try to create one.

@aral-matrix
Copy link
Collaborator

Note to self:

  • a worksheet xl/worksheets/sheetXX.xml refers to all related image (and comment) information in its own relationships file at xl/worksheets/_rels/sheetXX.xml.rels like so:
<?xml version="1.0" encoding="UTF-8"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
	<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing" Target="../drawings/drawing1.xml"/>
</Relationships>
  • image positioning information for xl/worksheets/sheetXX.xml is stored in the referred file xl/drawings/drawingYY.xml - this includes the anchor cell(s), image name (label), position offset (a:off, x & y) and size information (a:ext, cx & cy) in a TBD unit. The drawing xml can also refer to a relationship Id that identifies a specific image file (see next bullet). Note that the number of the drawing file YY is different from the worksheet number (index) XX.
  • finally, in a file xl/drawings/_rels/drawingYY.xml.rels, the relationship IDs referred from drawingYY.xml are defined and link to actual image files in xl/media/ like so:
<?xml version="1.0" encoding="UTF-8"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
	<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="../media/image1.png"/>
</Relationships>

Functionality to access (and manipulate) image information could be considered after implementing - in a first step - the generic support for worksheet relationships, which would be the prerequisite to support of comments as well.

@aral-matrix aral-matrix added the enhancement New feature or request label Oct 3, 2024
@aral-matrix
Copy link
Collaborator

milestone #1: generic support for worksheet relationships is in the development-aral branch as of today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants