Page tree
Skip to end of metadata
Go to start of metadata

Description

The WordTemplate object represents a WordWriter template. A WordWriter template is a file created in Microsoft Word that contains merge fields.
C#
vb.net

Remarks

The WordTemplate object is in the SoftArtisans.OfficeWriter.WordWriter namespace. The object can be referenced as SoftArtisans.WordWriter.WordTemplate. To minimize typing and errors, import the namespace to the aspx page, and reference the object as WordTemplate, without the namespace prefix.

Examples

If you are coding directly in the .aspx page, following the Page directive, include:

If you are coding in the "code behind" page (.aspx.vb or .aspx.cs), include an Imports or using statement at the top of the "code behind" page:

C#
vb.net

To create an instance of the WordTemplate object use:

C#
vb.net

Fields

ALL_ROWS

Used by SetDataSource to indicate that as much of the data source should be imported as possible.

Properties

Name

Description

AllowURIsGets or sets whether documents and images can be inserted from URIs (urls and file paths).

Bookmarks

Returns the names of all bookmarks in a WordWriter template.

ContentType

Sets or returns the content-type header that will be sent to the browser with the generated Word document.

CultureInfo

The CultureInfo property allows you to override the server's default locale when generating a new Word file. For example, to generate a US English document on a French operating system, you could use CultureInfo to set the Word file's System.Globalization.CultureInfo to US English.

DataSourceSeparator

Use DataSourceSeparator to set the character that separates a data source name from a column name in a data marker. '.' is the default data source separator.

EnableNEXTFields

Gets or sets whether NEXT fields should be enabled in the WordTemplate. If NEXT fields are enabled, the data source will move to the next row of data when merge field is repeated in the template file.

FieldMarkers

Returns the names of all merge fields in the main document.

LicenseKey

Sets or returns the registered 23-character license key that enables WordWriter.

PreserveFields

Gets or sets whether merge fields and next fields should be preserved after processing the WordTemplate.

SaveExtension

The extension that should be used when saving this template; based on the input file.

UnlinkIfFields

Gets or sets whether IF fields will be unlinked from the document after they are evaluated.

UpdateIfFields

Gets or sets whether IF fields should be evaluated server-side in the WordTemplate.

Version

Returns the exact version of WordWriter.

Methods

Name

Description

BookmarkFieldMarkers(String)

Returns the names of all merge fields in the specified bookmark.

Open(String)

Opens the WordWriter template specified by the templateFileName parameter.

Open(System.IO.Stream)

Opens a WordWriter template from a System.IO.Stream. A WordWriter template is a file created in Microsoft Word that contains merge fields.

Open(WordApplication, Document)

Passes a document from WordApplication to WordTemplate.

Process()

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.

Save(String)

Saves the generated Word file on the server.

Save(System.IO.Stream)

Sends the generated Word binary file to the specified System.IO.Stream or, a class derived from System.IO.Stream (for example, System.IO.FileStream).

Save(System.Web.HttpResponse)

If you pass Save an HttpResponse object object, WordWriter will stream the generated file to the client. If the user chooses to open (rather than save) the file, it will open in the browser window.

Save(System.Web.HttpResponse, String, Boolean)

If you pass save an HttpServletResponse object, WordWriter will stream the generated file to the client. This method allows you to specify a default client-side file name, and whether the file should be opened in the browser window or in Microsoft Word.

SetDataSource(Object(), String(), String)

Sets a main document data source to a one-dimensional object array. The method imports a single row of data to the specified set of main document merge fields.

SetDataSource(Object(), String())

Sets a main document data source to a one-dimensional object array. The method imports a single row of data to the specified set of main document merge fields.

SetDataSource(System.Data.DataSet, String)

Sets a main document data source to an ADO.NET DataSet. A DataSet contains a collection of DataTables. If you set a main document data source to a DataSet, WordWriter will get the first row of the first DataTable in the DataSet.

SetDataSource(System.Data.DataSet)

Sets a template's data source to an ADO.NET DataSet. A DataSet contains a collection of DataTables. If you set a template's data source to a DataSet, WordWriter will get the first row of the first DataTable in the DataSet.

SetDataSource(System.Data.DataTable, String)

Sets a main document data source to an ADO.NET DataTable. If the specified DataTable contains more than one row, WordWriter will use the first row as the data source.

SetDataSource(System.Data.DataTable)

Sets a template's data source to an ADO.NET DataTable. If the specified DataTable contains more than one row, WordWriter will use the first row as the data source.

