OpenXLSX
OpenXLSX copied to clipboard
Is there api to get image's position(range) in Excel?
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.
You can try to create one.
Note to self:
- a worksheet
xl/worksheets/sheetXX.xmlrefers to all related image (and comment) information in its own relationships file atxl/worksheets/_rels/sheetXX.xml.relslike 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.xmlis stored in the referred filexl/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 inxl/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.
milestone #1: generic support for worksheet relationships is in the development-aral branch as of today.