static void BuildSpreadsheet(ExcelDocumentRequest <T> Request) { var header = new HeaderBuilder <T>(Request); var body = new BodyBuilder <T>(Request, header); ExcelBuilder.Build <T>(Request.FileName, body, header); }
public BodyBuilder(ExcelDocumentRequest <T> Request, HeaderBuilder <T> Header) { BodyStyle = Request.BodyStyle; DataItems = Request.ItemsToExport; this.Header = Header; HeaderCellStyle = Request.HeaderStyle.CellStyle ?? Request.HeaderStyle.GenerateStyleObject(Request.Workbook); BodyCellStyle = BodyStyle.GenerateStyleObject(Request.Workbook); }
public Task <ExcelDocumentResponse> ExportToExcel(ExcelDocumentRequest <T> Request) { try { BuildSpreadsheet(Request); using var ms = new MemoryStream(); Request.Workbook.Write(ms); return(Task.FromResult( new ExcelDocumentResponse(Request.FileName) { SpreadSheetBytes = ms.ToArray(), })); } catch (Exception ex) { return(Task.FromResult(new ExcelDocumentResponse(ex))); } }
public HeaderBuilder(ExcelDocumentRequest <T> Request) { EntityType = typeof(T); workBook = Request.Workbook; CellStyle = Request.HeaderStyle.GenerateStyleObject(workBook); }