Page tree

Versions Compared

Key

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

...

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