How to fetch Row from excel workbook which has maximum data in it

Hello,

I want to get a row from xlsx workbook which has maximum data in it. I am using below code (cells.getMaxDataRow()) but which is returning last row in workbook.

workbook = new Workbook(sourceFilePath);
com.aspose.cells.WorksheetCollection sheets = workbook.getWorksheets();
Worksheet worksheets = sheets.get(0);
com.aspose.cells.Cells cells = worksheets.getCells();
int maxDatarow = cells.getMaxDataRow();

Could you please help me on this?

@dnyandevp,

Please note, MaxDataRow will return farthest row index (zero based) which has some data (e.g., string, numeric, Boolean, etc.) in it. It does not give you row/col/cell which has maximum data, maximum number of characters or highest value(s). So, you should understand the property as we explained. To get a row index which has more/maximum data, you got to write your own code or logic accordingly for it. For example, you may loop through rows and evaluate and gather the length of each cell’s data/text or string to know which row has more data in it.