Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Support theme based colors #1047

Closed
bob-schumaker opened this issue Mar 1, 2024 · 4 comments
Closed

Feature request: Support theme based colors #1047

bob-schumaker opened this issue Mar 1, 2024 · 4 comments

Comments

@bob-schumaker
Copy link

bob-schumaker commented Mar 1, 2024

Feature Request

I have a branch prepared that supports colors specified as a dict, so that it is possible to duplicate existing Excel "cell styles". For example, specifying a format like:

cell_format = workbook.add_format(
    {
        "font_name": "Calibri",
        "font_color": {"theme": 3},
        "font_size": 11,
        "bottom": "medium",
        "bottom_color": {"theme": 4, "tint": 0.4},
        "bold": True,
    }
)

would replicate the "Heading 3" Excel "Cell Style". With this change, it is possible to create all of the Excel Cell Style menu options.

@jmcnamara jmcnamara changed the title Support for dict-based color specifications Feature request: Support for dict-based color specifications Mar 1, 2024
@jmcnamara
Copy link
Owner

jmcnamara commented Mar 1, 2024

Thanks for the suggestion.

The way that I would like to deal with this is via a Color class/type similar to the like in the Rust version.

I have this as a proposed change on theXlsxWriter Roadmap v2: #1028 and I will tackle it at some point.

The way the Rust version works is that all APIs that have a color parameter can take a Color enum (Python object) which can also be constructed automatically from a string like #FF34B7. But more importantly, in relation to this feature request, the Color instance can be constructed from a Theme(color, shade) pair. You can see that in the examples in the rust_xlsxwriter docs and examples.

For example, specifying a format like ... would replicate the "Heading 3" Excel "Cell Style".

Strictly speaking this would replicate the cell theme color but not the cell "style". That would take additional support in the Format/Styles infrastructure and for complexity reasons isn't on my roadmap. The only styles that are supported are "Default" and "Hyperlink". That may not matter for your use case but I just wanted to point it out to avoid any confusion.

@bob-schumaker
Copy link
Author

I have an interim change that makes it possible to make look-alike Cell Styles using a dict-based color scheme. Let me rework it to use a class/dataclass, that does make more sense :-)

@jmcnamara jmcnamara changed the title Feature request: Support for dict-based color specifications Feature request: Support theme based colors Mar 2, 2024
@jmcnamara
Copy link
Owner

Let me rework it to use a class/dataclass, that does make more sense :-)

Let me prototype it first to see how it should/could work and perhaps you can row in with some help.

@jmcnamara
Copy link
Owner

Closing this and tracking the theme color addition in #1028

@jmcnamara jmcnamara closed this as not planned Won't fix, can't repro, duplicate, stale May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants