However... given the context of the forum I expect that the questioner was not wanting an answer in BASIC... (still it's nice to know there's more than one way to skin a cat, as they say).
There is a way in OODoc but you need to add library with XPath.
use OpenOffice::OODoc ;
use OpenOffice::OODoc::File ;
use OpenOffice::OODoc::XPath ;
Then it is fairly easy (eventually) to copy a sheet.
my $spread = $doc->getElement('//office:spreadsheet');
# 2 Context set to spreadsheet
$doc->currentContext($spread);
# 2b Report number of sheets
my $allSheets = [ $doc->getElementList('//table:table') ];
printf("Sheet count = %d\n",scalar(@$allSheets));
# 3 Get last sheet (setting maximum size to be 26 x 26 ==> as in NormalizeSheet )
my $sheet = $doc->getTable(-1,26,26);
# 4 Context set to last sheet
$doc->currentContext($sheet);
# 4b Get sheet name
my $shname = $sheet->getAttribute('table:name'); printf("Last Sheet Name -> $shname\n");
my $new_sheet;
my $new_name;
# 5 Now replicate the blank sheet into a new sheet preceding, (always maintain a blank last sheet).
$new_sheet = $doc->replicateElement($sheet,$sheet,position => 'before');
$doc->currentContext($new_sheet);
# 6 Stick some stuff into the Sheet
populateSheet($doc,$new_sheet,$dataBlock);
my $new_name = $new_sheet->getAttribute('table:name');
printf("Add Sheet Name -> $new_name\n");
# etc... repeat as necessary
This is a cut from something I'm working on which keeps a blank form as the last sheet, and makes a copy before the blank to put new data into it. The 'populateSheet' proc is just my way of stuffing data into the new sheet, you can make up your own for whatever purpose you want.
regards.
|