You did a raw import. The docs for that say “Remember too that the import is not actually carried out by OODoc::File until a save and the imported data is therefore not immediately available.” I suggest you try $container2->save;
and then re-load it right after importing styles and then see if Table.A1 shows up in doc2.odt’s content.xml after the next save:
# load output file
my $container2 = odfContainer( $outfile, create => 'text' );
$container2->raw_import("styles.xml");
# Carry out the import and reload it with the new styles.
$container2->save;
$container2 = odfContainer( $outfile );
my $doc2 = odfDocument
(
container => $container2,
part => 'content'
);
# Load table from 'mytest.odt'
my $table=$doc->getTable(0);
# Get style from first cell in $table
my $headerstyle=$doc->getStyle( $doc->getCell($table, 0, 0) );
# Create table in $doc2
my $newtable=$doc2->appendTable('newtable', 1, 1, 'table-style' => $doc->getStyle($table) );
# Set style of first cell in $newtable to 'Table1.A1'
$doc2->cellStyle( $newtable, 0, 0, 'Table1.A1' );
# Write 'doc2.odt' to disk
$container2->save;