Table of Contents

Method ReplacePlaceholders

Namespace
DocWright.Formats.Xlsx
Assembly
DocWright.Formats.Xlsx.dll

ReplacePlaceholders(IReadOnlyDictionary<string, object?>, XlsxPlaceholderOptions?)

Fills the placeholders in the sheet's text cells from a dictionary.

public XlsxPlaceholderResult ReplacePlaceholders(IReadOnlyDictionary<string, object?> values, XlsxPlaceholderOptions? options = null)

Parameters

values IReadOnlyDictionary<string, object>

The value for each name. A key with a null value fills as empty; a name with no key is unresolved.

options XlsxPlaceholderOptions

How placeholders are written and filled, or null for the defaults.

Returns

XlsxPlaceholderResult

How many were replaced, which names were and were not resolved, and the cells that could not be changed.

Remarks

A placeholder that is the whole of a cell takes the type of its value (unless TypedValues is off): {{Total}} filled with 1250.5m is a numeric cell that sums, in the format the template gave the cell. A DateTime is written as a date in the workbook's date system, and the cell is given DateFormat when its own format does not show dates.

A placeholder inside longer text is replaced by the value formatted with Culture. Formulas are not looked at.

Exceptions

ArgumentNullException

values is null.

ArgumentException

The prefix or the suffix is empty.

InvalidDocumentException

A name has no key and Unresolved is Throw (DXP1004); or the sheet's part is malformed.