-
-
Save tarasn/5871295 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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