[GH-ISSUE #263] Feature request: add support for image positioning #209

Closed
opened 2026-05-05 11:55:54 -06:00 by gitea-mirror · 2 comments
Owner

Originally created by @jmcnamara on GitHub (Jan 13, 2020).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/263

Originally assigned to: @jmcnamara on GitHub.

Add support for image positioning where object_position has one of the following allowable values:

  1. Move and size with cells.
  2. Move but don’t size with cells.
  3. Don’t move or size with cells.
  4. Same as Option 1 to "move and size with cells" except libxlsxwriter applies hidden cells after the object is inserted.

See the Python version for reference: https://xlsxwriter.readthedocs.io/working_with_object_positioning.html

Originally created by @jmcnamara on GitHub (Jan 13, 2020). Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/263 Originally assigned to: @jmcnamara on GitHub. Add support for image positioning where object_position has one of the following allowable values: 1. Move and size with cells. 2. Move but don’t size with cells. 3. Don’t move or size with cells. 4. Same as Option 1 to "move and size with cells" except libxlsxwriter applies hidden cells after the object is inserted. See the Python version for reference: https://xlsxwriter.readthedocs.io/working_with_object_positioning.html
gitea-mirror 2026-05-05 11:55:54 -06:00
Author
Owner

@jmcnamara commented on GitHub (Jan 14, 2020):

I've pushed initial support for this feature to the object_position branch. You can now use it for images or charts as follows:

#include "xlsxwriter.h"

int main() {

    lxw_workbook  *workbook  = workbook_new("test_object_position01.xlsx");
    lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);

    lxw_image_options options = {.object_position = LXW_OBJECT_MOVE_AND_SIZE};
    worksheet_insert_image_opt(worksheet, CELL("E9"), "images/red.png", &options);

    return workbook_close(workbook);
}

Where the valid options are:

/** Options to control the positioning of worksheet objects such as images
 *  or charts. */
enum lxw_object_position {

    /** Default positioning for the object. */
    LXW_OBJECT_POSITION_DEFAULT,

    /** Move and size with the worksheet object with the cells. */
    LXW_OBJECT_MOVE_AND_SIZE,

    /** Move but don't size with the worksheet object with the cells. */
    LXW_OBJECT_MOVE_DONT_SIZE,

    /** Don't move or size the worksheet object with the cells. */
    LXW_OBJECT_DONT_MOVE_DONT_SIZE,

    /** Same as LXW_OBJECT_MOVE_AND_SIZE except libxlsxwriter applies hidden
     *  cells after the object is inserted. */
    LXW_OBJECT_MOVE_AND_SIZE_AFTER
};

Note, this is currently missing functionality to deal with hidden or changed cells in the same way Excel does. That will be supported soon.

<!-- gh-comment-id:574373989 --> @jmcnamara commented on GitHub (Jan 14, 2020): I've pushed initial support for this feature to the object_position branch. You can now use it for images or charts as follows: ```C #include "xlsxwriter.h" int main() { lxw_workbook *workbook = workbook_new("test_object_position01.xlsx"); lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL); lxw_image_options options = {.object_position = LXW_OBJECT_MOVE_AND_SIZE}; worksheet_insert_image_opt(worksheet, CELL("E9"), "images/red.png", &options); return workbook_close(workbook); } ``` Where the valid options are: ```C /** Options to control the positioning of worksheet objects such as images * or charts. */ enum lxw_object_position { /** Default positioning for the object. */ LXW_OBJECT_POSITION_DEFAULT, /** Move and size with the worksheet object with the cells. */ LXW_OBJECT_MOVE_AND_SIZE, /** Move but don't size with the worksheet object with the cells. */ LXW_OBJECT_MOVE_DONT_SIZE, /** Don't move or size the worksheet object with the cells. */ LXW_OBJECT_DONT_MOVE_DONT_SIZE, /** Same as LXW_OBJECT_MOVE_AND_SIZE except libxlsxwriter applies hidden * cells after the object is inserted. */ LXW_OBJECT_MOVE_AND_SIZE_AFTER }; ``` Note, this is currently missing functionality to deal with hidden or changed cells in the same way Excel does. That will be supported soon.
Author
Owner

@jmcnamara commented on GitHub (Jan 19, 2020):

Upstream in 0.9.4: http://libxlsxwriter.github.io/working_with_object_positioning.html

<!-- gh-comment-id:576026258 --> @jmcnamara commented on GitHub (Jan 19, 2020): Upstream in 0.9.4: http://libxlsxwriter.github.io/working_with_object_positioning.html
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#209
No description provided.