0

I am trying to put data into cells using closedxml and according to their site we have to set parameters like this on the cells {{TestName}} but it won't work for me.

This is my code and I am not sure where I am going wrong.

const string outputFile = @"\\Reports\Output\Test.xlsx";
var template = new XLTemplate(@"\\Reports\Test.xlsx");

var test = new models.Test();
test.id = 1;
test.TestName = "ASDF";
test.TestScore = "303";

template.AddVariable(test) //also tried doing it like this.


template.AddVariable("TestScore", "232");
template.AddVariable("TestName", "TESTNAME");
template.SaveAs(outputFile);
Process.Start(new ProcessStartInfo(outputFile) { UseShellExecute = true });

And my excel template looks like this.

enter image description here

1 Answer 1

3

Solved it!

Just add template.Generate(); after adding the variables into the template.

Sign up to request clarification or add additional context in comments.

2 Comments

do have a repo example about it ?
no just add the template.Generate() before saving the file & it should add the variables

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.