public static Workbook AddErrors <T>(this Workbook ep, IList <ExportExcelError> errors, Action <CellRange, string> action = null) { string sheetName = null; var excelAttribute = typeof(T).GetCustomAttribute <ExcelAttribute>(); if (excelAttribute != null) { sheetName = excelAttribute.SheetName; } else { sheetName = nameof(T); } return(ep.AddErrors(sheetName, errors, action)); }
public void Import() { Workbook wb = null; try { using (var fs = File.Open("spirea.xlsx", FileMode.Open)) wb = workbookBuilder.CreateWorkbook(fs); var result = excelImportService.Import <Student>(wb); } catch (ExportExcelException ex) { wb.AddErrors <Student>(ex.ExportExcelErrors); wb.SaveToFile("spireb.xlsx"); } catch (Exception ex) { } }