MaxDataRow vs UsedRange


#1

The MaxDataRow for the file attached returns 86 (which is good, I really have 87 used rows in the sheet) but the UsedRange.Rows.Count with Excel returns 88. What can cause this?

Thank you

Alexandre


#2

Hi Alexandre,

What's UsedRange? I don't think Aspose.Cells provides such a property.


#3

I'm talking about the UsedRange in an Excel macro: ActiveSheet.UsedRange.Rows.Count

In the workbook attached to my previous message, with Aspose.Cells I deleted all the rows after row 87 (so 86 with Aspose.Cells) with the DeleteRows function. After that the MaxDataRow is 86, but with Excel, I have an additional row and the column borders appears on this row.


#4

I think that UsedRange.Rows.Count returns rows with data and format settings. Some cells of row 88 have up border. I think this makes the difference.


#5

But I deleted that row before saving the file.

There was borders and text in rows 88 and after, but I deleted all those rows.

But if I save the file, reopen it, delete the row and save it again, it works.

And the MaxRow should be 87 if I have something in this row?


#6

I checked your file and find a row record on row 88. How do you delete row 88?

Row 88 has a height of 12.75 and I find that default row height of that worksheet is 15. So a row record of row 88 is written to file.

MaxRow is still 86 because that no cell in row 88. It will return 87 if you put something in row 88.


#7

I found where was the error.

After I deleted the rows, I set a format to cells, even in the row 88.

Thank you.