SetDataSource(System.Data.IDataReader, String)

Sets a main document data source to an an IDataReader interface, which may be either a SqlDataReader, OleDbDataReader, or an AdomdDataReader. If the specified DataReader returns more than one row, WordWriter will use the first row as the data source.

SetDataSource(System.Data.IDataReader)

Sets a template's data source to an an IDataReader interface, which may be either a SqlDataReader, OleDbDataReader or an AdomdDataReader. If the specified DataReader returns more than one row, WordWriter will use the first row as the data source.

SetDataSource(Object, String)

Sets the data source for the specified main document merge field to an object. The main document is the part of the document that is not within a repeat block.

SetDataSource(System.Collections.IEnumerator, String())

Sets an IEnumerator collection as a data source to bind to a specified set of main document merge fields.

SetDataSource(System.Collections.IEnumerator, String(), String)

Sets an IEnumerator collection as a data source to bind to a specified set of main document merge fields.

SetDataSource(System.Collections.IDictionary)

Sets a template's main document data source to an IDictionary collection. An IDictionary represents a collection of key-and-value pairs.

SetDataSource(System.Collections.IDictionary, String)

Sets a template's main document data source to an IDictionary collection. An IDictionary represents a collection of key-and-value pairs.

SetDataSource(System.Collections.ICollection, String())

Sets an ICollection as a data source to bind to a specified set of main document merge fields.

SetDataSource(System.Collections.ICollection, String(), String)

Sets an ICollection collection as a data source to bind to a specified set of main document merge fields.

SetMailMerge(Object(,), String())

Sets the MailMerge's data source to a two-dimensional (rectangular) array of objects. A MailMerge by default treats the page content as a repeat block, repeating the page content for each row unless NEXT fields are used. If the WordTemplate.EnableNEXTFields property is set to true, the NEXT field can also be used to indicate that the next row of data should be inserted instead of the current row at the next occurence of the merge fields. This should largely imitate the behavior of a Microsoft Word Mail merge.

SetMailMerge(Object(,), String(), Int32, Boolean)

Sets the MailMerge's data source to a two-dimensional (rectangular) array of objects. A MailMerge by default treats the page content as a repeat block, repeating the page content for each row unless NEXT fields are used. If the WordTemplate.EnableNEXTFields property is set to true, the NEXT field can also be used to indicate that the next row of data should be inserted instead of the current row at the next occurence of the merge fields. This should largely imitate the behavior of a Microsoft Word Mail merge.

SetMailMerge(Object(), String())

Sets the MailMerge's data source to a two-dimensional (rectangular) array of objects. A MailMerge by default treats the page content as a repeat block, repeating the page content for each row unless NEXT fields are used. If the WordTemplate.EnableNEXTFields property is set to true, the NEXT field can also be used to indicate that the next row of data should be inserted instead of the current row at the next occurence of the merge fields. This should largely imitate the behavior of a Microsoft Word Mail merge.

SetMailMerge(Object()(), String())

Sets the MailMerge's data source to a two-dimensional (rectangular) array of objects. A MailMerge by default treats the page content as a repeat block, repeating the page content for each row unless NEXT fields are used. If the WordTemplate.EnableNEXTFields property is set to true, the NEXT field can also be used to indicate that the next row of data should be inserted instead of the current row at the next occurence of the merge fields. This should largely imitate the behavior of a Microsoft Word Mail merge.

SetMailMerge(Object()(), String(), Int32, Boolean)

Sets the MailMerge's data source to a two-dimensional (rectangular) array of objects. A MailMerge by default treats the page content as a repeat block, repeating the page content for each row unless NEXT fields are used. If the WordTemplate.EnableNEXTFields property is set to true, the NEXT field can also be used to indicate that the next row of data should be inserted instead of the current row at the next occurence of the merge fields. This should largely imitate the behavior of a Microsoft Word Mail merge.

SetMailMerge(System.Collections.ICollection)

Sets the MailMerge's data source to a two-dimensional (rectangular) array of objects. A MailMerge by default treats the entire page as a repeat block, adding a new page when needed. A MailMerge by default treats the page content as a repeat block, repeating the page content for each row unless NEXT fields are used. If the WordTemplate.EnableNEXTFields property is set to true, the NEXT field can also be used to indicate that the next row of data should be inserted instead of the current row at the next occurence of the merge fields. This should largely imitate the behavior of a Microsoft Word Mail merge.

