认为将一张纸从一个ODF文件复制到另一张是一块蛋糕。不幸的是,下面最简单的代码以空的新文件结尾:
#!/usr/bin/env perl
use strict; use warnings; use 5.014; use utf8::all;
use ODF::lpOD;
my $doc = odf_get_document( "olddoc.ods" )
or die "Failed to load the document\n";
my $table = $doc->get_body->get_table_by_position(0);
my $newdoc = odf_new_document('spreadsheet');
my $context = $newdoc->get_body;
my $newtable = $context->insert_element( $table );
$newdoc->save(target => "newdoc.ods");
我看到的只有Element already belonging to a tree
输出。
您是否看到为何无法使用第一张旧文档创建新文档?