Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0
Description

Excerpt

The 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.

Signature
C#C#
Wiki Markup
{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}{signature:vb.net
vb.net
}
Public Sub Process()
Remarks

The save method can then save the output file to disk, stream it to the browser, or both.

Call Process after SetDataSource and before Save.

You can only call Process once for each instance of WordTemplate.

{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}
Example

Generate a single Word file:

Code Block
csharpcsharp
titleC#
Code Block
vb.nettitle