MiniExcel的GetColumns仅返回标题的有效列(如果有5列就返回A,B,C,D,E五个字符),不能给出标题名
稍作修改:
private static FileStream MiniExcel_OpenSharedRead(string path) { return File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); } private static Dictionary<string, object> MiniExcel_GetColumns(string file) { IDictionary<string, object> dictionary = null; using (FileStream fileStream = MiniExcel_OpenSharedRead(file)) { dictionary = fileStream.Query(false, null, ExcelType.UNKNOWN, "A1", null).FirstOrDefault<object>() as IDictionary<string, object>; } var bbb = dictionary.ToDictionary(x => x.Key, x => x.Value); return bbb; }
获取标题名时用法如下
var bbb = MiniExcel_GetColumns(file).Values;//获取列名称
标签:dictionary,表格,MiniExcel,C#,GetColumns,标题,file,null From: https://www.cnblogs.com/xianghrs/p/17550085.html