<cfwhat>

Wednesday, March 01, 2006

Creating tables in RTF


Occasionally I have to output RTF (Rich Text Format) documents from ColdFusion. For simple paragraphs of text
with basic font formatting its not that hard. Producing tables can be a bit tricky though. Here's an example of the
RTF code for a very simple document with a 3x2 table:



{\rtf1
Text before table\par
\trowd\intbl
\cellx1000\cellx2000\cellx3000
Row 1 column 1 \cell Row 1 column 2\cell Row 1 column 3\cell
\trowd\intbl
\cellx1000\cellx2000\cellx3000
\row
\trowd\intbl
\cellx1000\cellx2000\cellx3000
Row 2 column 1 \cell Row 2 column 2\cell Row 2 column 3\cell
\trowd\intbl
\cellx1000\cellx2000\cellx3000
\row
\pard
Text after table\par
}


When viewed in an RTF editor (Word, NotePad, etc):





This example is adapted from Steve Skelton's excellent article
"How To Output RTF-formatted Documents with ASP".