Closed GoogleCodeExporter closed 9 years ago
Yes it does. Here's an example.
var companyCities = from c in excel.Worksheet()
select new
{
Employees = c["EmployeeCount"].Cast<double>(),
Name = c["Name"].ToString()
};
Original comment by paulyo...@gmail.com
on 19 May 2011 at 10:00
Hi Paul,
By the way, create job with linqtoexcel. Thanks for your response.
Your solution was not quite what I meant. My program does not know the
fields(columns) that the user wants to select until run time. Whilst I realise
I can get these names using the excel.GetColumnNames method but that doesn't
help me "select" just these column names. [In your example you explicitly
return just the EmployeeCount and Name fields (defined at design and compile
time) which cannot be changed at runtime.]
The DynamicLINQ extension methods expose a Select method which has string
expression parameter that can be dynamically built at run time to return just
the fields required. However I'm not sure of the syntax to use within the
string or even if your Row class supports it.
Please see the link below for a better description of dynamic linq which I have
been refering to.
http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-
linq-dynamic-query-library.aspx
Thanks again
John
Original comment by johnfs...@googlemail.com
on 20 May 2011 at 6:42
I haven't heard of dynamic linq expressions before. Thanks for introducing me.
I don't know if LinqToExcel will work with dynamic linq expressions or not. Can
you provide an example of what you're thinking about doing?
Original comment by paulyo...@gmail.com
on 23 May 2011 at 3:39
Hi Paul,
Thanks for your response. I've extracted the simple code file that I'm
using as a test (frmTest.cs) and attached it. I've also attached the file
"Dynamic.cs" that has the dynamic linq extensions that I'm trying to use
which I downloaded from the internet. Just create a new winforms project with a
form with a button and a datagrid and lift the code from my frmTest.cs.
The code is pretty self explanatory and almost ("isn't it always") working.
Thanks
John
Original comment by johnfs...@googlemail.com
on 24 May 2011 at 9:24
Attachments:
Original issue reported on code.google.com by
johnfs...@googlemail.com
on 19 May 2011 at 6:58