Beispiel #1
0
 /// <summary>
 /// 生成Excel文件
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="sources">数据源</param>
 /// <param name="path">文件路径</param>
 /// <param name="exportFieldsWithName">需要导出的字段及自定义列名</param>
 /// <param name="version">excel版本,可不传,默认excel2007</param>
 /// <returns></returns>
 public static void CreateFile <T>(IEnumerable <T> sources, string path, Dictionary <string, string> exportFieldsWithName, ExcelVersion version = ExcelVersion.Excel2007)
 {
     CheckSources(sources);
     CheckPath(path);
     CheckExportFieldsWithName(exportFieldsWithName);
     ExcelHandlerFactory.CreateHandler(version).CreateFile(sources, exportFieldsWithName, path);
 }
Beispiel #2
0
 /// <summary>
 /// 生成Excel文件
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="sources">数据源</param>
 /// <param name="path">文件路径</param>
 /// <param name="exportFields">需要导出的字段,可不传,则导出所有字段</param>
 /// <param name="version">excel版本,可不传,默认excel2007</param>
 /// <returns></returns>
 public static void CreateFile <T>(IEnumerable <T> sources, string path, ICollection <string> exportFields, ExcelVersion version = ExcelVersion.Excel2007)
 {
     CheckSources(sources);
     CheckPath(path);
     CheckExportFields(exportFields);
     ExcelHandlerFactory.CreateHandler(version).CreateFile(sources, exportFields, path);
 }
Beispiel #3
0
 /// <summary>
 /// 导出字节数组
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="sources">数据源</param>
 /// <param name="exportFieldsWithName">需要导出的字段及自定义列名</param>
 /// <param name="version">excel版本,可不传,默认excel2007</param>
 /// <returns></returns>
 public static byte[] CreateBytes <T>(IEnumerable <T> sources, Dictionary <string, string> exportFieldsWithName, ExcelVersion version = ExcelVersion.Excel2007)
 {
     CheckSources(sources);
     CheckExportFieldsWithName(exportFieldsWithName);
     return(ExcelHandlerFactory.CreateHandler(version).CreateBytes(sources, exportFieldsWithName));
 }
Beispiel #4
0
 /// <summary>
 /// 导出字节数组
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="sources">数据源</param>
 /// <param name="exportFields">需要导出的字段,不可为空</param>
 /// <param name="version">excel版本,可不传,默认excel2007</param>
 /// <returns></returns>
 public static byte[] CreateBytes <T>(IEnumerable <T> sources, ICollection <string> exportFields, ExcelVersion version = ExcelVersion.Excel2007)
 {
     CheckSources(sources);
     CheckExportFields(exportFields);
     return(ExcelHandlerFactory.CreateHandler(version).CreateBytes(sources, exportFields));
 }
Beispiel #5
0
 /// <summary>
 /// 导出字节数组
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="sources">数据源</param>
 /// <param name="version">excel版本,可不传,默认excel2007</param>
 /// <returns></returns>
 public static byte[] CreateBytes <T>(IEnumerable <T> sources, ExcelVersion version = ExcelVersion.Excel2007)
 {
     CheckSources(sources);
     return(ExcelHandlerFactory.CreateHandler(version).CreateBytes(sources));
 }
Beispiel #6
0
 /// <summary>
 /// 导出字节流
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="sources">数据源</param>
 /// <param name="version">excel版本,可不传,默认excel2007</param>
 /// <returns></returns>
 public static MemoryStream CreateMemoryStream <T>(IEnumerable <T> sources, ExcelVersion version = ExcelVersion.Excel2007)
 {
     CheckSources(sources);
     return(ExcelHandlerFactory.CreateHandler(version).CreateMemoryStream(sources));
 }
Beispiel #7
0
 /// <summary>
 /// 生成Excel文件
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="sources">数据源</param>
 /// <param name="path">文件路径</param>
 /// <param name="version">excel版本,可不传,默认excel2007</param>
 /// <returns></returns>
 public static void CreateFile <T>(IEnumerable <T> sources, string path, ExcelVersion version = ExcelVersion.Excel2007)
 {
     CheckSources(sources);
     CheckPath(path);
     ExcelHandlerFactory.CreateHandler(version).CreateFile(sources, path);
 }