Hi,
you can do a lot of formatting with macros. I used the following in my code:
#set( $String = "a" )
#set( $Char = $String.charAt(0) )
...
## ------------------------------------------------------------------------
## convertHeaderString: macro to pad header text to fit column contents
## ------------------------------------------------------------------------
## in $lines array of maps with the row contents
## in $key of the header
## out $header string in title case, centered padded with spaces
##
#macro( convertHeaderString $lines $key $header )
#if( $key.startsWith("noOf") )
#set( $header = '#' )
#set( $str = $key.substring(4) )
#else
#set( $header = $key.substring(0, 1).toUpperCase() )
#set( $str = $key.substring(1) )
#end
#set( $length = $str.length() - 1 )
#foreach( $i in [0..$length] )
#set( $char = $str.charAt($i) )
#if( $Char.isUpperCase($char) )
#set( $header = "$header " )
#end
#set( $header = "$header$char" )
#end
#set( $width = $header.length() )
#set( $rows = $lines.size() - 1 )
#if( $key.endsWith("Date") )
#set( $max = 17 )
#else
#set( $max = $width )
#foreach( $row in [1..$rows] )
#set( $value = $lines.get($row).get($key) )
#if( $value.length() > $max )
#set( $max = $value.length() )
#end
#end
#end
#if( $max > $width )
#foreach( $i in [$width..$max] )
#if( ($i % 2) == 1 )
#set( $header = "$header " )
#else
#set( $header = " $header" )
#end
#end
#end
#end
...
## and use it:
#foreach( $key in $lines.get(0) )## first row has headers (parsed from CSV
file!)
#set( $header = "" )
#set( $dummy = "#convertHeaderString( $lines $key $header )" )
#end
:) Christoph
Vasilis wrote:
> Hi all ,
>
> I am using Velocity to create autogenerated mail messages. These messages
> will be in html and text format. I want to represent data in rows and
> columns like in a table. For the html format this is easy just using the
> velocity $for command and represent the data using <td> and <tr>. How can I
> achieve this in the text without looing the table formatting?
> Below there is an example of what I want to do:
>
> Item Price VAT
> $item[1] $price[1] $vat[1]
> $item[2] $price[2] $vat[2]
> $item[..] $price[..] $vat[..]
>
> Thanks in advance,
> Roy
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]