Last active
April 14, 2021 14:17
-
-
Save clementlefevre/030ccbd8a936c812a9d510134cf6c6bf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add Logo | |
img = openpyxl.drawing.image.Image('logo.jpg') | |
p2e = pixels_to_EMU | |
h, w = img.height, img.width | |
size = XDRPositiveSize2D(p2e(w), p2e(h)) | |
# Set image position on the top right of the Worksheet: | |
column = 8 # last column index (!!!starts from 0) | |
row = 0 # first row index (!!!starts from 0) | |
coloffset = -p2e(w) # we align the image with the right limit of the worksheet | |
marker = AnchorMarker(col=column, colOff=coloffset, row=row) | |
img.anchor = OneCellAnchor(_from=marker, ext=size) | |
ws.add_image(img) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment