Click here to Skip to main content
15,914,780 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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:

C#
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
Posted

1 solution

Hi the toList() method gives you an error because it dosent Know the type.
You have 2 solutions:

precise the type of the list :
C#
ClassType List = ...


OR

precise the return type:

C#
...  }).ToList<ClassType>();


Type is the class type you are working with.

hope it helps
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900