//--- A 2-D jagged array of values
//--- This is a "transposed" array with columns in the first
//--- dimension and rows in the second
string[][] ValuesArr = new string[][] {
new string[] {"Boston", "Miami", "Merchantville"},
new string[] {"MA", "FL", "NJ"}
};
//--- Names array, elements correspond to merge field names
string[] NamesArr = {"City", "State"};
WordTemplate wt = new WordTemplate();
wt.Open("template.doc");
//--- Set the repeat block defined by the bookmark "Block"
//--- The data source is the 2-D rectangular ValuesArr array
//--- MaxRows is set to ALL_ROWS, which allows all rows to be imported
//--- Transpose is true to handle the transposed array
wt.SetRepeatBlock(ValuesArr, NamesArr, "Block",
WordTemplate.ALL_ROWS, true);
wt.Process();
wt.Save("out.doc");
|