-
Notifications
You must be signed in to change notification settings - Fork 16
Supported Expresssion Types
Jonathan Paré edited this page Feb 26, 2017
·
1 revision
To keep things simple and avoid code repetition, EPPlusExporter support both MemberExpression and NewExpression
MemberExpression: n => n.Prop1
NewExpression: n => new { n.Prop1, n.Prop2 }
var data = new[]
{
new { TextValue = "Text #1", DateValue = DateTime.Now, DoubleValue = 10.1, IntValue = 1},
new { TextValue = "Text #2", DateValue = DateTime.Now, DoubleValue = 10.2, IntValue = 2},
new { TextValue = "Text #3", DateValue = DateTime.Now, DoubleValue = 10.3, IntValue = 3},
new { TextValue = "Text #4", DateValue = DateTime.Now, DoubleValue = 10.4, IntValue = 4}
};
//configure the exporter
var exporter = EnumerableExporter.Create(data)
.NumberFormatFor(n => n.DateValue, "yyyy-mmm-dd") //MemberExpression for single column
.NumberFormatFor(n => new
{
n.DoubleValue,
n.IntValue
}, "0.00"); //NewExpression to assign the same format to 2 columns
- Getting started
- Working with:
- Customizations
- Goodies
- Supported Expressions
- DisplayNameAttribute