コード例 #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);
     WriteHandlerFactory.CreateHandler(version).CreateFile(sources, exportFieldsWithName, path);
 }
コード例 #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);
     WriteHandlerFactory.CreateHandler(version).CreateFile(sources, exportFields, path);
 }
コード例 #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(WriteHandlerFactory.CreateHandler(version).CreateBytes(sources, exportFieldsWithName));
 }
コード例 #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(WriteHandlerFactory.CreateHandler(version).CreateBytes(sources, exportFields));
 }
コード例 #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(WriteHandlerFactory.CreateHandler(version).CreateBytes(sources));
 }
コード例 #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(WriteHandlerFactory.CreateHandler(version).CreateMemoryStream(sources));
 }
コード例 #7
0
 /// <summary>
 /// 生成Excel文件,暂时只支持 Excel2007
 /// </summary>
 /// <param name="sources">数据源</param>
 /// <returns></returns>
 public static byte[] CreateBytes(DataTable sources)
 {
     return(WriteHandlerFactory.CreateHandler(ExcelVersion.Excel2007).CreateBytes(sources));
 }
コード例 #8
0
 /// <summary>
 /// 生成Excel文件,暂时只支持 Excel2007
 /// </summary>
 /// <param name="sources">数据源</param>
 /// <param name="path">文件路径</param>
 /// <returns></returns>
 public static void CreateFile(DataTable sources, string path)
 {
     CheckPath(path);
     WriteHandlerFactory.CreateHandler(ExcelVersion.Excel2007).CreateFile(sources, path);
 }
コード例 #9
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);
     WriteHandlerFactory.CreateHandler(version).CreateFile(sources, path);
 }