• Post Reply Bookmark Topic Watch Topic
  • New Topic

Apache POI  RSS feed

 
Luis Fernandes
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

can someone explain me how to list the number of rows that my file (C:\User\guest.xls) have, using the Apache POI tool ?

The only think that i need to know, is the number of rows.

best regards
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Reading and Rewriting Workbooks example shows how to open an XLS file, and get a reference to an HSSFSheet object. That object has a getLastRowNum method, which looks promising. Beware that it also has a getFirstRowNum method, which would seem unnecessary if things were as simple as they look.

The number of rows can be different for each sheet, so if you have multi-sheet files you may need to do this for each sheet.
 
bart zagers
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know you were asking about Apache POI,
but depending on your needs, JExcelApi could also be a good option.
 
Collins Mbianda
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi !!!

The method getLastRowNum
of HSSFSheet returns the last row on the sheet.
If you combine it with the method getFirstRowNum you will have the number of lines in the sheet.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!