Message-ID: <1254614144.7653.1711617047578.JavaMail.web05$@web05> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_7652_1820203437.1711617047578" ------=_Part_7652_1820203437.1711617047578 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html WordTemplate Guides

WordTemplate Guides

Creating a Template=20

OfficeWriter's WordTemplate object opens a WordWriter template file, pop= ulates it with data from one or more data sources, and generates a new Word= file. A WordWriter template is a file created in Microsoft Word that conta= ins merge fields. A merge field displays a data source field name (for= example, a database column name) where a data source value will be inserte= d. Merge fields are bound to a data source in OfficeWriter code. When you r= un the code, OfficeWriter replaces the merge fields with v

=20

Creating Merge Fields

=20

A WordWriter template is a Microsoft Word file that contains merge field= s. A merge field displays a data source field (for example, a database colu= mn name). A merge field is created in Microsoft Word and bound in code to a= data source. The data source may be an array, a DataSet, a DataTable, or a= DataReader. When you run the code, WordWriter populates the merge fields w= ith data source values.

=20

Formatting Merge Field= s

=20

When you create a merge field in Microsoft Word (see Creating a Wor= dWriter Template), you can apply formatting to the field. For example, you = can set a merge field's format to "Uppercase" to display the fiel= d's value in uppercase letters. WordWriter supports most text, date, and ti= me formats available in Microsoft Word.

=20

Adding Formulas = to a Document

=20

Beginning in WordWriter version 4.1, WordTemplate now has the ability to= evaluate a certain number of formulas on data fields that are br= ought into a template.

=20

Inserting an Image

= =20

WordWriter allows you to insert jpg, gif, bmp, and png images in merge f= ields. You can insert images repeat block and main document merge fields. T= here are two ways to insert an image into a merge field:

=20

Inserting an Em= bedded Document

=20

WordTemplate can insert certain types of documents into docx files by ad= ding the "document(format)" modifier to the merge field, where fo= rmat is RTF, HTML, or DOCX (see below).

=20

Inserting HTML snippet= s

=20

Creatin= g a Grouped and Nested Document

=20

Beginning in version 4.5, the WordTemplate object includes support for n= ested bookmarks with Office Open XML documents (.docx, .docm, .dotx, and .d= otm) in WordWriter Enterprise Edition. Nested bookmarks can be used to form= at and display hierarchical data.

=20

Using a Data= base as a Data Source

=20

You can use a database table as a data source for a WordWriter template = by passing the SetDataSource method a DataTable, a DataSet, an SqlDataReade= r, OleDbDataReader or an AdomdDataReader. If the specified data source cont= ains more than one row, SetDataSource will use the first row of the first t= able as the data source. To import multiple rows from data sources use= a repeat block.

=20

Importing= from Multiple Data Sources

=20

The main document may include multiples sets of merge fields, where each= set of fields binds to a different data source. A SetDataSource call is re= quired for each set of main document merge fields. Only one row of data can= be imported to each set of main document merge fields. When you include mo= re than one set of merge fields in the main document, use any of the follow= ing SetDataSource methods to set data sources:

=20

Using an Array= as a Data Source

=20

The following example generates a Word file from a template that contain= s the merge fields ProductName, CompanyName, and URL. The WordWriter code g= ets the values for these fields from an array of objects.

=20

Importing Multiple Row= s

=20

Use a repeat block to import multiple rows from a data source.= A repeat block is a fragment in the template document - defined by a Word = bookmark - that contains merge fields and that will be repeated f= or each row in a data source. To import multiple rows from a single data so= urce, create a repeat block in the template and, in the WordWriter code, ca= ll SetRepeatBlock to bind the repeat block to a data source.

=20

WordTemplate Outpu= t Options

=20

After populating your WordWriter template from a data source, call Save = to either save the new Word file on the server, or stream it to the browser= . WordWriter can:

=20

------=_Part_7652_1820203437.1711617047578--