Determining rows and columns with data in it

I need to be able to read Excel files that I dont know how many columns or rows of data it contains. Can your excel product help and if so how?

Thanks
Adrian

Hi Adrian,

You can try to use Cells.MinRow, Cells.MaxRow, Cell.MinColumn,Cells.MaxColumn properties.

@gordona,
Aspose.Excel is discarded and no more available now. You may use our new product Aspose.Cells that is much advanced and better in performance. It provides all the features of its predecessor along with the support for the latest features in different versions of MS Excel. It contains large number of APIs providing information about the rows and columns in a workbook. Here is an example that can be used to retrieve your desired information using Aspose.Cells.

Workbook workbook = new Workbook();
Cells cells = workbook.Worksheets[0].Cells;
cells["D3"].Value = "D3 Data";
cells["F4"].Value = "F4 Data";
Console.WriteLine("MaxDisplayRange = " + cells.MaxDisplayRange);

Console.WriteLine("MinRow = " + cells.MinRow);
Console.WriteLine("MinColumn = " + cells.MinColumn);
Console.WriteLine("MinDataRow = " + cells.MinDataRow);
Console.WriteLine("MinDataColumn = " + cells.MinDataColumn);

Console.WriteLine("MaxRow = " + cells.MaxRow);
Console.WriteLine("MaxColumn = " + cells.MaxColumn);
Console.WriteLine("MaxDataRow = " + cells.MaxDataRow);
Console.WriteLine("MaxDataColumn = " + cells.MaxDataColumn);
workbook.Save("RowsColsWithData.xlsx");

Program Output
MaxDisplayRange = Aspose.Cells.Range [ Sheet1!A1:F4 ]
MinRow = 2
MinColumn = 3
MinDataRow = 2
MinDataColumn = 3
MaxRow = 3
MaxColumn = 5
MaxDataRow = 3
MaxDataColumn = 5

Program Output File

For more information about working with cells collection, refer to the following API Reference:
cells

Give a try to this new product by downloading the latest free trial version here:
Aspose.Cells for .NET(Latest version)

You may download a runnable solution here for detailed testing of this new product.