//--- Create an object array of values
//--- and a string array of field names to pass to
//--- SetDataSource.
Object[] arrValue = {"SoftArtisans WordWriter"};
string[] arrName = {"ProductName"};
//--- Create an instance of WordTemplate.
WordTemplate oWW = new WordTemplate();
//--- Open a template file.
oWW.Open(Server.MapPath(@"../StringVarTemplate.doc"));
//--- Set the file's data source by passing
//--- SetDataSource an array of values and an
//--- array of merge field names.
oWW.SetDataSource(arrValue, arrName);
//--- Call Process() to populate the template with
//--- the new data.
oWW.Process();
//--- After processing the template, call Save() and pass it
//--- Page.Response to stream the generated file to the browser.
oWW.Save(Page.Response, "StringVarOutput.doc", false);
|