예제 #1
0
        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);
        }
예제 #2
0
 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);
 }
예제 #3
0
        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)));
            }
        }
예제 #4
0
 public HeaderBuilder(ExcelDocumentRequest <T> Request)
 {
     EntityType = typeof(T);
     workBook   = Request.Workbook;
     CellStyle  = Request.HeaderStyle.GenerateStyleObject(workBook);
 }