C# Linq To Excel Getting Table Data Not Starting In The First Row
I'm developing a MVC 4 web application and one of the requirements is to allow users to upload an excel file which is in a standard format and extract data and save that to a database. I have used linq to excel to read data off of the excel. This works fine provided that the table that I'm extracting data from starts from the first row of the excel sheet.
var details = from c in excel.Worksheet<ContributionScheduleExcelFormat>() select c;
Now my question is how can we still return the same data if say the table headers starts on the third row? Basically some extra information needs to be reflected on the first two rows so that's why my the table in the excel sheet needs to start from the third row now. I believe there is a function already available to get data from a range of cells.
var details = from c in excel.WorksheetRange<ContributionScheduleExcelFormat>(startRange, endRange) select c;
But how would I get the endRange value?
I'm new to linq to excel so please any assistance would be greatly appreciated. Thanks in advance.
For the sake of others that may have this same issue:
Turns out that you can't actually do this at the moment. The only solution is to specify an end range that you know your excel sheet data will not exceed. For example:
var details = from c in excel.WorksheetRange<ContributionScheduleExcelFormat>("A3", "G16000") select c;
It's not pretty at all and personally just looking at it makes me feel uncomfortable but that's the only way right now.