We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do I find the last row in a worksheet

Thread ID:

Created:

Updated:

Platform:

Replies:

100218 Jul 13,2011 09:27 PM UTC Jul 15,2011 12:56 PM UTC ASP.NET Web Forms (Classic) 3
loading
Tags: XlsIO
Mark Oudesluys
Asked On July 13, 2011 09:27 PM UTC

Hi,

I am looking for a simple way to find the last available row in a worksheet. In Excel 97To2003, it is around 65536, while Excel 2007/2010 it is 1048576.

Is there a function or command or something that I can use in a Range call, like:
IRange[] rHide = wsPage.Range[10, 1, xlLastCellRow, 1].Rows;

Thanks,
Mark


Jawahar Jeevanandan J [Syncfusion]
Replied On July 14, 2011 05:23 AM UTC

Hi Mark,

Thank you very much for using syncfusion products.

To find the last row used in a work sheet we have a property called UsedRange. Through this property we can find the first row, last row, first column and last column used in the work sheet. I have placed the code snippet below for the same.

Code Snippet(C#):

int firstRow = sheet.UsedRange.Row;
int lastRow = sheet.UsedRange.LastRow;
int firstColumn = sheet.UsedRange.Column;
int lastColumn = sheet.UsedRange.LastColumn;

In case of unused rows we can directly access the row through index of the range object. The following code snippet also explains the same.

Code Snipppet (C#):

IRange range = sheet.Range[1, 1, 1048576, 3];
range[1048576, 3].Value = "Syncfusion";

Please let us know if you have any clarifications.

Thanks,
Jawahar.


Mark Oudesluys
Replied On July 14, 2011 06:42 PM UTC

Hi,

Thanks for the response. That is helpful if I want to find the row or column of the last used cell in my worksheet. But what I was hoping for was some kind of function or variable which would return the maximum number of rows or columns available in a worksheet.

As I mentioned, depending on the source sheet version (97To2003 or 2007/2010) the maximum number of rows and columns is different and I was hoping there was a function/variable which would just return that. I was hoping to avoid having to hard code the values into my projects.

Thanks,
Mark


Jawahar Jeevanandan J [Syncfusion]
Replied On July 15, 2011 12:56 PM UTC

Hi Mark,

Thank you very much for using syncfusion products.

Currently we don't have support for providing maximum no rows or columns through properties or methods as this is known. We don't have any immediate plan to implement this feature. We will get back to you once the feature has been implemented in any of our upcoming releases. I have placed the link below which provides more detailed information about the query posted.

http://office.microsoft.com/en-us/excel/HA100778231033.aspx.

Please let us know if you any clarifications.

Thanks,
Jawahar.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;