[GH-ISSUE #85] Fit image to cell #72

Closed
opened 2026-05-05 11:36:27 -06:00 by gitea-mirror · 1 comment
Owner

Originally created by @iamabhiee on GitHub (Jan 4, 2017).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/85

Originally assigned to: @jmcnamara on GitHub.

Library seems really good, I am trying to fit image to cell but I couldn't find a way, whats best way to do the same?

Originally created by @iamabhiee on GitHub (Jan 4, 2017). Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/85 Originally assigned to: @jmcnamara on GitHub. Library seems really good, I am trying to fit image to cell but I couldn't find a way, whats best way to do the same?
gitea-mirror 2026-05-05 11:36:28 -06:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@jmcnamara commented on GitHub (Jan 4, 2017):

Hi Abhishek,

The best, and only, way is to scale the image with the worksheet_insert_image_opt() function to fit into a standard Excel cell size of 20x64 pixels:

lxw_image_options options = {.x_offset = 30,  .y_offset = 10,
                             .x_scale  = 0.5, .y_scale  = 0.5};
worksheet_insert_image_opt(worksheet, 2, 1, "logo.png", &options);

See the docs for worksheet_insert_image_opt(): http://libxlsxwriter.github.io/worksheet_8h.html#a0b05e75e2c2a5c3452374714cdb2b79b

John

<!-- gh-comment-id:270396054 --> @jmcnamara commented on GitHub (Jan 4, 2017): Hi Abhishek, The best, and only, way is to scale the image with the `worksheet_insert_image_opt()` function to fit into a standard Excel cell size of 20x64 pixels: ```C lxw_image_options options = {.x_offset = 30, .y_offset = 10, .x_scale = 0.5, .y_scale = 0.5}; worksheet_insert_image_opt(worksheet, 2, 1, "logo.png", &options); ``` See the docs for `worksheet_insert_image_opt()`: http://libxlsxwriter.github.io/worksheet_8h.html#a0b05e75e2c2a5c3452374714cdb2b79b John
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/libxlsxwriter#72
No description provided.