Re: how to print data with a table-like layout in txt file
"Jonathan Revusky" <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
On Thu, Sep 18, 2008 at 5:28 AM, HawkCoretech <[email protected]> wrote: > > > Hi all, > I would like to print data with a table-like layout in a pure txt file (NOT > in html file), like following: > B01 154 155 140 147 147 149 158 117 149 142 152 147 160 147 > B02 0 0 0 0 1 0 0 0 0 0 0 0 0 0 > B03 0 0 1 0 0 0 0 0 0 0 0 0 0 0 > B04 0 5 2 1 2 1 2 4 2 1 1 4 2 4 > B05 2 1 3 2 2 0 3 9 0 3 0 0 0 2 > B06 1 0 1 2 0 2 0 0 5 2 0 1 0 0 > B07 0 1 1 0 0 2 0 1 0 1 0 0 0 1 > B08 2 1 3 2 0 1 1 0 1 2 2 1 1 2 > > the data comes from database query. > > my idea is : > 1)calculate the data and store them in a sequence row by row, use <#list> > to print it all. > > but if we want this table has more flexibility or configurable, for example > a summary column or summary row like this: > > B01 154 155 140 147 147 149 158 117 149 142 152 147 160 147 > total > B02 0 0 0 0 1 0 0 0 0 0 0 0 0 0 > 1 > B03 0 0 1 0 0 0 0 0 0 0 0 0 0 0 > 0 > B04 0 5 2 1 2 1 2 4 2 1 1 4 2 4 > 29 > B05 2 1 3 2 2 0 3 9 0 3 0 0 0 2 > 27 > B06 1 0 1 2 0 2 0 0 5 2 0 1 0 0 > 16 > B07 0 1 1 0 0 2 0 1 0 1 0 0 0 1 > 7 > B08 2 1 3 2 0 1 1 0 1 2 2 1 1 2 > 19 > total 5 7 11 7 5 6 6 14 8 9 3 6 3 9 > 99 > > or even more complex printing like cross table, or separation line, > adjusting column width, row height, spacing between columns, maybe we should > 2)build a custom data model for table. > > any suggestion? thanks in advance. Well, you need to write a macro or two that does these things, I guess. It seems to me that the ?left_pad built-in gets you most of the way there. See: http://freemarker.sourceforge.net/docs/ref_builtins_string.html#ref_builtin_left_pad JR > -- > View this message in context: http://www.nabble.com/how-to-print-data-with-a-table-like-layout-in-txt-file-tp19545299p19545299.html > Sent from the freemarker-user mailing list archive at Nabble.com. > > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > FreeMarker-user mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/freemarker-user > ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/