{description} {excerpt}The [Process|WordTemplate.Process()] method enters data source values in a template's merge fields, and creates an image of the output file \(the new document\) in memory.{excerpt} {signature:C#} public void Process() {signature}{signature:vb.net} Public Sub Process() {signature} {remarks}The save method can then save the output file to disk, stream it to the browser, or both. Call {{Process}} after [SetDataSource|WordTemplate.SetDataSource] and before [Save|WordTemplate.Save]. You can only call {{Process}} once for each instance of [WordTemplate|WordTemplate]. {remarks} {example}Generate a single Word file: {code:csharp|title=C#} //--- 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); {code} {code:vb.net|title=vb.net} '--- Create an object array of values '--- and a string array of field names to pass to '--- SetDataSource. Dim arrValue As Object() = {"SoftArtisans WordWriter"} Dim arrName As String() = {"ProductName"} '--- Create an instance of WordTemplate. Dim oWW As 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) {code} {example} |