Perl-Sensitive Sunglasses | |
PerlMonks |
Module proposal: Text::FormatComplexTablesby mirod (Canon) |
on Sep 25, 2002 at 14:45 UTC ( [id://200639]=perlmeditation: print w/replies, xml ) | Need Help?? |
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:
SYNOPSISuse 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
DESCRIPTIONThis modules allows editing of tables with a syntax similar to html, and renders them to text
TODOcode 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
AUTHORMichel Rodriguez <mirod@xmltwig.com>
SEE ALSOperl(1).
Back to
Meditations
|
|