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

Worksheet global styles & row styles #53

Open
goremykin opened this issue May 18, 2024 · 4 comments
Open

Worksheet global styles & row styles #53

goremykin opened this issue May 18, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@goremykin
Copy link

Hello! First of all, thank you very much for such a wonderful library. I really appreciate your work.
Maybe I didn't look well, but I didn't find a way to set global styles for the entire worksheet or for an entire row.

Use case:
I have the same font and font size for the entire worksheet. In addition some rows are bold. Specifying styles only at the cell level results in duplicate styles.

@sveinungf
Copy link
Owner

Thank you for the feedback!
This is currently not supported, but being able to set a global or default style could be a nice feature to have.

One thing that needs to be decided upon is what should happen if e.g. a custom font was set globally, and another style with only a fill color set was used on a cell. Right now I think the expectation would be that the cell would get both the custom font from the global style and the fill color from the other style. In that case we would have to make sure there is also a way to avoid using the global style for a cell.

It shouldn't be necessary to create duplicate styles the way things work now. You should be able to create the styles you need once, and then pass StyleId to the cells.

@goremykin
Copy link
Author

goremykin commented May 20, 2024

Right now I think the expectation would be that the cell would get both the custom font from the global style and the fill color from the other style

Fully agree. Also what to do in case of conflict? For example global font size is 10 but I specify font size 12 for a cell. In this case I expect cell styles to have higher priority.

It shouldn't be necessary to create duplicate styles the way things work now

I mean I have to duplicate global styles in each style declaration. Not a problem at all, just nice to have.

var headerStyle = new Style();
headerStyle.Font.Size = 14; // duplicated

var someCellStyle = new Style();
someCellStyle.Font.Size = 14; // duplicated

var anotherCellStyle = new Style();
anotherCellStyle.Font.Size = 14; // duplicated

@sveinungf
Copy link
Owner

Also what to do in case of conflict? For example global font size is 10 but I specify font size 12 for a cell. In this case I expect cell styles to have higher priority.

Yes I agree. The most specific font size should be used.

I mean I have to duplicate global styles in each style declaration. Not a problem at all, just nice to have.

Ah, I see. Style is a record so maybe a with-expression could work? E.g.

var defaultStyle = new Style();
defaultStyle.Font.Size = 14;

var someCellStyle = defaultStyle with
{
    Font.Bold = true
};

@goremykin
Copy link
Author

@sveinungf, So sweet and neat option! Thanks!

@sveinungf sveinungf added the enhancement New feature or request label Jul 5, 2024
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

2 participants