Reputation: 1409
I'm looking at Linq to Excel tutorials and they all seem pretty simple and straightforward excpet all of them assume the excel table being used has all column headers neatly placed on row 1 and starting at column A.
I need to query data from excel files where the tables not only start around row 6 (some may start at lower rows) and have headers and subheaders (headers represent a specific place/company; subheaders represent column values for that place like id, stock remaining, sales made, etc.).
Is there any way to specify for the query which row holds the headers I want to use so it only takes information from beneath them?
Upvotes: 0
Views: 2586
Reputation: 10800
Can you just skip the number of rows you don't care about?
rows.Skip(1).Select(r => // Rest of your stuff here...
Better yet, query the appropriate range from the start like the LinqToExcel wiki suggests:
//Selects data within the B3 to G10 cell range
var indianaCompanies = from c in excel.WorksheetRange<Company>("B3", "G10")
where c.State == "IN"
select c;
Upvotes: 2