I am working on a project and I’m using ClosedXML to document some results in an Excel sheet.
I have the following data structure:
The PortTag Dictionary is just a Key Value Pair of Port Id and Tag (either “T”, “U”, “F” or “-“)
This should result in a Table that looks like this:
This is the combination of a vertical and a horizontal version and I’m failing to create it.
My current sheet displays information I polled off of a switch with SNMP and looks as follows:
Is there any help you can offer me or direct me to a source of knowledge regarding this problem?
I already read the information on the Github Wiki and the Website (https://closedxml.github.io/ClosedXML.Report/docs/en/)
thank you very much !
I. If all
Vlan entries have the same set of keys
You can use this approach:
- Define a vertical table
- Define a horizontal table
- Define another horizontal table
PortTagKeyswhere the keys should be placed
- In code, add
dataas one variable and
PortTagKeysas another (note that I ommit checks for null and empty collection for simplicity):
var template = new XLTemplate(workbook); template.AddVariable(data); template.AddVariable("PortTagKeys", data.Vlans.PortTag.Keys); template.Generate();
Vlan entries may have different sets of keys
In this case, I would suggest performing a pre-processing to get a collection of all keys and to fill all
PortTags with the same keys (putting
- for missing keys). I doubt it is possible to do in “pure” ClosedXML.Report, without pre-processing.