|
Following the previous answer (thanks to trendle), some code simplifications are possible.
First, the two following use statements are not needed:
use OpenOffice::OODoc::File ;
use OpenOffice::OODoc::XPath ;
As soon as the main OpenOffice::OODoc top module is used, File and XPath (and others) are loaded too.
Second, there is a getTableList() method that returns all the tables/sheets of the document (or the current context) as a list. So it's not necessary to explicitly select the "office:spreadsheet" context then to use the getElementList() with an XPath expression in order to get this list. We just need to write
my $allSheets = [ $doc->getTableList() ];
Such coding style could improve the program readability for people who don't know the ODF XML schema.
In addition, there is a document-level tableName() mnemonic method that allows the user to get (or set) a sheet name without knowledge of the XML "table:name" attribute. So, the following instruction:
my $shname = $sheet->getAttribute('table:name');
should be replaced by:
my $shname = $doc->tableName($sheet);
Such coding style could improve the program readability for people who don't know the ODF XML schema.
|