1

I have been using LinqToExcel Library Lately and i came across this issue.

here is the code

  var excel = new ExcelQueryFactory(fileName);
  var dataList = (from c in excel.WorksheetRangeNoHeader("A1", "A4", "Test Worksheet")
                select c).ToList();

This dataList Collection Will have something like "Cat","Dog" ,"Fish" and "Goat"

Now All i want to do is assign Fish to a variable as an string by doing something like this

string temp=dataList[2];

However when i run the code i get the value of temp as "LinqToExcel.RowNoHeader". Anyone got idea on how to extract the actual value Fish into the variable temp.

Thanks in Advance

4

1 回答 1

1

Cracked it ! I was referring to the whole row rather than the first cell of each row. Therefore i needed C[0] in order to get the items.

 var excel = new ExcelQueryFactory(fileName);
 var dataList = (from c in excel.WorksheetRangeNoHeader("A1", "A4", "Test Worksheet")
            select c[0]).ToList();

And the extraction code will be

var temp=Convert.ToString(dataList[2]);
于 2014-07-01T10:58:20.267 回答