一、引用插件LumenWorks.Framework.IO.dll(CsvReader)
插件下载地址:https://pan.baidu.com/s/1c3kTKli 提取密码 dz7j
二、定义通用接口IExcelData.cs和IDataTransform.cs
IDataTransform.cs
public interface IDataTransform { List<Dictionary<string, string>> DataTableToDictionary(DataTable dt); }
IExcelData.cs
public interface IExcelData : IDataTransform { /// <summary> /// Excel工作薄所有表格转化成DataTable对应字典 /// </summary> Dictionary<string, DataTable> DataTableDictionary { get; } /// <summary> /// Excel工作薄所有表格的名称集合 /// </summary> List<string> SheetNames { get; } /// <summary> /// Excel工作薄所有表格数据集合 /// </summary> List<DataTable> DataTableList { get; } /// <summary> /// 表格数量 /// </summary> int SheetCount { get; } /// <summary> /// Excel文件路径 /// </summary> string FilePath { get; } /// <summary> /// Excel流 /// </summary> Stream ExcelStream { get; } /// <summary> /// Excel文件类型 /// </summary> ExcelType ExcelType { get; } /// <summary> /// 获取Excel第一列数据集合 /// </summary> List<Dictionary<string, string>> GetFirstRecords(); /// <summary> /// 执行方法 /// </summary> void Load(); }