Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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
iconfalse
titleRequirements

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 StringDataSourceGroupingAndNesting
    {
        private string recipientName;
        private string recipientCompany;

        /// <summary>
        /// Build the report with ExcelTemplate
        /// </summary>
        public void GenerateReport()
        {
             this.recipientName = "Jon Smith";
     //--- Create a new ExcelTemplate object and open a template file

     this.recipientCompany = "SoftArtisans";     ExcelTemplate xlt = new ExcelTemplate();
   // Create an instance of SoftArtisans ExcelTemplate   //Open the template
       ExcelTemplate xlt = new ExcelTemplate( xlt.Open(@"..\..\ExcelTemplateFiles\GroupingAndNestingTemplate.xlsx");

            //--- OpenFill the templatedataset workbookwith the data from the CSV file
      string templatePath      DataSet ds = GetCSVData(@"..\..\templatesExcelData\StringDataSourceTemplateGroupingandNestingData.xlsxCSV");


          xlt.Open(templatePath);  //--- Bind the data to the template file and save it.
 // Bind the variables to the template datamarkers    xlt.BindData(ds, "Data", xlt.CreateDataBindingProperties());
      // %%=$RecipientName     xlt.Process();
            xlt.BindCellDataSave(recipientName, "RecipientName", xlt.CreateDataBindingProperties())@"..\..\ExcelOutputFiles\GroupingandNesting_output.xlsx");
        }

        //Parse %%=$RecipientCompanythe data from the CSV file
       xlt.BindCellData(recipientCompany, "RecipientCompany", xlt.CreateDataBindingProperties()) System.Data.DataSet GetCSVData(string csvFileName)
        {
            DataSet ds;
            using //(GenericParserAdapter Processparser the= template to populate it with the Data Source datanew GenericParserAdapter(csvFileName))
            {
      xlt.Process()          parser.ColumnDelimiter = ',';
             // Save the reportparser.FirstRowHasHeader by= streamingtrue;
to
the client             xlt.Save(@"..\..\Output\StringDataSource_output.xlsx"  ds = parser.GetDataSet();
            }
            return ds;
        }

...

    }


 

Downloads