public static IWorkbook AddErrors <T>(this IWorkbook workbook, IList <ExportExcelError> errors, Action <ICell, string> action = null) { string sheetName = null; var excelAttribute = typeof(T).GetCustomAttribute <ExcelAttribute>(); if (excelAttribute != null) { sheetName = excelAttribute.SheetName; } else { sheetName = nameof(T); } return(workbook.AddErrors(sheetName, errors, action)); }
public void Import() { using (var fs = File.Open("a.xlsx", FileMode.Open)) { IWorkbook ep = null; try { ep = workbookBuilder.CreateWorkbook(fs); var result = excelImportService.Import <Student1>(ep); } catch (ExportExcelException ex) { ep.AddErrors <Student1>(ex.ExportExcelErrors); FileStream fs1 = File.Create("b.xlsx"); ep.Write(fs1); fs1.Close(); } catch (Exception ex) { } } }