Method FillTemplate
- Namespace
- DocWright.Spreadsheet
- Assembly
- DocWright.Spreadsheet.dll
FillTemplate(IReadOnlyDictionary<string, object?>, XlsxTemplateOptions?)
Fills the workbook as a template: each block of rows marked {{#Name}} is repeated
once for each item of the list Name, with the item's members filled in, and every
other placeholder is filled from data.
public XlsxTemplateResult FillTemplate(IReadOnlyDictionary<string, object?> data, XlsxTemplateOptions? options = null)
Parameters
dataIReadOnlyDictionary<string, object>The values and the lists, by name.
optionsXlsxTemplateOptionsHow placeholders and blocks are filled; null for the defaults.
Returns
- XlsxTemplateResult
What was filled.
Remarks
See FillTemplate(IReadOnlyDictionary<string, object?>, XlsxTemplateOptions?) for the markers and what a repeated block carries. Every worksheet is filled, in tab order.
Exceptions
- ArgumentNullException
datais null.- ArgumentException
A block's value is not a list, a list holds objects whose members cannot be read, or the prefix or the suffix is empty.
- InvalidOperationException
A list needs more rows than the sheet has below its block.
- UnsupportedFeatureException
Rows of a block cannot be inserted or deleted, as Excel refuses (an array formula across the block's edge, a table's header).
- ResourceLimitExceededException
The blocks would write more cells than MaxCells.
- InvalidDocumentException
The markers do not pair up, blocks nest more than one level, the data has no value for a name and the options say to throw (DXP1004), or a sheet's part is malformed.