Bug 11721 - [PATCH] multiply sheet
Summary: [PATCH] multiply sheet
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 2.0-dev
Hardware: All other
: P3 critical (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-08-15 13:37 UTC by Zsoldos Istv
Modified: 2004-11-16 19:05 UTC (History)
0 users



Attachments
Patch to add clone support for sheets (80.00 KB, patch)
2002-09-03 10:52 UTC, Jason Height
Details | Diff
Patch that add the clone support to graphing records and the record generator (42.62 KB, patch)
2002-09-04 04:05 UTC, Jason Height
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zsoldos Istv 2002-08-15 13:37:13 UTC
Hi

I use  POI 1.7. We'd need to generate an Excel Workbook with an
undefined no. of sheets. All sheets should use the same template.
I can't seem to find a method that allows me to make a copy of a
sheet (incl. content) and insert it into an existing workbook.

Also, I tried to open a template workbook with 80 sheets and delete
the sheets that are not needed. I can successfully read the file,
write all sheets properties to consol and save it without any
modifications, however, when I try to open it Excel 97 says
"an error occurs while initializin VBA libraries(2)".

Thanks for your help in advance

Istvan
Comment 1 Jason Height 2002-08-29 22:37:08 UTC
OK Id like to take responsibility for this one. (At least the clone sheet 
portion of it).

I did a quick hack and could clone a sheet just by maintaining references to 
the record objects, of course this meant that if the records on one sheet were 
changed the other did also ;-)

So what I would like to do is to include a clone method for any records that 
are passed into a Sheet. It would be similar to the following code:

    public Object clone() {
      IndexRecord rec = new IndexRecord();
      rec.field_1_zero = field_1_zero;
      rec.field_2_first_row = field_2_first_row;
      rec.field_3_last_row_add1 = field_3_last_row_add1;
      rec.field_4_zero = field_4_zero;
      rec.field_5_dbcells = new IntList();
      rec.field_5_dbcells.addAll(field_5_db_cells);
      return rec;
    }

Is that the best/easiest way to clone a record, It looks like it to me.

The problem lies with the code that has been automatically generated. I will 
ignore the automatically generated records at the moment but in due course 
someone may need to update the code that generated these to provide a deep 
clone method.

Thanks
Jason

Comment 2 Jason Height 2002-09-03 10:52:18 UTC
Created attachment 2900 [details]
Patch to add clone support for sheets
Comment 3 Jason Height 2002-09-03 10:56:02 UTC
Ok i have attached a patch that provided clone support for sheets. I havent
implemented clone methods for ALL records (but on the simple sheets that i tried
it didnt fail). I think that i have the most of them but graphing records will
NOT have clone implemented since these records are automatically generated. I
dont know what to do about these, are these Glen's resposibility???

It is very easy to implement the clone methods. I feel a bit of a loozer for
adding myself to the list of authors for so many files, for such little changes...

