Intro
Excerpt |
---|
Data markers have multiple switches and options that are available for use in ExcelTemplate workbooks. |
ExcelTemplate Grouping and Nesting allows users to bind flat data to a specially formatted spreadsheet with the data being displayed in a grouped or nested format. To learn how to create a template for Grouping and Nesting, see our in-depth tutorai Using Grouping and Nesting with ExcelTemplate.
Note | ||||
---|---|---|---|---|
| ||||
This sample requires OfficeWriter Enterprise Edition to be installed because the OfficeWriter Grouping and Nesting is only available in the Enterprise Edition of the product. |
Code
Code Block |
---|
public class GroupingAndNesting
{
/// <summary>
/// Build the report with ExcelTemplate
/// </summary>
public void GenerateReport()
{
//--- Create a new ExcelTemplate object and open a template file
ExcelTemplate xlt = new ExcelTemplate();
//Open the template
xlt.Open(@"..\..\ExcelTemplateFiles\GroupingAndNestingTemplate.xlsx");
//--- Fill the dataset with the data from the CSV file
DataSet ds = GetCSVData(@"..\..\ExcelData\GroupingandNestingData.CSV");
//--- Bind the data to the template file and save it.
xlt.BindData(ds, "Data", xlt.CreateDataBindingProperties());
xlt.Process();
xlt.Save(@"..\..\ExcelOutputFiles\GroupingandNesting_output.xlsx");
}
//Parse the data from the CSV file
System.Data.DataSet GetCSVData(string csvFileName)
{
DataSet ds;
using (GenericParserAdapter parser = new GenericParserAdapter(csvFileName))
{
parser.ColumnDelimiter = ',';
parser.FirstRowHasHeader = true;
ds = parser.GetDataSet();
}
return ds;
}
}
|
\
Downloads
- Template: GroupingandNestingTemplate.xlsx
- Output: GroupingandNesting_output.xlsx