[jOpenDocument] copy a single sheet from one spreadsheet to another.

  • Follow


Hello,
I am using JOpenDocument 1.2 library to import multiple spreadsheets from 
Openoffice, modify them and then save them back.

I've tried (hardly) to copy a single sheet 
(org.jopendocument.dom.spreadsheet.Sheet) from one 
spreadsheet(org.jopendocument.dom.spreadsheet.SpreadSheet) to another.
Is there a quick way to do that ?

Something like :
--------------------------------------------------------------------------------------------------------------
File inputFile = new File(fic1.odt);
File outputFile = new File(fic2.odt);
SpreadSheet classeur_in = SpreadSheet.createFromFile(inputfile);
SpreadSheet classeur_out = SpreadSheet.createFromFile(outputfile);
Sheet generique = classeur_in.getSheet(0);   // assuming it exists

--> (this method doesn't exists)
classeur_out.addsheet(int index, Sheet generique);
---------------------------------------------------------------------------------------------------------------

Thx in advance,
MM.
0
Reply m 2/6/2011 7:51:02 PM

I answer to myself :

I found that it was necessary to access the content of the spreadsheet
from the sheet itself :
so getSheet(0) needs to exist ...
---------------------------------------------------------------------------------------------------------------
spreadsheet_out.getSheet(0).getElement().getParentElement().addContent(0,
(org.jdom.Element) spreadsheet_in.getSheet(1).getElement().clone());
---------------------------------------------------------------------------------------------------------------

Thx,
MM.
0
Reply m 2/8/2011 8:31:24 PM


1 Replies
634 Views

(page loaded in 0.04 seconds)

Similiar Articles:












7/24/2012 7:36:05 AM


Reply: