WorkbookDesigner.SetDataSource

SetDataSource(string, ICellsDataTable)

Sets data source of a ICellsDataTable object.

public void SetDataSource(string dataSource, ICellsDataTable cellsDataTable)
ParameterTypeDescription
dataSourceStringThe name of the data source.
cellsDataTableICellsDataTabledata table.

See Also


SetDataSource(DataSet)

Sets data source of a DataSet object.

public void SetDataSource(DataSet dataSet)
ParameterTypeDescription
dataSetDataSetDataSet object

Examples


[C#]

//Create a connection object, specify the provider info and set the data source.
OleDbConnection con = new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=Northwind.mdb");
//Open the connection object.
con.Open();
//Create a command object and specify the SQL query.
OleDbCommand cmd = new OleDbCommand("Select * from [Order Details]", con);
//Create a data adapter object.
OleDbDataAdapter da = new OleDbDataAdapter();
//Specify the command.
da.SelectCommand = cmd;
//Create a dataset object.
DataSet ds = new DataSet();
//Fill the dataset with the table records.
da.Fill(ds, "Order Details");
//Create a datatable with respect to dataset table.
DataTable dt = ds.Tables["Order Details"];
//Create WorkbookDesigner object.
WorkbookDesigner wd = new WorkbookDesigner();
//Open the template file (which contains smart markers).
wd.Workbook = new Workbook("SmartMarker_Designer.xls");
//Set the datatable as the data source.
wd.SetDataSource(dt);
//Process the smart markers to fill the data into the worksheets.
wd.Process(true);
//Save the excel file.
wd.Workbook.Save("outSmartMarker_Designer.xls");

[Visual Basic]

'Create a connection object, specify the provider info and set the data source.
Dim con As OleDbConnection = New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=Northwind.mdb")
'Open the connection object.
con.Open()
'Create a command object and specify the SQL query.
Dim cmd As OleDbCommand = New OleDbCommand("Select * from [Order Details]", con)
'Create a data adapter object.
Dim da As OleDbDataAdapter = New OleDbDataAdapter()
'Specify the command.
da.SelectCommand = cmd
'Create a dataset object.
Dim ds As DataSet = New DataSet()
'Fill the dataset with the table records.
da.Fill(ds, "Order Details")
'Create a datatable with respect to dataset table.
Dim dt As DataTable = ds.Tables("Order Details")
'Create WorkbookDesigner object.
Dim wd As WorkbookDesigner = New WorkbookDesigner()
'Open the template file (which contains smart markers).
Dim workbook As Workbook = New Workbook("SmartMarker_Designer.xls")
wd.Workbook = workbook
'Set the datatable as the data source.
wd.SetDataSource(dt)
'Process the smart markers to fill the data into the worksheets.
wd.Process(True)
'Save the excel file.
wd.Workbook.Save("outSmartMarker_Designer.xls")

See Also


SetDataSource(DataTable)

Sets data source of a DataTable object.

public void SetDataSource(DataTable dataTable)
ParameterTypeDescription
dataTableDataTableDataTable object

See Also


SetDataSource(string, DataView)

Sets data source of a DataView object and binds it to a data source name.

public void SetDataSource(string dataSourceName, DataView dataView)
ParameterTypeDescription
dataSourceNameStringData source name.
dataViewDataViewDataView object.

See Also


SetDataSource(DataView)

Sets data source of a DataView object.

public void SetDataSource(DataView dataView)
ParameterTypeDescription
dataViewDataViewDataView object

See Also


SetDataSource(string, IDataReader, int)

Sets data source of a IDataReader object.

public void SetDataSource(string name, IDataReader dataReader, int rowCount)
ParameterTypeDescription
nameStringThe data source map name.
dataReaderIDataReaderIDataReader object
rowCountInt32The number of the data rows. If the smart marker does not contains “noadd”, we have to insert rows by the row count for performance issue and dynamic repeated formulas. -1 means the param is useless.

See Also


SetDataSource(string, object)

Sets data binding to a variable.

public void SetDataSource(string variable, object data)
ParameterTypeDescription
variableStringVariable name created using smart marker.
dataObjectSource data.

See Also


SetDataSource(OleDbConnection)

Sets data source of a OleDbConnection object.

public void SetDataSource(OleDbConnection connection)
ParameterTypeDescription
connectionOleDbConnectionOleDbConnection object

See Also


SetDataSource(SqlConnection)

Sets data source of a SqlConnection object.

public void SetDataSource(SqlConnection connection)
ParameterTypeDescription
connectionSqlConnectionSqlConnection object

See Also