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.

Answers


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.


Need Your Help

How to deal with functions returning objects with generic type in Scala

scala generics typeclass static-typing

Here's simplified example of something I'm trying to accomplish. I have a function that produces HashMap of different signature depending on type of Field object that is passed to it. I'm not sure ...

SQLalchemy/wtforms update issue - 400 bad request

python flask sqlalchemy jinja2

What I'm trying to do is, once the user submits all the results I want it to update the Fixture_prediction model according to my filters. Although what I get is 400 bad request. The log doesnt tell...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.