public void LoadGeneric <T>(List <T> obj, string sheetName = "Sheet1") { this.controlAdapter.ChangeCursor(CursorStyle.Busy); try { GenericFormatProvider <T> genericProvider = new GenericFormatProvider <T>(); var arg = new GenericFormatArgument { SheetName = sheetName, //Stylesheet = stylesheet, }; Clear(); genericProvider.Load(this.workbook, obj, arg); } finally { this.controlAdapter.ChangeCursor(CursorStyle.PlatformDefault); } }
public void Load(IWorkbook workbook, List <T> obj, object arg) { bool autoSpread = true; string sheetName = String.Empty; int bufferItems = DEFAULT_READ_BUFFER_ITEMS > obj.Count ? obj.Count : DEFAULT_READ_BUFFER_ITEMS; RangePosition targetRange = RangePosition.EntireRange; GenericFormatArgument genericArg = arg as GenericFormatArgument; if (genericArg != null) { sheetName = genericArg.SheetName; targetRange = genericArg.TargetRange; } Worksheet sheet = null; if (workbook.Worksheets.Count == 0) { sheet = workbook.CreateWorksheet(sheetName); workbook.Worksheets.Add(sheet); } else { while (workbook.Worksheets.Count > 1) { workbook.Worksheets.RemoveAt(workbook.Worksheets.Count - 1); } sheet = workbook.Worksheets[0]; sheet.Reset(); } this.Read(obj, sheet, targetRange, bufferItems, autoSpread); // ApplyStyles(sheet, genericArg.Stylesheet); }