Closed GoogleCodeExporter closed 8 years ago
Can you share the lines of code you are using.
That will help me debug the issue.
Original comment by paulyo...@gmail.com
on 12 Dec 2011 at 2:24
I also found this issue at 1.5.4 version.
Code example:
var excel = new ExcelQueryFactory();
excel.FileName = "Test.xlsx";//file has more then two rows
excel.AddMapping<ExcelDataModel>(x => x.Id, "Id");
var records = excel.Worksheet<ExcelDataModel>(sheetName);
Console.WriteLine("Total count " + records.Count());
var recordsWithSkip = excel.Worksheet<ExcelDataModel>(sheetName).Skip(1);
//next row throw error. foreach doesn't work too
Console.WriteLine("Skip count " + recordsWithSkip.Count());
//Workaround: use ToList()
//Console.WriteLine("Skip count " + recordsWithSkip.ToList().Count);
Original comment by kolpakov...@gmail.com
on 30 Dec 2011 at 8:03
You will need to call ToList() before you call Skip().
var records = excel.Worksheet<ExcelDataModel>(sheetName).ToList();
Console.WriteLine("Total count " + records.Count);
var recordsWithSkip =
excel.Worksheet<ExcelDataModel>(sheetName).ToList().Skip(1);
//next row throw error. foreach doesn't work too
Console.WriteLine("Skip count " + recordsWithSkip.Count);
Original comment by paulyo...@gmail.com
on 30 Dec 2011 at 2:39
I see. I suggest it isn't normal for the linq. Am I wrong?
Original comment by kolpakov...@gmail.com
on 31 Dec 2011 at 7:56
Yea, using Skip() in linq is normal.
Creating a custom linq provider that implements all the linq methods natively
is extremely difficult and time consuming, so I've had to strike a balance
between how many linq methods that are natively implemented verses how much
time I have to implement each one.
Skip is one of those linq methods that I haven't implemented in LinqToExcel.
Fortunately there is an easy workaround that allows you to get the same
functionality. You just have to call ToList() before calling Skip()
LinqToExcel is open source, and the nice thing about open source projects is
that you can contribute code to them to provide the functionality you want, and
you are more than welcomed to submit a pull request that implements the Skip
functionality :-)
Original comment by paulyo...@gmail.com
on 31 Dec 2011 at 12:41
Original issue reported on code.google.com by
LindsayM...@gmail.com
on 12 Dec 2011 at 5:37