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
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
Created attachment 2900 [details] Patch to add clone support for sheets
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
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.
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.
Created attachment 2910 [details] Patch that add the clone support to graphing records and the record generator
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
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.
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
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.
YES my patch would have removed those references to the TextObjectRecord. I have cross checked and it is OK. Jason