Nested tables with RTF::Writer

Discussion in 'Perl Misc' started by Mahesh A, Dec 18, 2003.

  1. Mahesh A

    Mahesh A Guest

    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;
    Mahesh A, Dec 18, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter Bassett
    Replies:
    3
    Views:
    912
    Augustus
    Aug 15, 2003
  2. DaVinci
    Replies:
    1
    Views:
    556
    Piotr Kobzda
    Oct 5, 2006
  3. Henri
    Replies:
    1
    Views:
    363
    Henri
    Jul 13, 2004
  4. Tony
    Replies:
    2
    Views:
    270
  5. Sparky

    RTF::Writer work

    Sparky, Nov 29, 2006, in forum: Perl Misc
    Replies:
    1
    Views:
    84
    J. Gleixner
    Nov 30, 2006
Loading...

Share This Page