How to find all cells with content in excel sheet

I want to find all data in an excel sheet but I do not know how many rows/columns actually have data. So is there a method for doing so in apose.cells. I have found

DataTable dataTable = worksheet.Cells.ExportDataTable(0, 0, 10, 7, true); and that works great except that I would like aspose to automatically detect what the values instead of 10 and 7 should be when processing a new sheet.

Or maybe I should use a completly different approach to extract data from a sheet?

thanks :-)

Hans Jørgen

Hi Hans,


Thank you for using Aspose APIs.

Please use the Cells.MaxDataRow & Cells.MaxDataColumn properties to dynamically find out the max row & column numbers of the data range on a worksheet. Try the following code and feel free to get back in case you have further questions.

C#

Aspose.Cells.Cells cells = sheet.Cells;
DataTable dataTable = sheet.Cells.ExportDataTable(0, 0, cells.MaxDataRow, cells.MaxDataColumn, true);

Works beautifully - thanks :slight_smile:

Hi Hans,


We are glad to help you out. Please feel free to get in touch if you need our further assistance with Aspose APIs.