[GH-ISSUE #279] How to get the default format? #225

Closed
opened 2026-05-05 11:59:01 -06:00 by gitea-mirror · 3 comments
Owner

Originally created by @znakeeye on GitHub (Mar 30, 2020).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/279

Originally assigned to: @jmcnamara on GitHub.

In workbook.c you add a default format:

/* Add the default cell format. */
    format = workbook_add_format(workbook);
    GOTO_LABEL_ON_MEM_ERROR(format, mem_error);

How do you retrieve that format? E.g. I would like to change the default font for all cells, so I expected something like this:

format = workbook_get_default_format(workbook);

But no such API. Ideas?

Originally created by @znakeeye on GitHub (Mar 30, 2020). Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/279 Originally assigned to: @jmcnamara on GitHub. In `workbook.c` you add a default format: ```c /* Add the default cell format. */ format = workbook_add_format(workbook); GOTO_LABEL_ON_MEM_ERROR(format, mem_error); ``` How do you retrieve that format? E.g. I would like to change the default font for all cells, so I expected something like this: ```c format = workbook_get_default_format(workbook); ``` But no such API. Ideas?
gitea-mirror 2026-05-05 11:59:01 -06:00
Author
Owner

@jmcnamara commented on GitHub (Mar 30, 2020):

That font isn't exposed, deliberately, since changing it generally affects size calculations used for image insertion and other cell measurements.

If you really want to access it anyway, then you can do so via the workbook->formats linked list. However, things may break and I don't recommend it.

<!-- gh-comment-id:605971514 --> @jmcnamara commented on GitHub (Mar 30, 2020): That font isn't exposed, deliberately, since changing it generally affects size calculations used for image insertion and other cell measurements. If you really want to access it anyway, then you can do so via the `workbook->formats` linked list. However, things may break and I don't recommend it.
Author
Owner

@znakeeye commented on GitHub (Mar 30, 2020):

Thanks for clarification! Then I'm probably better off adding a custom format and provide that instance when writing cell values.

<!-- gh-comment-id:605974671 --> @znakeeye commented on GitHub (Mar 30, 2020): Thanks for clarification! Then I'm probably better off adding a custom format and provide that instance when writing cell values.
Author
Owner

@jmcnamara commented on GitHub (Mar 30, 2020):

Then I'm probably better off adding a custom format and provide that instance when writing cell values.

Yes. That is safer.

<!-- gh-comment-id:605989006 --> @jmcnamara commented on GitHub (Mar 30, 2020): > Then I'm probably better off adding a custom format and provide that instance when writing cell values. Yes. That is safer.
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#225
No description provided.