Skip to content

Instantly share code, notes, and snippets.

@derans
Created September 23, 2012 22:14
Show Gist options
  • Save derans/3773231 to your computer and use it in GitHub Desktop.
Save derans/3773231 to your computer and use it in GitHub Desktop.
Specific Columns & Formatting with Helper Method
public ActionResult ExportToExcel()
{
var records = _getSampleInfoQuery.Execute();
var columns = new[]
{
Column(x => x.College),
Column(x => x.Amount, ExcelFormat.Money),
Column(x => x.CreatedDate, ExcelFormat.Date, "Date"),
Column(x => x.CreatedBy),
Column(x => x.CreatedDate, ExcelFormat.Time, "Time"),
Column(x => x.PercentageExample, ExcelFormat.Percent),
};
return new ExcelFileResult<SampleInfo>(records) {ColumnDefinitions = columns};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment