poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steve" <step...@Basit.COM>
Subject Re: Cannot write to extra sheets
Date Tue, 17 Jun 2003 18:05:25 GMT
if the sheet exists, you don't want to create it.
you want to use

 wb is the Workbook object
sheetnumber is the int sheetnumber you want
 String sheetname = wb.getSheetName(sheetnumber);
 HSSFSheet sheet = wb.getSheet(sheetname);

now that you have the sheet, you can operate on it.

----- Original Message -----
From: <Clifton.Craig@rrd.com>
To: "POI Users List" <poi-user@jakarta.apache.org>
Sent: Tuesday, June 17, 2003 10:46 AM
Subject: Re: Cannot write to extra sheets


>
> Does anybody have any clue as to how I can handle this scenario? Is there
> even a quick and easy way to test for a "new" or "empty" spreadsheet so
> that I can at least have my code delete the sheet prior to re-creating it?
> Is the a way to shuffle or re-organize sheets in a workbook? I'm stuck on
> this. Please help.
>
> Thanks in advance,
> -Cliff
>
>
>
>                       Clifton.Craig@rrd
>                       .com                     To:       "POI Users List"
<poi-user@jakarta.apache.org>
>                                                cc:
>                       06/16/2003 11:55         Subject:  Re: Cannot write
to extra sheets
>                       AM
>                       Please respond to
>                       "POI Users List"
>
>
>
>
>
>
>
> I don't think creating the sheet is appropriate in this scenario. I have 3
> sheets in a brand new workbook. The 1st sheet has some data on it and I
> need to write to the 2nd sheet leaving the 3rd sheet blank. If I do a
> createSheet("Sheet2") I end up with two Sheet2's where the one I create in
> POI is at the end. There is no method createSheetAt(int idx) available to
> create a sheet over an existing sheet. Now if there was some easy way to
> test for this condition then maybe I could delete/rewrite the sheet in
> question but it would be a good solution. I'd have problems getting the
new
> sheet in the correct order. If you consider a workbook with these "new"
> sheets intermingled and sporadically placed throughout other used sheets
> then it becomes a real nightmare. What do I do?
>
> -Cliff
>
>
>
>                       "Steve"
>                       <stephen@Basit.CO        To:       "POI Users List"
>                       <poi-user@jakarta.apache.org>
>                       M>                       cc:
>                                                Subject:  Re: Cannot write
>                       to extra sheets
>                       06/16/2003 10:34
>                       AM
>                       Please respond to
>                       "POI Users List"
>
>
>
>
>
>
> it doesn't create extra sheets. only the space for them.
> you need to create all sheets that you want,
> as far as I know.
>
> ----- Original Message -----
> From: <Clifton.Craig@rrd.com>
> To: <poi-user@jakarta.apache.org>
> Sent: Monday, June 16, 2003 8:59 AM
> Subject: Cannot write to extra sheets
>
>
> > Hello all,
> >
> > I am having a problem writing to the extra sheets that Excel creates by
> > default when you create a new workbook. I'm using the
> > jakarta-poi1.8.0-dev-20020919.jar version. I've developed a conversion
> > program that allows data to be merged with existing spreadsheets. The
> merge
> > works when I attempt to write on a sheet that has already been written
> on.
> > However, whenever I attempt to write to one of the blank sheets (sheets
2
> > and 3) that Excel creates automatically with an empty workbook it
doesn't
> > work. I can adjust the width of cells in these sheets but they do not
> > retain any info from the  cell.setCellValue() method calls. I verified
in
> > debug that these methods are not failing. My debugger (Eclipse) allows
me
> > to see the cell values before and after the method calls. I've attempted
> > many tests where I enter the exact same parameters to merge data to an
> > existing workbook changing only the sheet number. The data is retained
> only
> > on the 1st sheet where I've already added data. This is the only
variance
> > in my test runs. In all cases I obtain references to the sheet, row and
> > cell objects the same way. I do a Workbook.getSheetAt(int num) to get
the
> > existing sheet. (I've tried with Workbook.getSheet(String name) as
well.)
> I
> > am using Worksheet.createRow(short row) to create the row and
> > Row.createCell(short cell) to create cell references. In my code I
verify
> > that the rows and cells do not exist prior to creating. In the latter
> case
> > I use the corresponding methods to obtain references to the existing
> > objects. What am I missing?
> >
> > -Cliff
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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
>
>
>
>
>
>
> ---------------------------------------------------------------------
> 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