Hi Philipp, I have quickly tested the suggestion I just made and I see it working fine. How are you creating the document and the templatedocument? Are you sure the templatedocument actually has a sheet?
Best, Nick 2014-11-04 15:26 GMT+01:00 Nicholas Evans <[email protected]>: > Hi Philipp, > > I have previously used the appendSheet("sheet") method without > difficulties, but have never tried to append an existing table. Does the > NullPointerException also occur if you try to append the sheet to the > template, as in > documenttemplate.appendSheet(documenttemplate.getSheetByIndex(0), "name") ? > > I will try and test the method when I have a minute. > > Best, > Nick > > > 2014-11-04 0:38 GMT+01:00 Philipp Thöricht < > [email protected]>: > >> Maybe now someone has a clue for me? >> As said in my previous mail, I tried to append a template sheet to a >> spreadsheet document. But the appendSheet method of the class >> SpreadsheetDocument gives me back the following error: >> >> java.lang.NullPointerException >> at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(Unknown Source) >> at sun.reflect.UnsafeQualifiedObjectFieldAccessorImpl.get(Unknown >> Source) >> at java.lang.reflect.Field.get(Unknown Source) >> at >> org.odftoolkit.odfdom.pkg.OdfFileDom.newOdfElement(OdfFileDom.java:340) >> at >> org.odftoolkit.odfdom.pkg.OdfElement.cloneNode(OdfElement.java:297) >> at >> org.odftoolkit.odfdom.pkg.OdfElement.cloneNode(OdfElement.java:316) >> at >> >> org.odftoolkit.simple.SpreadsheetDocument.appendSheet(SpreadsheetDocument.java:315) >> >> What I do is: >> document.appendSheet(documenttemplate.getSheetByIndex(0), "name"); >> where document is the document I want to create and documenttemplate is >> the document with the template sheet. >> Surely I did something wrong, but I can't see what it is. I hope that >> someone can help me. >> >> Regards, >> Philipp >> >> >> On 01.10.2014 16:22, Philipp Thöricht wrote: >> > Hi, >> > >> > I'm searching for help how to handle templates with the odftoolkit. >> > I want to load a template document (spreadsheet), then create a new >> > spreadsheet document and add several sheets to it based on the sheet of >> > the template. >> > I tried methods like appendSheet(templatesheet, "name"), >> > insertSheet(templatesheet, 0) on the new created document, but they all >> > threw a NullPointerExceptions. >> > >> > Maybe someone has a code example how one can get this done? >> > >> > Regards, >> > Philipp >> > >> > >
