poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "DRINKARD, JAMES E (SBCSI)" <jd4...@sbc.com>
Subject RE: Dynamically create worksheets
Date Fri, 07 Mar 2003 15:36:32 GMT
I read the api, just was having problems getting my code to compile. This is
the solution I figured out where I was
having problems:

	int sheetIndex = wb.getSheetIndex(String name goes here);
	HSSFRow row = wb.getSheetAt(sheetIndex).createRow((short)i++);

I guess because of the setup of my try and while blocks I couldn't resolve
my worksheet object without a reference to the workbook object: wb. It's
working great now!

James


-----Original Message-----
From: Steve [mailto:stephen@Basit.COM]
Sent: Thursday, March 06, 2003 5:30 PM
To: POI Users List
Subject: Re: Dynamically create worksheets


There are different approaches possible.
It depends on whether you need to have graphics, and need to start with a
template.
It's simpler if you don't need that capability.

When you create a sheet, you can give it a name:
createSheet(java.lang.String sheetname)
When you create it, you have the object reference, so you can do anything
you want with it.
But, if you lose the reference, you can get it via
getSheet(java.lang.String name)
You can also get the 0-based index of any sheet by:
getSheetIndex(java.lang.String name)
and, when you know the index, you can get the name
getSheetName(int sheet)
to get the actual HSSFSheet, you can get it by either index or by name:
 HSSFSheet getSheet(java.lang.String name)
          Get sheet with the given name
 HSSFSheet getSheetAt(int index)
          Get the HSSFSheet object at the given index.
I assume you have the JAVADOC API on your PC, which is indexed at:
\build\docs\javadocs\index.html
after you install the release.


----- Original Message -----
From: "DRINKARD, JAMES E (SBCSI)" <jd4147@sbc.com>
To: <poi-user@jakarta.apache.org>
Sent: Thursday, March 06, 2003 5:19 PM
Subject: Dynamically create worksheets


> Hello All,
> I am trying to come up with a way to dynamically create worksheets, as the
> number of sheets isn't fixed, for a java report generating program I
> developed. I'm using POI version 1.5.0. to create an xls spreadsheet that
I
> populate with an resultset. I've been able to create multiple sheets, but
I
> don't know how to reference them in the code, without hard coding each one
> and therefore cannot populate them. Any ideas as to the best way to do
this?
>
> James
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: poi-user-help@jakarta.apache.org
>


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

Mime
View raw message