public void Export(ExportBook book, Stream stream) { if (stream == null) { throw new Exception("stream is null"); } FillWorkBook(book); _workBook.Write(stream); }
public byte[] Export(ExportBook book) { FillWorkBook(book); using (var stream = new MemoryStream()) { _workBook.Write(stream); return(stream.ToArray()); } }
private void FillWorkBook(ExportBook book) { if (!book.Sheets?.Any() ?? true) { throw new Exception("sheets is empty"); } _workBook = WorkbookGenerator.GetIWorkbook(book.Ext); foreach (var item in book.Sheets) { this.CreateSheet(item.Data.GetType().GetGenericArguments()[0], item.SheetName, item.Title, item.Data?.ToList(), item.FilterColumn?.ToList()); } }
public Stream Export(ExportBook book, Stream stream) { if (stream == null) { throw new Exception("stream is null"); } if (!book.Sheets?.Any() ?? true) { throw new Exception("sheets is empty"); } IWorkbook workbook = WorkbookGenerator.GetIWorkbook(book.Ext); foreach (var item in book.Sheets) { this.CreateSheet(workbook, item.SheetName, item.Title, item.Data, item.FilterColumn); } workbook.Write(stream); workbook.Close(); return(stream); }