We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Combine TemplateMarkers with static content

I want to mix TemplateMarkers with static content, for example (as a template in 4 columns):

                   A                                     B                     C                   D
1   %Customers.Name - %Customers.FirstName - 42 - %Customers.City

And as a result I like to have:

Doe - John - 42 - London
Doe - Jane - 42 - Paris
Smith - William - 42 - New York
... - 42 - ...
... - 42 - ...
... - 42 - ...

In other words I want to have the value in column 3 repeated for each row in my Customers list. How can this be achieved?

1 Reply

VS Vikas Sekar Syncfusion Team June 15, 2015 12:09 PM UTC

Hi Okieh,

Thank you for using Syncfusion products.

XlsIO doen’t support using static variable in template marker. Whereas, this can be achieved by using “copy range” argument in the template, which will copy a value and show it for number of records it contains. To achieve this in template excel file need to allot a column for the variable we like to repeat for each and every record. Add the argument “copyrange:RC[]” in the previous column of the static value column.  Before applying marker need to set the static value in the starting position of the cell, which copy range refers. We have attached the screen shot of the template file, code snippet and simple sample for your reference.

Screen shot of template file:

In column 4 we are going to add the value that should repeat for every record and in the previous column (3rd column) while declaring the property we have added the argument copyrange and refer the range.

Code snippet:

ITemplateMarkersProcessor marker = workbook.CreateTemplateMarkersProcessor();

if (this._customers.Count == 0)


   this._customers = GetCustomerAsObjects();


marker.AddVariable("Customers", _customers);

worksheet.Range["D2"].Value = Customer.Value;


Sample: https://www.syncfusion.com/downloads/support/forum/119381/ze/Sample-2100172871

UG Link: https://help.syncfusion.com/windowsforms/overview

Please lets us know if you need any clarification.



Live Chat Icon For mobile
Up arrow icon