SetMailMerge(System.Collections.IEnumerator)

Sets the MailMerge's data source to a two-dimensional (rectangular) array of objects. A MailMerge by default treats the page content as a repeat block, repeating the page content for each row unless NEXT fields are used. If the WordTemplate.EnableNEXTFields property is set to true, the NEXT field can also be used to indicate that the next row of data should be inserted instead of the current row at the next occurence of the merge fields. This should largely imitate the behavior of a Microsoft Word Mail merge.

SetMailMerge(System.Data.DataSet)

Sets the MailMerge's data source to a two-dimensional (rectangular) array of objects. A MailMerge by default treats the page content as a repeat block, repeating the page content for each row unless NEXT fields are used. If the WordTemplate.EnableNEXTFields property is set to true, the NEXT field can also be used to indicate that the next row of data should be inserted instead of the current row at the next occurence of the merge fields.

SetMailMerge(System.Data.DataSet, Int32)

Sets the MailMerge's data source to a two-dimensional (rectangular) array of objects. A MailMerge by default treats the page content as a repeat block, repeating the page content for each row unless NEXT fields are used. If the WordTemplate.EnableNEXTFields property is set to true, the NEXT field can also be used to indicate that the next row of data should be inserted instead of the current row at the next occurence of the merge fields.

SetMailMerge(System.Data.DataTable)

Sets the MailMerge's data source to a two-dimensional (rectangular) array of objects. A MailMerge by default treats the page content as a repeat block, repeating the page content for each row unless NEXT fields are used. If the WordTemplate.EnableNEXTFields property is set to true, the NEXT field can also be used to indicate that the next row of data should be inserted instead of the current row at the next occurence of the merge fields.

SetMailMerge(System.Data.DataTable, Int32)

Sets the MailMerge's data source to a DataTable. A MailMerge by default treats the page content as a repeat block, repeating the page content for each row unless NEXT fields are used. If the WordTemplate.EnableNEXTFields property is set to true, the NEXT field can also be used to indicate that the next row of data should be inserted instead of the current row at the next occurence of the merge fields.

SetMailMerge(System.Data.IDataReader)

Sets the MailMerge's data source to a two-dimensional (rectangular) array of objects. A MailMerge by default treats the page content as a repeat block, repeating the page content for each row unless NEXT fields are used. If the WordTemplate.EnableNEXTFields property is set to true, the NEXT field can also be used to indicate that the next row of data should be inserted instead of the current row at the next occurence of the merge fields.

SetMailMerge(System.Data.IDataReader, Int32)

Sets the MailMerge's data source to a two-dimensional (rectangular) array of objects. A MailMerge by default treats the page content as a repeat block, repeating the page content for each row unless NEXT fields are used. If the WordTemplate.EnableNEXTFields property is set to true, the NEXT field can also be used to indicate that the next row of data should be inserted instead of the current row at the next occurence of the merge fields.

SetRepeatBlock(System.Data.DataSet, String)

Sets the specified repeat block's data source to an ADO.NET DataSet. A repeat block is a fragment in the template document that will be repeated for each row in a data source. In the template document, repeat blocks are defined by Word bookmarks that contain merge fields.

SetRepeatBlock(System.Data.DataSet, String, Int32)

Sets the specified repeat block's data source to an ADO.NET DataSet.

SetRepeatBlock(System.Data.DataTable, String)

Sets the specified repeat block's data source to an ADO.NET DataTable.

SetRepeatBlock(System.Data.DataTable, String, Int32)

Sets the specified repeat block's data source to an ADO.NET DataTable.

SetRepeatBlock(System.Data.IDataReader, String)

Sets the specified repeat block's data source to an IDataReader interface, which may be either a SqlDataReader, OleDbDataReader or an AdomdDataReader.

SetRepeatBlock(System.Data.IDataReader, String, Int32)

Sets the specified repeat block's data source to an IDataReader interface, which may be either a SqlDataReader, OleDbDataReader, or an AdomdDataReader.

SetRepeatBlock(Object(), String(), String)

Sets the specified repeat block's data source to a 1-dimensional array of objects.

SetRepeatBlock(Object(,), String(), String)

Sets the specified repeat block's data source to a multidimensional (rectangular) array of objects.

SetRepeatBlock(Object(,), String(), String, Int32, Boolean)

Sets the specified repeat block's data source to a multidimensional (rectangular) array of objects.

SetRepeatBlock(Object()(), String(), String)

