Message-ID: <758348039.9739.1711701141927.JavaMail.web05$@web05> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_9738_978404274.1711701141927" ------=_Part_9738_978404274.1711701141927 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html ExcelTemplate.BindRowData(System.Collections.IEnumerable, String= (), String, DataBindingProperties)

ExcelTemplate.BindRowData(System.Collections.IEnumerable, String(),= String, DataBindingProperties)

Description

=20

Sets a row's data source to an = IEnumerable collection. The IEnumerable interface sup= ports a simple iteration over a collection.
This method will return o= nly one row of data for the column bound by the datamarker. You must insert= a datamarker into the template for each column of data you want shown.

= =20
C#
=20
 public virtual void BindRowData(System.Collections.IEnumerable dataSource,=
 System.String[] columnNames, System.String dataSourceName, DataBindingProp=
erties property)
=20
=20
vb.net
=20
Public Overridable Sub BindRowData(ByVal dataSource As System.Collections.I=
Enumerable, ByVal columnNames As String(), ByVal dataSourceName As String, =
ByVal [property] As DataBindingProperties)
=20
=20

Parameters

=20
dataSource
An=20 IEnumerable collection to use as the data source.=20
colNames
The names of the col= umns to get from the data source. If the=20 columnNames parameter is null, field binding can only be perfo= rmed by ordinal (for example, %%=3DDSN.#1 or %%=3D$DSN). If=20 colNames is specified, both ordinal field binding and named fi= eld binding can be used.=20
dataSourceName
The name= of the data marker at which to insert the values imported from the data so= urce. For example, to bind a data source to the data marker %%=3DOrders.Ord= erId, the value of dataSourceName should be "Orders". The string = passed must begin with a letter.=20
property
The=20 DataBindin= gProperties object which contains information about how the data should= be bound to the template.=20 property Must be specified, but the=20 DataBindingProperties need not be set beforehand. To bind data= to a template with the default=20 DataBindingProperties, pass in=20 ExcelTemplate.CreateDataBindingProperties() as the=20 property value. Otherwise, use the=20 ExcelTemplate.CreateDataBindingProperties() method to generate= a new=20 DataBindingProperties object and set the=20 Da= taBindingProperties.MaxRows,=20 = DataBindingProperties.Transpose, and/or=20 DataBindingProperties.WorksheetName properties for the workbook.=20

Exceptions

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

Remarks

You can set several da= ta sources for a single template. Use the following methods to set template= data sources:=20 BindC= ellData,=20 Bin= dColumnData,=20 BindRo= wData, and=20 BindData<= /a>.=20

Examples

=20
C#
=20

          ExcelTemplate xlt =3D new ExcelTemplate();
          xlt.Open(@"C:\ExcelWriter\EmployeeOrdersTemplate.xls");

          //--- Bind the IEnumerable collection to the
          //--- %%=3DOrders.[Field] data marker.
          xlt.BindRowData(OrdersColl,
               null,
               "Orders",
               xlt.CreateDataBindingProperties());
          xlt.Process();
          xlt.Save(Page.Response, "EmployeeOrders.xls", false);
        
=20
=20
vb.net
=20

          Dim xlt As New ExcelTemplate();
          xlt.Open("C:\ExcelWriter\EmployeeOrdersTemplate.xls")

          '--- Bind the IEnumerable collection to the
          '--- %%=3DOrders.[Field] data marker.
          xlt.BindRowData(OrdersColl, _
               null, _
               "Orders", _
               xlt.CreateDataBindingProperties())
          xlt.Process()
          xlt.Save(Page.Response, "EmployeeOrders.xls", False)
        
=20
------=_Part_9738_978404274.1711701141927--