47
©2002-2016, Ido Millet, ido@MilletSoftware.com
Page 204
Populating Word Tables with Crystal Formula Data
During WORD_Replace_Tags processing (see section above), you can instruct Visual CUT to
also populate tables with data from Crystal formulas. To populate the 1
st
table you name the
formula Word_Replace_Table_1. To populate the Nth table in the document, name the formula
Word_Replace_Table_N
Remember to place the formula in RH/RF section if not bursting or in GH1/GF1 section if the
formula provides different data for each Group level 1 during bursting. As always, the formula
or the section may be suppressed.
The formula should contain a strings delimited according to the following structure:
- Table Rows should be separated with a "][" delimiter.
- Table cells should be separated with a "||" delimiter
The table in the template Word document should already have at least as many rows as you
expect to populate. Visual CUT will delete the extra rows. This way, any formatting you
applied to the table would be maintained.
In most cases, the final formula would simply return the value of a global string variable that has
been accumulated via other formulas. For example, if you are bursting the sample report
Visual_Cut_11.rpt and wish to populate the 1
st
Table in a Word document with information
about the Product Name (1
st
column) and Revenue (2
nd
Column), you may use the following 3
formulas:
GH1 Formula to reset the global string variable:
WhilePrintingRecords;
If NOT InRepeatedGroupHeader THEN Global StringVar Table_1 := "";
GH2 section Formula to accumulate the information into the Table_1 string variable:
WhilePrintingRecords;
Global stringvar Table_1;
IF Len(Table_1) = 0 Then
// First table row. Separate cell values with "||"
Table_1 := {Product.Product Name}+ "||" + "$" + ToText(Sum ({@value},
{Product.Product Name}),0)
ELSE
// Additional row, so add it to the accumulated string variable (Table_1)
// after a "][" to indicate a new row
Table_1 := Table_1 + "][" + {Product.Product Name}+ "||" + "$" + ToText(Sum
({@value}, {Product.Product Name}),0)
Group Footer Formula to pass the string to Visual CUT:
WhilePrintingRecords;
Global StringVar Table_1;