Table of Contents
A WordWriter template is a Microsoft Word file that contains merge fields. A merge field displays a data source field (for example, a database column 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 with data source values.
A template may contain multiple sets of merge fields. Each set of fields binds to a single data source. Implicitly or explicitly, a merge field always specifies both a data source and a column. For example, in the merge field*«Products.ProductID», "Products" is the data source and "ProductID" is the column. The merge field«ProductID»* refers to the "ProductId" column from the first data source defined in the WordWriter code.
The Main Document and Repeat Blocks\
- Merge Fields Names
- Using Short Merge Fields
- Using Long Merge Fields
- Merge Field Modifiers
- Merge Field Formulas
Merge Field Names
- Data source and column names must not include Unicode characters.
- * Data source and column names must begin with a letter (A-Z, a-z).
Data source and column names may include the following characters only:
If you assigned a different data source separator, you can also use a "." in your data source and column names.
- Spaces are not allowed anywhere in a merge field.
Use brackets if your column name does not conform to these rules
- «$Employee» means the first column in the data source "Employee."
- * «Employee» means the "Employee" column in the first data source defined in the WordWriter code.
An WordWriter merge field can include modifiers. Modifiers are included in parenthesis at the end of the merge field. For example:
If a merge field includes more than one modifier, the modifiers should be separated by commas. Do not include spaces between modifiers. For example:
WordWriter supports the following merge field modifiers:
Use the Fieldname modifier to insert database column headings in a document. For example, in place of the merge field \
If a merge field includes the Uppercase modifier, all text values imported to the merge field will be displayed in uppercase. If a merge field includes both the Uppercase and Lowercase modifiers, the last will be applied.
If a merge field includes the Lowercase modifier, all text values imported to the merge field will be displayed in lowercase. If a merge field includes both the Uppercase and Lowercase modifiers, the last will be applied.
By default, if a merge field's data source name or column name is not bound to a data source in code, an error will occur. If a merge field contains the Optional modifier, and the merge field is not bound by name to a data source, WordWriter will discard the merge field in the generated document and will not throw an error. \
If the image modifier is present and the column of data for the merge field is either of type byte array (byte) or SQL BLOB, then the image will be rendered. The image modifier can take optional parameters to format the size of the image (e.g. <<Product.Image(image(1,600,600))>>. For more see Inserting an Image.
The document modifier can be used to insert certain types of documents into docx files where format is either