Class WorkbookDesigner
WorkbookDesigner class
Encapsulates the object that represents a designer spreadsheet.
public class WorkbookDesigner
Constructors
| Name | Description |
|---|
| WorkbookDesigner() | Initializes a new instance of the WorkbookDesigner class. |
| WorkbookDesigner(Workbook) | Initializes a new instance of the WorkbookDesigner class. |
Properties
| Name | Description |
|---|
| CalculateFormula { get; set; } | Indicates whether formulas should be calculated. |
| CallBack { get; set; } | Gets and sets callback interface of processing smartmarker. |
| ContainsVariables { get; set; } | (Obsolete.) Indicates whether the first worksheet contains custom variables. |
| LineByLine { get; set; } | (Obsolete.) Indicates whether processing the smart marker line by line. |
| RepeatFormulasWithSubtotal { get; set; } | Indicates whether repeating formulas with subtotal row. |
| SortDataSource { get; set; } | Indicates whether sorting data source. |
| UpdateEmptyStringAsNull { get; set; } | If TRUE, Null will be inserted if the value is “”; |
| UpdateReference { get; set; } | Indicates if references in other worksheets will be updated. |
| VariablesWorksheetName { get; set; } | Gets and sets the name of the worksheet which contains variables smart marker. |
| Workbook { get; set; } | Gets and sets the Workbook object. |
Methods
| Name | Description |
|---|
| ClearDataSource() | Clears all data sources. |
| GetSmartMarkers() | Returns a collection of smart markers in a spreadsheet. |
| Process() | Processes the smart markers and populates the data source values. |
| Process(bool) | Processes the smart markers and populates the data source values. |
| Process(int, bool) | Processes the smart markers and populates the data source values. |
| Process(Range, bool) | (Obsolete.) Processes the smart markers and populates the data source values. |
| SetDataSource(DataSet) | Sets data source of a DataSet object. |
| SetDataSource(DataTable) | Sets data source of a DataTable object. |
| SetDataSource(DataView) | Sets data source of a DataView object. |
| SetDataSource(OleDbConnection) | Sets data source of a OleDbConnection object. |
| SetDataSource(SqlConnection) | Sets data source of a SqlConnection object. |
| SetDataSource(string, DataView) | Sets data source of a DataView object and binds it to a data source name. |
| SetDataSource(string, ICellsDataTable) | Sets data source of a ICellsDataTable object. |
| SetDataSource(string, object) | Sets data binding to a variable. |
| SetDataSource(string, IDataReader, int) | Sets data source of a IDataReader object. |
| SetJsonDataSource(string, string) | Set json string value as data source of smart markers. |
Examples
namespace AsposeCellsExamples
{
using Aspose.Cells;
using System;
using System.Data;
public class WorkbookDesignerDemo
{
public static void WorkbookDesignerExample()
{
// Create WorkbookDesigner object
WorkbookDesigner wd = new WorkbookDesigner();
// Open the template file (which contains smart markers)
wd.Workbook = new Workbook("SmartMarker_Designer_original.xlsx");
// Initialize your data from data source
DataSet ds = new DataSet();
// Add data to the dataset (this is just an example, replace with actual data source)
DataTable dt = new DataTable("Table1");
dt.Columns.Add("Column1");
dt.Columns.Add("Column2");
dt.Rows.Add("Value1", "Value2");
dt.Rows.Add("Value11", "Value22");
ds.Tables.Add(dt);
// Set the dataset as the data source
wd.SetDataSource(ds);
// Process the smart markers to fill the data into the worksheets
wd.Process(true);
// Save the excel file
wd.Workbook.Save("WorkbookDesignerExample.xlsx");
// Demonstrating other properties
wd.RepeatFormulasWithSubtotal = true;
wd.UpdateEmptyStringAsNull = true;
wd.UpdateReference = true;
wd.CalculateFormula = true;
wd.LineByLine = true;
// Clear data source
wd.ClearDataSource();
// Set data source using different methods
wd.SetDataSource("dataSourceName", dt);
wd.SetDataSource(dt);
wd.SetDataSource(ds);
wd.SetDataSource("dataSourceName", new DataView(dt));
wd.SetDataSource(new DataView(dt));
wd.SetDataSource("name", new DataTableReader(dt), dt.Rows.Count);
wd.SetJsonDataSource("variable", "{\"key\":\"value\"}");
wd.SetDataSource("variable", new object());
// Process the smart markers again
wd.Process();
wd.Process(true);
wd.Process(0, true);
// Save the excel file again
wd.Workbook.Save("WorkbookDesignerExample_SmartMarker_Designer_Processed.xlsx");
return;
}
}
}
See Also