Jason Height
Comment 4 Glen Stampoultzis 2002-09-03 11:28:52 UTC
Anyones free to modify the record generator.  Don't let me stop you.  If you'd
rather I do it I'd be happy to... I just have extremely thin bandwidth at the
moment as I'm working a day job and a night job so I can't give any timeframes
for getting it done.
Comment 5 Andy Oliver 2002-09-03 14:13:14 UTC
don't feel bad about adding your name to all those files!  It helps POI and you
when your name is added.  (At least I think it does).. .  I'll look at
this/apply this *soon*.  (Sorry I didn't look at it before really...  I couldn't
get the attachment out and patched/etc...  Here I can.
Comment 6 Jason Height 2002-09-04 04:05:06 UTC
Created attachment 2910 [details]
Patch that add the clone support to graphing records and the record generator
Comment 7 Jason Height 2002-09-04 04:06:34 UTC
Both patches need to be applied. The first patch is for the majority of records,
the second patch is only for the graphing records and the record generator.

Jason
Comment 8 Andy Oliver 2002-09-05 00:17:46 UTC
It failed...  The EqualPtg I understand cause I just added that...but I'm at a
loss as far as the textobjectrecord error.


compile:
Compiling project core with Java 1.4, debug on, optimize off, deprecation on
Compiling 282 source files to
/mnt/u03/home/andyext/jakarta/formula/jakarta-poi/build/classes
/mnt/u03/home/andyext/jakarta/formula/jakarta-poi/build/java/org/apache/poi/hssf/record/formula/EqualPtg.java:72:
org.apache.poi.hssf.record.formula.EqualPtg should be declared abstract; it does
not define clone() in org.apache.poi.hssf.record.formula.Ptg
public class EqualPtg
       ^
/mnt/u03/home/andyext/jakarta/formula/jakarta-poi/build/java/org/apache/poi/hssf/record/RecordFactory.java:112:
cannot resolve symbol
symbol  : class TextObjectRecord  
location: class org.apache.poi.hssf.record.RecordFactory
                PaletteRecord.class, StringRecord.class, TextObjectRecord.class
                                                         ^
/mnt/u03/home/andyext/jakarta/formula/jakarta-poi/build/java/org/apache/poi/hssf/record/RecordFactory.java:143:
cannot resolve symbol
symbol  : class TextObjectRecord  
location: class org.apache.poi.hssf.record.RecordFactory
                PaletteRecord.class, StringRecord.class, TextObjectRecord.class
                                                         ^
3 errors

BUILD FAILED
/mnt/u03/home/andyext/jakarta/formula/jakarta-poi/tools/cents/centipede.cent/xbuild.xml:28:
Compile failed; see the compiler error output for details.

Comment 9 Jason Height 2002-09-05 00:21:13 UTC
Dang!

I accidentently left in my refernces to the text object record which i have 
been experimenting with. I went through the patch and deleted some references 
but didnt catch them all.

Is it easier for you to edit the RecordFactory and remove the references or for 
me to resubmit the patches?

Jason
Comment 10 Andy Oliver 2002-09-05 00:27:37 UTC
It failed...  The EqualPtg I understand cause I just added that...but I'm at a
loss as far as the textobjectrecord error.

It looks like this patch added it.  I fixed both things the EqualPtg returns a
new one, and dropped the textobjectrecord from the recordfactory (assuming thats
your next patch ;-) )

patch applied. please crosscheck.

compile:
Compiling project core with Java 1.4, debug on, optimize off, deprecation on
Compiling 282 source files to
/mnt/u03/home/andyext/jakarta/formula/jakarta-poi/build/classes
/mnt/u03/home/andyext/jakarta/formula/jakarta-poi/build/java/org/apache/poi/hssf/record/formula/EqualPtg.java:72:
org.apache.poi.hssf.record.formula.EqualPtg should be declared abstract; it does
not define clone() in org.apache.poi.hssf.record.formula.Ptg
public class EqualPtg
       ^
/mnt/u03/home/andyext/jakarta/formula/jakarta-poi/build/java/org/apache/poi/hssf/record/RecordFactory.java:112:
cannot resolve symbol
symbol  : class TextObjectRecord  
location: class org.apache.poi.hssf.record.RecordFactory
                PaletteRecord.class, StringRecord.class, TextObjectRecord.class
                                                         ^
/mnt/u03/home/andyext/jakarta/formula/jakarta-poi/build/java/org/apache/poi/hssf/record/RecordFactory.java:143:
cannot resolve symbol
symbol  : class TextObjectRecord  
location: class org.apache.poi.hssf.record.RecordFactory
                PaletteRecord.class, StringRecord.class, TextObjectRecord.class
                                                         ^
3 errors

BUILD FAILED
/mnt/u03/home/andyext/jakarta/formula/jakarta-poi/tools/cents/centipede.cent/xbuild.xml:28:
Compile failed; see the compiler error output for details.
Comment 11 Jason Height 2002-09-05 01:06:09 UTC
YES my patch would have removed those references to the TextObjectRecord. 

I have cross checked and it is OK.

Jason