Versions Compared


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



Data markers have multiple switches and options that are available for use in ExcelTemplate workbooks.

The Data Marker Options used in this example are:

  • Fieldname, which imports the name of the field
  • Uppercase, which forces characters to uppercase
  • Lowercase, which forces characters to lowercase
  • Preserve, which forces number strings to be treated as text
  • Optional, this will cause the data marker's place to be left empty if it is unbound


Code Block
public class DataMarkerOptions
        /// <summary>
        /// Build the report with ExcelTemplate
        /// </summary>
        public void GenerateReport()
              // This 2D Object[][] array will hold the values to be imported

              object[,] values = {
                              //employee ID 
                              {1, 2, 3, 4},
                              //Last Name   
                              {"Davolio", "Fuller", "Leverling", "Peacock"},
                              //First Name 
                              {"Nancy", "Andrew", "Janet", "Margaret"},
                              {"Sales Rep", "VP of Sales", "Sales Rep", "Sales Rep"},

            // These are the field names
            string[] colnames = { "EmployeeID", "LastName", "FirstName", "Title", "Zip" };
            // Create an instance of ExcelTemplate
            ExcelTemplate xlt = new ExcelTemplate();
            // Open the template workbook
                        string templatePath = @"..\..\ExcelTemplateFiles\DataMarkerOptionsTemplate.xlsx";

            // Pass colnames and values arrays to BindData()
            DataBindingProperties bindingProperties = xlt.CreateDataBindingProperties();
            bindingProperties.MaxRows = ExcelTemplate.ALL_ROWS;
            bindingProperties.Transpose = true;
            xlt.BindData(values, colnames, "dSource", bindingProperties);
            // Call the process() method to populate the template with the data source values
            // Save the report