I have a need to format tables as text. The original tables are in OpenOffice XML format and the text export does not format them.
I have looked around for an existing solution to this problem, but I have not found any module or canned script that would allow me to do this, even if I converted the OO format to HTML.
Is there any way I could re-use an existing tool?
If not I plan to write a module: Text::FormatComplexTable (Text::FormatTable already exists but it only creates simple tables, now row/col span for example)
The pod is below, comments are welcomed:
use Text::FormatComplexTable;
my $table= Text::FormatComplexTable->new( width => 80,
);
$table->add_cell( "text of cell 1x1");
$table->add_cell( { colspan => 2 }, "text of cell 1x2,3");
$table->add_cell( { rowspan => 2 }, "text of cell 1,2x4");
$table->new_row;
$table->add_cell( { align => "right" }, "text of cell 2x1");
$table->add_cell( { valign => "top" }, "text of cell 2x2");
$table->add_cell( "text of cell 2x3\nincluding line returns");
$table->add_row( "text of cell 3x1",
{ colspan => 3 }, "text of cell 3x2-4");
$table->add_row_before( 1, "text of cell 0x1",
{ colspan => 3 }, "text of cell 0x2-4");
$table->add_column( "text of cell 0x5",
{ rowspan => 3 }, "text of cell 1-4x5")
$table->add_column_before( 1, "text of cell 0x0",
{ rowspan => 4 }, "text of cell 1-4x0")
$table->set_column_width( 20, 10, 10, 10, 10, 20);
my $table_as_text= $table->render; # that's where the job is really done
# performed and error checks
This modules allows editing of tables with a syntax similar to html, and renders them to text
code the module ;--)
naming of cells/rows/columns
deleting/editing of cells/rows/columns (by position or par name)
traversal of the table (so you can edit/insert/delete cells/rows/columns)
direct import of HTML tables (using an HTML parser)
other export formats: HTML (trivial), XML (based on names?)
use as a SAX filter
nested tables
Michel Rodriguez <mirod@xmltwig.com>
perl(1).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Module proposal: Text::FormatComplexTables
by trs80 (Priest) on Sep 25, 2002 at 19:44 UTC | |
|
Re: Module proposal: Text::FormatComplexTables
by BUU (Prior) on Sep 25, 2002 at 21:59 UTC |