ClosedXML use "items" Expression in multiple worksheets with different data

26 views Asked by At

I am currently working with ClosedXML and I use the Expression "items" to auto-map data into my table like so:

using var workBook = new XLWorkbook(exportTemplateFile);

var list1 = workBook.Worksheet("List1");

var template = new XLTemplate(exportTemplateFile);

template.AddVariable("items", _appState.FirstDataSource);
template.Generate();
template.SaveAs(Path.Combine(generatedExportFolders, "MyFile.xlsx"));

Inside the FirstDataSource I have properties like "Data1", "Data2", "Data3" and so on. The template file looks something like this:

Worksheet "List1"

enter image description here

Then I have a _appState.SecondDataSource with properties called "NewData1", "NewData2" and "NewData3".

Worksheet "List2"

enter image description here

Now I want to do the same for the second worksheet called "List2", but I can't use "items" again, and as far as I know, it is the only expression to do that kind of auto-mapping.

Does anyone have an idea on how to solve this?

0

There are 0 answers