Sets the specified repeat block's data source to a jagged array (array-of-arrays) of objects.

SetRepeatBlock(Object()(), String(), String, Int32, Boolean)

Sets the specified repeat block's data source to a jagged array (array-of-arrays) of objects.

SetRepeatBlock(System.Collections.IEnumerator, String)

Sets the specified repeat block's data source to an IEnumerator collection.

SetRepeatBlock(System.Collections.IEnumerator, String, String)

Sets the specified repeat block's data source to an IEnumerator collection.

SetRepeatBlock(System.Collections.ICollection, String)

Sets the specified repeat block's data source to an ICollection.

SetRepeatBlock(System.Collections.ICollection, String, String)

Sets the specified repeat block's data source to an ICollection.

WordTemplate()

Creates a new WordTemplate object.

Extension Methods

Introduced in build 4.5

Overload

Description

Open(Microsoft.SharePoint.SPDocumentLibrary, String)

Opens the WordWriter template specified by the templateFileName parameter.

Open(Microsoft.SharePoint.SPListItem, String)

Opens the WordWriter template specified by the templateFileName parameter.

Save(Microsoft.SharePoint.SPDocumentLibrary, String, Boolean)

Saves the generated Word file to a SharePoint Document Library.

Save(Microsoft.SharePoint.SPListItem, String)

Saves the generated Word file to a SharePoint List Item.

SetDataSource(Microsoft.SharePoint.SPList, String)

Sets a main document data source to a SharePoint List. If the specified List contains more than one row, WordWriter will use the first row as the data source.

SetDataSource(Microsoft.SharePoint.SPList)

Sets a main document data source to a SharePoint List. If the specified List contains more than one row, WordWriter will use the first row as the data source.

SetDataSource(Microsoft.SharePoint.SPView, Microsoft.SharePoint.SPList, String)

Sets a main document data source to a SharePoint View. If the specified View contains more than one row, WordWriter will use the first row as the data source.

SetDataSource(Microsoft.SharePoint.SPView, Microsoft.SharePoint.SPList)

Sets a main document data source to a SharePoint View. If the specified View contains more than one row, WordWriter will use the first row as the data source.

SetMailMerge(Microsoft.SharePoint.SPList, Int32)

Sets the MailMerge's data source to a SharePoint View. A MailMerge by default treats the page content as a repeat block, repeating the page content for each row unless NEXT fields are used. If the WordTemplate.EnableNEXTFields property is set to true, the NEXT field can also be used to indicate that the next row of data should be inserted instead of the current row at the next occurence of the merge fields.

SetMailMerge(Microsoft.SharePoint.SPList)

Sets the MailMerge's data source to a SharePoint View. A MailMerge by default treats the page content as a repeat block, repeating the page content for each row unless NEXT fields are used. If the WordTemplate.EnableNEXTFields property is set to true, the NEXT field can also be used to indicate that the next row of data should be inserted instead of the current row at the next occurence of the merge fields.

SetMailMerge(Microsoft.SharePoint.SPView, Microsoft.SharePoint.SPList, Int32)

Sets the MailMerge's data source to a SharePoint View. A MailMerge by default treats the page content as a repeat block, repeating the page content for each row unless NEXT fields are used. If the WordTemplate.EnableNEXTFields property is set to true, the NEXT field can also be used to indicate that the next row of data should be inserted instead of the current row at the next occurence of the merge fields.

SetMailMerge(Microsoft.SharePoint.SPView, Microsoft.SharePoint.SPList)

Sets the MailMerge's data source to a SharePoint View. A MailMerge by default treats the page content as a repeat block, repeating the page content for each row unless NEXT fields are used. If the WordTemplate.EnableNEXTFields property is set to true, the NEXT field can also be used to indicate that the next row of data should be inserted instead of the current row at the next occurence of the merge fields.

SetRepeatBlock(Microsoft.SharePoint.SPList, String, Int32)

Sets the specified repeat block's data source to a SharePoint List.

SetRepeatBlock(Microsoft.SharePoint.SPList, String)

Sets the specified repeat block's data source to a SharePoint List.

SetRepeatBlock(Microsoft.SharePoint.SPView, Microsoft.SharePoint.SPList, String, Int32)

Sets the specified repeat block's data source to a SharePoint View.

SetRepeatBlock(Microsoft.SharePoint.SPView, Microsoft.SharePoint.SPList, String)

Sets the specified repeat block's data source to a SharePoint View.
  • No labels