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.
Unfortunately, activation email could not send to your email. Please try again.

A Formula for each Row when using Template Markers

Thread ID:

Created:

Updated:

Platform:

Replies:

123270 Mar 2,2016 08:11 AM Mar 3,2016 07:45 AM ASP.NET Web Forms 1
loading
Tags: XlsIO
Phil Coe
Asked On March 2, 2016 08:11 AM

Hi, 

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? 

Thanks

Ishwarya Narayanan [Syncfusion]
Replied On March 3, 2016 07:45 AM

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);

 

marker.ApplyMarkers();

 

workbook.SaveAs("Output.xlsx");

 

workbook.Close();

engine.Dispose();

}

 

//DataTable Creation

static DataTable CreateDataTable()

{

DataTable products = new DataTable();

products.Columns.Add("Code");

products.Columns.Add("Desc");

products.Columns.Add("Qty");

products.Columns.Add("Rate");

 

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;

}

 

Regards,

Ishwarya N


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;