You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, it is not possible to use custom types as values for a cell without mapping model properties. I'd like to ask for the option to change this behavior. As an example:
public class ExampleExcelRow
{
/// <summary>
/// To type can be applied the style NumberFormat.TwoDecimalPlaces and the provider function can be used to round.
/// </summary>
[ColumnHeader("Money value")]
[CellStyle("MoneyStyleName")]
[CellValueConverter(typeof(NullToDashDataCellConverter<Money>))]
public Money MoneyType { get; set; }
/// <summary>
/// To type can be applied the style NumberFormat.TwoDecimalPlaces and the provider function can be used to round.
/// </summary>
[ColumnHeader("Percent value")]
[CellStyle("Percent style")]
[CellValueConverter(typeof(NullToDashDataCellConverter<Percent>))]
public Percent PercentType { get; set; }
/// <summary>
/// Just general case
/// </summary>
[ColumnHeader("A regular value")]
public decimal Regular { get; set; }
}
This can help to avoid manual mapping of object value to simple value, especially if the custom object has a ToString() overload. For me personally, it's more readable to have types for different numbers, like money, percent, numbers with dots, and maybe for someone else it's more readable too.
So it's can be smth like AllowCustomTypesAttribute to instruct src gen to use ToString(). As an example we can look at Mapperly library, they have similar functional for mappers. Or at least allow to use it with CellValueConverter
[WorksheetRow(typeof(SummaryReportExcelRow))]
[AllowCustomTypes]
internal partial class ExcelRowContext : WorksheetRowContext;
and in source gen:
cells[0] = new DataCell(obj.MoneyType?.ToString());
cells[1] = new StyledCell(new DataCell(obj.PercentType?.ToString()), styleIds[0]);
The text was updated successfully, but these errors were encountered:
Currently, it is not possible to use custom types as values for a cell without mapping model properties. I'd like to ask for the option to change this behavior. As an example:
This can help to avoid manual mapping of object value to simple value, especially if the custom object has a
ToString()
overload. For me personally, it's more readable to have types for different numbers, like money, percent, numbers with dots, and maybe for someone else it's more readable too.So it's can be smth like
AllowCustomTypesAttribute
to instruct src gen to useToString()
. As an example we can look at Mapperly library, they have similar functional for mappers. Or at least allow to use it withCellValueConverter
and in source gen:
The text was updated successfully, but these errors were encountered: