Skip to content
This repository has been archived by the owner on Nov 24, 2020. It is now read-only.

row.LastCellNum is to high #84

Open
danny-p93 opened this issue Aug 29, 2018 · 2 comments
Open

row.LastCellNum is to high #84

danny-p93 opened this issue Aug 29, 2018 · 2 comments

Comments

@danny-p93
Copy link

Hello there,
i recently started working with NPOI and just did some experiments to get to know the Framework.
So i created a very simple xlsx file and looked how to get acces to the data.

Here is my code:

var sheet = WB.GetSheetAt(0);
int check = sheet.LastRowNum;
var r = sheet.GetRow(3);
var sb = new StringBuilder();
var cell = r.GetCell(4);
sb.AppendLine(string.Format("row  from {0} to {1}", sheet.FirstRowNum, sheet.LastRowNum));
sb.AppendLine(string.Format("Col from {0} to {1}", r.FirstCellNum, r.LastCellNum));

So nothing difficult.
with the following example file i expected
row from 0 to 5
col from 0 to 4
HelloWorld.xlsx

But actually LastCellNum says 5.
And when i looked into r.Cells (the array has the 4 expected cells) and jumped to the last cell it says ColumnIndex = 4.

At first i thought there is just an empty Cell in the next column but after i deleted the complete coloumn with ctrl+- the result was the same. And the number changed aswell as i added the last column with the random character.

@LeaFrock
Copy link

LeaFrock commented Sep 7, 2018

Aha, i'm also curious about this question. The 'CellNum' starts from 0 and ends with the actual max number plus 1.
In my opinion it's a mistake which cannot be corrected because a lot of people realize and obey it. If it changes, it may cause a large disaster for the projects using it. The developers cannot inform total users of the changes which aren't compatible to old versions.

@tonyqus

This comment was marked as abuse.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants