Message-ID: <256736484.7823.1711622908085.JavaMail.web05$@web05> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_7822_1999409820.1711622908085" ------=_Part_7822_1999409820.1711622908085 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html WordTemplate.SetDataSource(Object(), String(), String)

WordTemplate.SetDataSource(Object(), String(), String)

Description

=20

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 m= erge fields.

=20
C#
=20
 public void SetDataSource(System.Object[] dataRow, System.String[] fieldNa=
mes, System.String name)
=20
=20
vb.net
=20
Public Sub SetDataSource(ByVal dataRow As Object(), ByVal fieldNames As Str=
ing(), ByVal name As String)
=20
=20

= Parameters

=20
data An object array of values to use as a data source. WordWriter will inse= rt these values in the template's merge fields.=20
= fieldNames
A string array of data source field names. These must be th= e same as the corresponding merge field names in the template=20
name A string that matches the data source name.=20

= Exceptions

=20
ArgumentNullException
=20 Save will t= hrow this exception if=20 null (C#) or=20 Nothing (VB.NET) is passed to the method.=20
ArgumentException
=20

Rem= arks

=20

The method's third parameter - name - specifies the data so= urce name for the set of merge fields. For example, if the main document co= ntains the following sets of merge fields:

=20
=20 =20 =20 =20 =20 =20 =20 =20 =20

«Customer.FirstName»

«Order.OrderId»

«Customer.LastName»

«Order.Date»

=20

For the first set of merge fields, set name to "Custo= mer," and for the second, set name to "Order."<= /p>=20

Set= DataSource takes an object array of values and a string array of field = names. The two arrays must contain the same number of elements. Each name i= n the array of field names must be the same as the corresponding merge fiel= d name in the template.

=20

Each merge field in a WordWriter template must bind to a data source fie= ld/value pair. The number of merge fields in a set (merge fields that share= the same data source name or number) may not exceed the number of values i= n the data source defined by SetDataSource. However, the numbe= r of values in the data source may be greater than the number of merge fiel= ds in the set.

=20

This method may be called once for each set of merge fields in the main = document.

=20

Ex= amples

=20
C#
=20

          //--- Create a string array of field names.
          //--- The field names must be the same as the merge field
          //--- names in the template.
          string[] arrFields =3D {"CompanyName",
               "StreetAddr",
               "City",
               "State",
               "ZipCode"};

          //--- Create an object array of values
          //--- Ordinal numbers match those of the fields array
          object[] arrValues =3D {"SoftArtisans",
               "1330 Beacon Street",
               "Brookline",
               "MA",
               "02446"};
          oWW.SetDataSource(arrValues, arrFields, "data");
        
=20
=20
vb.net
=20

          '--- Create a string array of field names.
          '--- The field names  must be the same as the merge field
          '--- names in the template.
          Dim arrFields As String() =3D {"CompanyName", _
               "StreetAddr", _
               "City", _
               "State", _
               "ZipCode"}
          '--- Create an object array of values
          '--- Ordinal numbers match those of the fields array
          Dim arrValues As Object() =3D {"SoftArtisans", _
               "1330 Beacon Street", _
               "Brookline", _
               "MA", _
               "02446"}
          oWW.SetDataSource(arrValues, arrFields, "data")
        
=20
------=_Part_7822_1999409820.1711622908085--