Expression syntax and context
Expressions use the shared .NET DynamicExpresso interpreter. They are C#-style expressions, not JavaScript or Excel formulas. Evaluate an expression with editable JSON data (English UK culture).
Common expressions
Section titled “Common expressions”| Expression | Result or purpose |
|---|---|
this.CustomerName |
The report’s customer name. |
this.Total * 1.2 |
Arithmetic; the sample produces 2940. |
this.Approved ? "Ready" : "Draft" |
Conditional value. |
this.Total.ToString("N2") |
Format a number using the selected report culture. |
this.Lines[0].Product |
First product, using zero-based indexing. |
this.Lines.Length |
Array length. JSON arrays are CLR arrays, not lists with Count. |
IsMatch(this.CustomerName, "^Alpine") |
Match text against a regular expression. |
Use +, -, *, /, %, comparisons such as == and >=, boolean operators &&, ||, and !, parentheses, and the ternary ?: operator. Quote string literals with double quotes. JSON transport escapes a literal quote as \"; a Word tag or Excel note contains the expression itself. The playground’s expression field is plain text.
| Context | this |
Other names |
|---|---|---|
| Word document root | Report data | root also refers to report data. |
| Word repeat child | Current collection item | root is original report data; block["Title"] is the current item of a named enclosing repeat. |
| Excel single cell | Report data | Use explicit this paths. |
| Excel table row | Current item | Do not assume Word’s named-repeat contexts. |
| Excel repeating grid | Depends on the grid structure | Use the iterator aliases declared in @repeat-grid. |
The playground’s First Lines item context models a Word repeat. Try this.Product, root.CustomerName, and block["Lines"].Quantity. The Tags repeat in the Word sample demonstrates a nested scalar collection with access to its enclosing Lines item. Sibling repeat items are not in scope; duplicate titles along an enclosing chain are invalid.
Bindings and modes
Section titled “Bindings and modes”Word stores expressions in control tags. if: this.Approved is a condition tag; the interpreter evaluates this.Approved, not the if: prefix. A repeat binds its collection in the surrounding context before evaluating its children. The Word pane and strict fill normalize simple bare paths, such as CustomerName, to this.CustomerName; compound expressions should use explicit context names.
Excel stores expressions in legacy notes, not threaded comments. The template engine removes notes from generated workbooks. Excel formula cells are a separate feature: formula text is preserved and recalculated by Excel, not by the reporting expression interpreter.
Legacy HTTP DOCX filling retains its older JSON marker/expression transforms. Strict DOCX and browser samples interpret JSON strings literally, disable external image sources, and do not register HTML helpers. Do not assume a helper configured in a library application is available in every host.
Types, culture, and errors
Section titled “Types, culture, and errors”Data types matter. A JSON number supports arithmetic; a quoted number is a string. Convert or format deliberately, and guard nullable values before accessing their members. null, a missing property, an out-of-range index, and an empty collection have different consequences. Test each condition and repeat path using representative data.
The selected culture affects methods such as numeric ToString("N2"). Website language does not change report culture. JSON has no native date type; strict literal-string handling does not implicitly turn every date-looking string into a .NET date object.
The Word tag limit is 64 characters including if:. If an expression fails, inspect the tag and context named in the diagnostic. Strict Word filling returns an error instead of a partial document. Excel filling can retain placeholders or skip structures with warnings; the browser surfaces these warnings with the generated output.