OpenXLSX icon indicating copy to clipboard operation
OpenXLSX copied to clipboard

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

Open GreenValue opened this issue 3 years ago • 2 comments

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.

GreenValue avatar Nov 01 '22 02:11 GreenValue

You can try to create one.

chang-zy avatar Feb 04 '23 03:02 chang-zy

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 avatar Oct 03 '24 09:10 aral-matrix

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

aral-matrix avatar Jan 16 '25 17:01 aral-matrix