MaxRow changed while getting string value located outside of the MaxRow

Dear Aspose Support Team,


I would like to raise a concern on Worksheet.Cells.MaxRow

ENVIRONMENT:
Aspose 9.0.7.0
Excel 2016
VS 2012 Express
.Net 3.5

PROBLEM (?):
The value of maxRow of a worksheet will be affected
if I access StringValue (ReadOnly) of a Cell outside maxRow

Expect Result:
MaxRow should not be affected (?)

Result:
MaxRow increased to the value I have just visited.
MarRow returned to normal after saving and re-opening.

<div style=“color: rgb(0, 0, 0); font-family: “Times New Roman”; font-size: medium;”>( I am not sure about if this is a desired feature or not,
<div style=“color: rgb(0, 0, 0); font-family: “Times New Roman”; font-size: medium;”>if so, would you mind explaining the thought behind this?)

Code
Workbook wb = new Workbook();
Worksheet ws = wb.Worksheets[0];

// ws.Cells.MaxRow == -1;

string abc = null;
abc = ws.Cells[100, 0].StringValue;

// ws.Cells.MaxRow == 100;

Regards,
Jonathan Lau
<div style=“color: rgb(0, 0, 0); font-family: “Times New Roman”; font-size: medium;”>
<div style=“color: rgb(0, 0, 0); font-family: “Times New Roman”; font-size: medium;”>P.S. I can work around it for now so don’t worry

Hi,


Thanks for your posting and using Aspose.Cells.

For performance reason, we do not create cell unless they are accessed. So when you accessed the cell i.e Cells[100, 0], this cell was instantiated and the MaxRow became 100.

Please check the following code that will clarify this behavior to you.

C#
//At this moment c is null, because it was never accessed
Cell c = ws.Cells.CheckCell(100, 0);

string abc = null;
abc = ws.Cells[100, 0].StringValue;

//But this moment c is not null because it has been accessed in above lines
c = ws.Cells.CheckCell(100, 0);