Example #1
0
 public byte[] StreamExcelDocument <T>(List <T> data) where T : class, new()
 {
     using (var stream = new MemoryStream())
         using (var document = SpreadsheetDocument.Create(stream, SpreadsheetDocumentType.Workbook, true))
         {
             var ds = new DataSet();
             ds.Tables.Add(EPCore.ListToDataTable(data));
             document.WriteExcelFile(ds, Stylesheet);
             return(stream.ToArray());
         }
 }
Example #2
0
 public byte[] StreamExcelDocument <T>(Dictionary <string, List <T> > sheetsData) where T : class, new()
 {
     using (var stream = new MemoryStream())
         using (var document = SpreadsheetDocument.Create(stream, SpreadsheetDocumentType.Workbook, true))
         {
             var ds = new DataSet();
             foreach (var data in sheetsData)
             {
                 ds.Tables.Add(EPCore.ListToDataTable(data.Value, data.Key));
             }
             document.WriteExcelFile(ds, Stylesheet);
             return(stream.ToArray());
         }
 }