Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0
Description

Excerpt

Sets an object as a data source for a single cell in a template.

Signature
C#C#
Wiki Markup
{description}
{excerpt}Sets an object as a data source for a single cell in a template.{excerpt}
{signature:C#}
 public virtual void BindCellData(System.Object cellData, System.String dataSourceName, DataBindingProperties property)
Signature
{signature}{signature:vb.net
vb.net
}
Public Overridable Sub BindCellData(ByVal cellData As Object, ByVal dataSourceName As String, ByVal [property] As DataBindingProperties)
Parameters

...

An object to use as the data source.

...

The name of the template data marker at which to insert the data source value. This parameter must be specified, but can be null or an empty string when setting the first data source to bind to the template.

...

The DataBindingProperties object which contains information about how the data should be bound to the template. property Must be specified, but the DataBindingProperties need not be set beforehand. To bind data to a template with the default DataBindingProperties, pass in ExcelTemplate.CreateDataBindingProperties() as the property value. Otherwise, use the ExcelTemplate.CreateDataBindingProperties() method to generate a new DataBindingProperties object and set the DataBindingProperties.MaxRows, DataBindingProperties.Transpose, and/or DataBindingProperties.WorksheetName properties for the workbook.

Exceptions

...

BindCellData will throw this exception if null (C#) or Nothing (VB.NET) is passed to the method.

...

Remarks

You can set several data sources for a single template. Use the following methods to set template data sources: BindCellData, BindColumnData, BindRowData, and BindData.

{signature}
{parameters}
{param:cellData}An object to use as the data source.{param}
{param:dataMarkerName}The name of the template data marker at which to insert the data source value. This parameter must be specified, but can be null or an empty string when setting the first data source to bind to the template.{param}
{param:property}The [DataBindingProperties|DataBindingProperties] object which contains information about how the data should be bound to the template. {{property}} Must be specified, but the {{DataBindingProperties}} need not be set beforehand. To bind data to a template with the default {{DataBindingProperties}}, pass in {{ExcelTemplate.CreateDataBindingProperties()}} as the {{property}} value. Otherwise, use the {{ExcelTemplate.CreateDataBindingProperties()}} method to generate a new {{DataBindingProperties}} object and set the {{DataBindingProperties.MaxRows}}, [DataBindingProperties.Transpose|DataBindingProperties.Transpose], and/or [DataBindingProperties.WorksheetName|DataBindingProperties.WorksheetName] properties for the workbook.{param}
{exceptions}
{exception:ArgumentNullException}{{BindCellData}} will throw this exception if {{null}} \(C\#\) or {{Nothing}} \(VB.NET\) is passed to the method.{exception}
{exception:ArgumentException}{exception}
{remarks}You can set several data sources for a single template. Use the following methods to set template data sources: [BindCellData|ExcelTemplate.BindCellData(Object, String, DataBindingProperties)], [BindColumnData|ExcelTemplate.BindColumnData], [BindRowData|ExcelTemplate.BindRowData], and [BindData|ExcelTemplate.BindData].

{remarks}
{example}{code:csharp|title=C#}

          //--- Set a cell data source for the data marker
          //--- %%=$Company
          xlt.BindCellData("SoftArtisans",
               "Company",
               xlt.CreateDataBindingProperties());
        
{code}
{code:vb.net
|title=vb.net
}

          '--- Set a cell data source for the data marker
          '--- %%=$Company
          xlt.BindCellData("SoftArtisans", _
               "Company", _
               xlt.CreateDataBindingProperties())
        {code}

{example}
Example
Code Block
csharpcsharp
titleC#
Code Block
vb.nettitle