Open goremykin opened 4 months ago
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.
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
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
};
@sveinungf, So sweet and neat option! Thanks!
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.