...
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\
Download the template and the report to see how the Data Marker Options in the template change the way that the data in the report is presented.\
Code
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 //employee ID //Last NamE //First Name //Title //Zip object[,] values = { {1, 2, 3, 4}, {"Davolio", "Fuller", "Leverling", "Peacock"}, {"Nancy", "Andrew", "Janet", "Margaret"}, {"Sales Rep", "VP of Sales", "Sales Rep", "Sales Rep"}, {"02139","02144","23451","00213"} }; // 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 = @"..\..\templates\DataMarkerOptionsTemplate.xlsx"; xlt.Open(templatePath); // 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 xlt.Process(); // Save the report xlt.Save(@"..\..\Output\DataMarkerOptions_output.xlsx"); } } |
...