Nested tables with RTF::Writer

M

Mahesh A

Hi,

I am trying to use RTF::Writer to create an RTF document that contains
nested tables (or table with nested cells).

Followng is what i've come up with. Nested $rtf->table() call looks
pretty wrong - table() doesnot return a string. The inner table() call
executes first and I end up getting get two separate tables instead of
nested tables as intended.

Help/guidance from someone with experience in this area would be greatly
appriciated.

Thanks,
Mahesh.
------------------------------------
#!/usr/local/bin/perl -w

# Intent:
# ,-----------------.------------------------------------,
# | Cell1:1 | Cell1:2 |
# |-----------------+------------------.-----------------|
# | Cell2:1 | Cell2:2:1:1 | Cell2:2:1:2 |
# | |------------------+-----------------|
# | | Cell2:2:2:1 | Cell2:2:2:2 |
# `-----------------'------------------'-----------------'

use strict;
use RTF::Writer;

my $rtf = RTF::Writer->new_to_file("table.rtf");

$rtf->prolog( 'title' => "Nested Tables" );

my $parentRow = RTF::Writer::TableRowDecl->new(
'widths' => [3000, 4000]);
my $childRow = RTF::Writer::TableRowDecl->new(
'widths' => [2000, 2000]);

$rtf->table($parentRow,
["Cell1:1", "Cell1:2"],
["Cell2:1", $rtf->table($childRow,
["Cell2:2:1:1", [\'\i', 'Cell2:2:1:2']],
["Cell2:2:2:1", [\'\i', 'Cell2:2:2:2']])]);

$rtf->close;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,044
Messages
2,570,388
Members
47,052
Latest member
ketan

Latest Threads

Top