15

I'm using hssf api for reading data from xls files. But is there any way to get the exact no. of sheets in a workbook containing stored data?

Community
  • 1
  • 1
Supereme
  • 2,379
  • 12
  • 46
  • 67

1 Answers1

32

What does getNumberOfSheets return you?

Narayan
  • 6,031
  • 3
  • 41
  • 45
  • Thank U! It gave me the no. of sheets in the workbook but is there any way to know whether the sheet contains any data or not,means if there is data only in first sheet and not in other two then? Similarly is there any way to know the region occupied by the data in terms of rows and columns? – Supereme Jan 16 '10 at 16:14
  • 1
    @Supriya, You need to iterate through each Sheet in the workbook, then check whether the sheets contains rows, and then the rows containing cells contain any data, through the Enums provided by the HSSF class Check the Example given here http://www.javaworld.com/javaworld/javaqa/2002-05/01-qa-0503-excel3.html – Narayan Jan 18 '10 at 08:15
  • Thank you I got that and also could implement it successfully! :) – Supereme Jan 18 '10 at 14:30