Skip to content

Infragistics Community Forum / Cross Platform / Ultimate UI for Xamarin / How to get the range of Rows and Columns in Excel workbook ?

How to get the range of Rows and Columns in Excel workbook ?

New Discussion
Ankit Gupta
Ankit Gupta asked on Jul 31, 2014 7:51 PM

I am using the following code to import data from xlsx file:

Infragistics.Documents.Excel.Workbook.Load(Path to File);

Now, I want to show this workbook into an ultra grid, therefore, I read the worksheet cell by cell and then store in a data table, and then bind that to ultra grid. But to read that workbook cell by cell, I need to know the maximum number of rows and columns in the worksheet. To some extent I achieved this bu using nested loops, but suppose if the excel sheet has 9 rows and 9 columns but they do not start from a1 instead the rows extend from f10 to n10, and columns extend from f10 to f18, what should I do in this case ?

Sign In to post a reply

Replies

  • 0
    Dave Frischknecht
    Dave Frischknecht answered on Jul 31, 2014 7:51 PM

    Hello Ankit,

    Thank you for contacting Infragistics.

    If you modify the worksheet so the data you want to display is in a named table, you will be able to access the indices of the first and last rows of the table and the first and last columns of the table.

    For example, if you named your table "Table1", you would use a line of code similar to the following to get the index of the last row.

    workbook1.Worksheets[0].Tables["Table1"].WholeTableRegion.LastRow;

    The other three properties off the region are FirstRow, FirstColumn, and LastColumn.

    Please let me know if you have any other questions about this.

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Ankit Gupta
Favorites
0
Replies
1
Created On
Jul 31, 2014
Last Post
11 years, 7 months ago

Suggested Discussions

Tags

Created by

Created on

Jul 31, 2014 7:51 PM

Last activity on

Feb 24, 2026 2:22 PM