Get Maximum Row/Column Count

Hi,

Is there an easier way to get the maximum number of rows or columns supported in Aspose? Currently this is what I do:

var maxRowCount = worksheet.Cells.CreateRange(0, 1, true).RowCount;

Thanks!
-Steve

Hi Steve,

Well, If you need to find out the last row/column with data in a worksheet, the Cells.MaxDataRow and Cells.MaxDataColumn methods can be used that return the farthest indexes of rows and columns which contain data only, so, if a cell having null value but have some formattings applied or merged won’t be included. Furthermore, you may use Cells.MaxRow and Cells.MaxColumn methods that return the farthest row/column indexes which contain data or style.

Sample code:

var maxRowCount = worksheet.Cells.MaxDataRow;


Feel free to contact us any time if we can be of any further help.

Thank you.

max_row = ws.Cells.MaxDataRow

when i am trying to run above command in jupyter using python, i am facing AttributeError as below;

‘com.aspose.cells.Worksheet’ object has no attribute ‘Cells’

Below is my complete code please check and help me out with this

wb = api.Workbook(“sample.xls”)
ws = wb.getWorksheets().get(0)

max_row = ws.Cells.MaxDataRow
print(max_row)

@asposeLegit,

Please change it to:

max_row = ws.getCells().getMaxDataRow()
1 Like

Thank you so much your suggestion is worked.

I have one more query, which method or function should i use, to get the list of sheet in a single workbook and also function to delete the sheet in the excel or can you suggest something to read from asopsecells documentation.

@asposeLegit,

To get worksheet list in the workbook, you may loop through WorksheetCollection and get each worksheets. Also, you may get sheet’s name via Worksheet.getName method. See the document on how to manage (access, add or remove) worksheets for your reference.