LinqToExcel,Row into Array [英] LinqToExcel, Row into Array
问题描述
我需要收集字符串中的所有行,我正在使用LinqToExcel查询,我还有许多其他操作需要使用LinqToExcel包。
我的问题是我无法在单个字符串中转换所有行值,
我的代码:
< pre lang =cs> var excelFile = new ExcelQueryFactory(Server.MapPath( Documents // Existing Users10.xlsx));
excelFile.DatabaseEngine = LinqToExcel.Domain.DatabaseEngine.Ace;
var list =( from a in excelFile.Worksheet( 现有用户)
选择 new MyClass
{
email = a [ 电子邮件]。Value.ToString(),
values = string .Join( ,,a.ToList()。选择(y = > y.Value))
})。ToList();
a.ToList()给我错误字典中没有给定的密钥。
谢谢
你好toLis t()方法会给你一个错误,因为它知道类型。
你有2个解决方案:
精确列表的类型:
ClassType List = ...
或
精确的返回类型:
...})。ToList< ClassType>();
类型是您正在使用的班级类型。
希望有帮助
I need to collect all rows in string, I am using LinqToExcel query, I have many others operation that I need to use LinqToExcel package.
My problem is that I am not able to convert all rows value in single string,
My code:
var excelFile = new ExcelQueryFactory(Server.MapPath("Documents//Existing Users10.xlsx"));
excelFile.DatabaseEngine = LinqToExcel.Domain.DatabaseEngine.Ace;
var list= (from a in excelFile.Worksheet("Existing Users")
select new MyClass
{
email= a["Email"].Value.ToString(),
values= string.Join(",", a.ToList().Select(y => y.Value))
}).ToList();
a.ToList() giving me error that The given key was not present in the dictionary.
Thanks
Hi the toList() method gives you an error because it dosent Know the type.
You have 2 solutions:
precise the type of the list :
ClassType List = ...
OR
precise the return type:
... }).ToList<ClassType>();
Type is the class type you are working with.
hope it helps
这篇关于LinqToExcel,Row into Array的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!