Message-ID: <1876135455.9591.1711696000966.JavaMail.web05$@web05> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_9590_1024469122.1711696000966" ------=_Part_9590_1024469122.1711696000966 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
Sets an ADO.NET DataSet as a data source to bind to template data marker= s.
=20public void BindData(System.Data.DataSet data, System.String dataSourceNam= e, DataBindingProperties property)=20
Public Sub BindData(ByVal data As System.Data.DataSet, ByVal dataSourceName= As String, ByVal [property] As DataBindingProperties)=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(); OleDbConnection Conn =3D new OleDbConnection(); DataSet OrdersDs =3D null; try { Conn.ConnectionString =3D Application["connstring"= ].ToString(); //--- SQL Query for orders string OrdersSQL =3D "SELECT Orders.OrderID, Customers.CompanyName As C= ustomer, " + "Orders.OrderDate, " + "([Order Details].UnitPrice * [Order Details].Quan= tity) " + "As [OrderTotal] " + "FROM Orders, [Order Details], Customers " + "WHERE Orders.OrderID=3D[Order Details].OrderID AN= D " + "Orders.CustomerID=3DCustomers.CustomerID AND Orde= rs.EmployeeID=3D?"; OleDbCommand CmdOrders =3D new OleDbCommand(OrdersSQL, Conn)= ; CmdOrders.Parameters.Add("@EmployeeID", EmployeeId= ); OleDbDataAdapter AdptSales =3D new OleDbDataAdapter(CmdOrder= s); OrdersDs =3D new DataSet(); AdptSales.Fill(OrdersDs, "Orders"); } xlt.BindData(OrdersDs, "Orders", xlt.CreateDataImportProperties());=20
Dim xlt As New ExcelTemplate() Dim Conn As New OleDbConnection() Dim OrdersDs As DataSet =3D Nothing Try Conn.ConnectionString =3D Application("connstring"= ).ToString() '--- SQL Query for orders Dim OrdersSQL As String =3D _ "SELECT Orders.OrderID, Customers.CompanyName As C= ustomer, " & _ "Orders.OrderDate, " & _ "([Order Details].UnitPrice * [Order Details].Quan= tity) " & _ "As [OrderTotal] " & _ "FROM Orders, [Order Details], Customers" &am= p; _ "WHERE Orders.OrderID=3D[Order Details].OrderID AN= D " & _ "Orders.CustomerID=3DCustomers.CustomerID AND Orde= rs.EmployeeID=3D?" Dim CmdOrders As New OleDbCommand(OrdersSQL, Conn) CmdOrders.Parameters.Add("@EmployeeID", EmployeeId= ) Dim AdptSales As New OleDbDataAdapter(CmdOrders) OrdersDs =3D New DataSet() AdptSales.Fill(OrdersDs, "Orders") End Try xlt.BindData(OrdersDs, _ "Orders", _ xlt.CreateDataImportProperties())=20