/// <summary> /// Export object to excel file /// </summary> /// <typeparam name="TModel"></typeparam> /// <param name="data">a IEnumerable of TModel</param> /// <param name="path">excel full path</param> public static void ObjectToExcel <TModel>(IEnumerable <TModel> data, string path) where TModel : class, new() { var importer = new ExcelExporter(); var bytes = importer.ObjectToExcelBytes(data); File.WriteAllBytes(path, bytes); }
public static byte[] ObjectToExcelBytes(DataTable dt, ExcelType excelType, string sheetTitle = null) { var excelExporter = new ExcelExporter(); return(excelExporter.ObjectToExcelBytes(dt, excelType, sheetTitle)); }
/// <summary> /// Export object to excel bytes /// </summary> /// <typeparam name="TModel"></typeparam> /// <param name="data"></param> /// <param name="excelType"></param> /// <param name="sheetTitle"></param> public static byte[] ObjectToExcelBytes <TModel>(IEnumerable <TModel> data, ExcelType excelType, string sheetTitle = null) where TModel : class, new() { var excelExporter = new ExcelExporter(); return(excelExporter.ObjectToExcelBytes(data, excelType, sheetTitle)); }
/// <summary> /// Export object to excel bytes /// </summary> /// <typeparam name="TModel"></typeparam> /// <param name="data"></param> public static byte[] ObjectToExcelBytes <TModel>(IEnumerable <TModel> data) where TModel : class, new() { var importer = new ExcelExporter(); return(importer.ObjectToExcelBytes(data)); }