Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get row count if there is only one sheet #99

Open
JavaGuruLMKR opened this issue May 29, 2017 · 1 comment
Open

How to get row count if there is only one sheet #99

JavaGuruLMKR opened this issue May 29, 2017 · 1 comment

Comments

@JavaGuruLMKR
Copy link

I am getting correct row count if there are two or more sheets but getting always 0 if there is only one sheet. I am executing this code.

Sheet sheet = workbook.getSheet(sheetName);
int rowCount = sheet.getLastRowNum();

Please suggest some solution.

Regards,

Mubashar Ahmad

@NiharGharat
Copy link

You can use a counter variable to count the row.next(), but the tradeoff is that you need to iterate over the sheet, and "exhaust" the rowIterator object. See #97 if your need is to reuse it. One issue is that the row iterator skips empty rows.

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

No branches or pull requests

2 participants