Skip to content

Instantly share code, notes, and snippets.

@tarasn
Forked from bryanhunter/DumpToExcel.cs
Created June 26, 2013 20:25
Show Gist options
  • Save tarasn/5871295 to your computer and use it in GitHub Desktop.
Save tarasn/5871295 to your computer and use it in GitHub Desktop.
using System.Collections.Generic;
using System.IO;
using OfficeOpenXml; // (EPPLus - http://epplus.codeplex.com/)
namespace OfficeReports
{
public static class DumpToExcel
{
public static void Dump<T>(IEnumerable<T> data, string outputFilename)
{
var fileInfo = new FileInfo(outputFilename);
using (var package = new ExcelPackage(fileInfo))
{
var worksheet = package.Workbook.Worksheets.Add("Report");
worksheet.Cells["A1"].LoadFromCollection(data, true);
package.Save();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment