You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by RonnieSpike <ro...@nerdshack.com> on 2008/08/29 19:41:10 UTC

HOWTO Read only the first, or one, worksheet

Hi,

We process excel workbooks that begin as templates for our users, templates
whose drop-down lists are maintained on the 2nd worksheet or tab of the
workbook. In processing the workbook, the 2nd worksheet is also being
processed - not what we want. Does anyone have an example or guidance on how
to process the first (or any particular) worksheet or tab of the workbook?
Thanks!

Ronnie
-- 
View this message in context: http://www.nabble.com/HOWTO-Read-only-the-first%2C-or-one%2C-worksheet-tp19224451p19224451.html
Sent from the POI - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: HOWTO Read only the first, or one, worksheet

Posted by RonnieSpike <ro...@nerdshack.com>.
I'm using the Event model. The link
http://article.gmane.org/gmane.comp.jakarta.poi.user/1705 was helpful in
determining that I needed to track the BoundSheetRecord and BOFRecord (Sheet
type) sids so I'd know which sheets, by name, to skip.
-- 
View this message in context: http://www.nabble.com/HOWTO-Read-only-the-first%2C-or-one%2C-worksheet-tp19224451p19300037.html
Sent from the POI - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: HOWTO Read only the first, or one, worksheet

Posted by Anthony Andrews <py...@yahoo.com>.
Have a look at the two getSheetAt() methods defined in the HSSFWorkbook class. One will allow you to recover a sheet by passing it's name to the method, the other by passing it's index - and remember that as with arrays in Java, that index number is zero based. So, to get a particular sheet, all you need to do is;

* Open the workbook
* Call the getSheetAt() method and store the returned HSSFSheet reference into a variable.
* Process the sheet

It may also be worth looking at the getNumberOfSheets() method. This will return an int value that indicates how many sheets there are in the workbook and I can imagine a situation where you want the final sheet for instance without knowing how many the user may have inserted in front of it.

--- On Fri, 8/29/08, RonnieSpike <ro...@nerdshack.com> wrote:
From: RonnieSpike <ro...@nerdshack.com>
Subject: HOWTO Read only the first, or one, worksheet
To: user@poi.apache.org
Date: Friday, August 29, 2008, 10:41 AM

Hi,

We process excel workbooks that begin as templates for our users, templates
whose drop-down lists are maintained on the 2nd worksheet or tab of the
workbook. In processing the workbook, the 2nd worksheet is also being
processed - not what we want. Does anyone have an example or guidance on how
to process the first (or any particular) worksheet or tab of the workbook?
Thanks!

Ronnie
-- 
View this message in context:
http://www.nabble.com/HOWTO-Read-only-the-first%2C-or-one%2C-worksheet-tp19224451p19224451.html
Sent from the POI - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org