-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
Add options to provide custom fallback value for source generators #67
Comments
You're right, there is no way to do this right now when using the source generator. To do this right now you will have to map your type to For the source generator I'm considering how to offer more flexibility on how properties are mapped to cells. What I currently have in mind is to be able to define a mapping class with a specific shape, and then instruct the source generator to use it by using an attribute. For example like this: public class MyObject
{
[CellValueMapper(typeof(NullToDashMapper))]
public int? Number { get; set; }
}
public class NullToDashMapper : ICellValueMapper<int?>
{
public DataCell MapToCell(int? value)
{
return value is null ? new DataCell("-") : new DataCell(value.Value);
}
} This is not possible right now, but I think that could solve your use case and also many other possible use cases. |
What do you think about providing style in this way? If I need to add style to a cell, I need to pass the |
I'm currently working on #44 which will add support for named styles, and also a public API to get a style by its name. A mapping class like I suggested above could potentially handle styling by referencing style names. Having access to the |
This has been implemented in version 1.17.0. |
I'd like to have the ability to provide my own custom default value. For example, I need to make a report. I have a rule that if a number is null, then I need to fill the cell with a "-" character. But currently, I can't do it. If I set my number property to string, then in the Excel file it will also be a string. So I can't have all options for numbers that Excel has. But if my property is Nullable then I can't provide "-" character for it.
The text was updated successfully, but these errors were encountered: