Formatting simple tabular text data Add comment to Wiki View in Wiki Edit Wiki page Printable Version

Formatting simple tabular text data

This class has been posted first time on the Groovy-User Mailing List by Raffaele Castagno in this format:

 and later "groovyfied" by Gavin Grover:

 First version is here only as an example of the "groovify process". Of course, the Gavin's version is better.

This class emulate the output of most RDBMS consoles (ie. Oracle SQL*, MySql).

Here's an usage example (again, grooved up by Gavin):

This is the output:

Actually is really limited: column width must be declared, and strings are truncated to that given size.


  • Automatic column width based on maximum string length
  • Multiline records
  • Multiline fields
  • More formatting options (alignment, case, etc)
  • Management of footer fields (totals, formulae, etc)
  • Automatic line-wrap based on screen size

Version with ability to wrap text within a column (rather than truncating it).

The version below is part of a larger project that you are free to grab and use for you own. The main project wiki page is

  here. We prefer static typing for our larger projects, so we have modified the original code to suit our style. Hope it is useful for you. Victor Vlasenko authored most of this enhancement under contract for Build Lackey Labs, and I helped clean up the code a bit for presentation on this site [].

Summary of Enhancement

 This enhancement enables wrapping-to-multi-lines for  column text

that exceeds the width of a given column. We break out word boundaries

(white space) where possible,  The implementation we built on truncated

the overly long column value instead of wrapping it.




Results of your search request can come from various sources: the Groovy website itself, the JIRA issues, the API documentation, as well as a few other interesting Groovy-related blogs.

  By  -  pages  -  views  - last modified