Message-ID: <751114307.8693.1711655693436.JavaMail.web05$@web05> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_8692_386558526.1711655693436" ------=_Part_8692_386558526.1711655693436 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
Sets a two-dimensional - possibly jagged - array of objects as a templat= e data source.
=20public virtual void BindData(System.Object[][] arrayData, System.String[] = columnNames, System.String dataSourceName, DataBindingProperties property)=20
Public Overridable Sub BindData(ByVal arrayData As Object()(), ByVal column= Names As String(), ByVal dataSourceName As String, ByVal [property] As Data= BindingProperties)=20
columnNames
parameter is null, field binding can only be perfo=
rmed by ordinal (for example, %%=3DDSN.#1 or %%=3D$DSN). If=20
columnNames
is specified, both ordinal field binding and named=
field binding can be used.=20
dataSourceName
must be specified, but can be left as null or a=
n empty string if this is the first data source bound AND the data markers =
in the template use the=20
short da=
ta marker syntax or refer to the datasource by number rather than name.=
Note:=20
dataSourceName
does not include a data marker's column name, f=
or example, the=20
dataSourceName
for=20
%%=3DProducts.ProductID
is "Products."=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
Dat=
aBindingProperties.MaxRows,=20
D=
ataBindingProperties.Transpose, and/or=20
DataBindingProperties.WorksheetName properties for the workbook.=20
BindData
will throw this exception if=20
null
(C#) or=20
Nothing
(VB.NET) is passed to the method.=20
BindData
will throw this exception if the data source contains=
more rows than the worksheet can hold.
ExcelTemplate xlt =3D new ExcelTemplate(); xlt.Open(@"C:\DataBinding\ArrayBindingTemplate.xls"); string[][] twodim =3D { new string[]{"Watertown", "MA", "02= 472"}, new string[]{"Washington", "DC", "2= 0500"} }; string[] names =3D {"City", "State", "Zi= p"}; xlt.BindData(twodim, names, "TwoDimArray", xlt.CreateDataBindingProperties()); xlt.PreserveStrings =3D true; xlt.Process(); xlt.Save(Page.Response, "ArrayBinding.xls", false);=20
Dim xlt As New ExcelTemplate() xlt.Open("C:\DataBinding\ArrayBindingTemplate.xls") Dim twodim()() As String =3D New String()() { _ New String(){"Watertown", "MA", "02= 472"}, _ New String(){"Washington", "DC", "2= 0500"}, _ } Dim names As String() =3D {"City", "State", &= quot;Zip"} xlt.BindData(twodim, _ names, _ "TwoDimArray", _ xlt.CreateDataBindingProperties()) xlt.PreserveStrings =3D True xlt.Process() xlt.Save(Page.Response, _ "ArrayBinding.xls", _ False)=20