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

A Formula for each Row when using Template Markers


I have a template with a bunch of markers across one row, I would like a formula for each row that gets generated by the template markers, I have tried putting the formula in the template on the top row but it only shows for the first row when I generate the new excel file, I hope this makes sense,  can you tell me what I'm doing wrong? 


1 Reply

IN Ishwarya Narayanan Syncfusion Team March 3, 2016 12:45 PM UTC

Hi Phil,


Thank you for contacting Syncfusion support.


In Template Marker, we provide an option to copy a range of values using copyrange property. We prepared a sample in the following link to update the formula in the generated file based on the DataTable row count. Please check the sample and let us confirm whether the sample helps you to achieve your requirement. Also you can refer the UG link for further reference about working with Template Markers.


Sample Link: http://www.syncfusion.com/downloads/support/directtrac/general/ze/XlsIO_Sample549030196


UG Link: http://help.syncfusion.com/file-formats/xlsio/working-with-template-markers


Code Sample:


public static void CreateWorkbook()


ExcelEngine engine = new ExcelEngine();

IApplication application = engine.Excel;

application.DefaultVersion = ExcelVersion.Excel2013;


IWorkbook workbook = application.Workbooks.Open("../../Data/InputTemplate.xlsx");

IWorksheet sheet = workbook.Worksheets[0];


DataTable dt = CreateDataTable();


sheet["C2"].Value = "%products.Desc;copyrange:R2C6:R" + dt.Rows.Count + "C6";


ITemplateMarkersProcessor marker = workbook.CreateTemplateMarkersProcessor();

marker.AddVariable("products", dt);










//DataTable Creation

static DataTable CreateDataTable()


DataTable products = new DataTable();






products.Rows.Add(1000, "Pen", 3, 2);

products.Rows.Add(1001, "Writing Pad", 5, 4);

products.Rows.Add(1002, "Eraser", 10, 1);

products.Rows.Add(1003, "Pencil", 20, 1);

products.Rows.Add(1004, "30CM Scale", 20, 3);


return products;




Ishwarya N

Live Chat Icon For mobile
Up arrow icon