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

Conditional formatting #28

Open
Misiu opened this issue Oct 9, 2023 · 4 comments
Open

Conditional formatting #28

Misiu opened this issue Oct 9, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@Misiu
Copy link
Contributor

Misiu commented Oct 9, 2023

I'd like to ask for adding support for conditional formatting.
Use case:
I'm generating a report that contains a couple of columns, in the last columns I need to calculate the average from previous ones. If it is less than 1 I'd like to set the background to red, if it is more than 4.9 I want the background to be green.
I know I can calculate the value per row in my app, then put the value as the average column and apply styleId. Still, ideally, I'd like to use a formula to calculate the value (this can be done right now) and apply a conditional style to that cell, so when someone updates the values in the generated Excel file the average and the color will update.

Ref: https://stackoverflow.com/a/25724262/965722

@sveinungf
Copy link
Owner

Yes that would be a nice feature to have. There is a lot of possible options to cover for conditional formatting. Initially the feature would most likely not be implemented with all possible options, but your use case could be a good starting point.

@Misiu
Copy link
Contributor Author

Misiu commented Oct 11, 2023

@sveinungf I'd like to help with contributing, but there must be a starting point.
I've searched for API inspiration in existing libraries, for example: https://help.syncfusion.com/flutter/xlsio/working-with-conditional-formatting or https://docs.devexpress.com/WindowsForms/16190/controls-and-libraries/spreadsheet/data-presentation/conditional-formatting but not sure if similar approach would work with your library
A simple conditional formatting would be a good start.

@sveinungf
Copy link
Owner

Great! Any help is appreciated.

I don't know all the ins and outs regarding conditional formatting in Excel, so I don't have an API proposal ready for it. Perhaps there could be some similarity to the way data validations work. In any case, even though we could start of with a small subset of the feature, we should have some idea of what would come later, so that the remaining parts can be added without requiring breaking changes.

We will also need to understand how conditional formatting is implemented in an Excel file. That will most likely also have a say in how the API should be. Reading the Open XML specification can be a bit daunting, so what I typically do is reverse engineering instead. I would use the feature in Excel, save it to a file, and then unzip the file to see how the generated XML will look like.

@sveinungf sveinungf added the enhancement New feature or request label Jul 5, 2024
@pmeharry
Copy link

We want to do alternate row colors. The only real way to do this is with Conditional Formatting - (that would continue to work after sorting, etc.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants