Insert a JArray as a simple table.
Compatibility
The macro can be used in the highlighted input document types only. A greyed-out icon indicates not supported.
Usage
When the JArray input is not a 'table' (i.e. not a JArray of JArrays or a JArray of JObjects), an error will occur.
Updates
The help and the Report Studio macro picker now show this macro as [JArray.Table:], the name it runs under. They previously showed [Jarray.Table:], which is not a working macro name.
History (3)
The 'style' parameter now applies Word's own built-in style for the Grid Table 5 Dark, Grid Table 6 Colorful and Grid Table 7 Colorful families (and their Accent variants), rather than a look-alike custom style named 'Grid Table 5', 'Grid Table 6' or 'Grid Table 7'. Using one of these styles for several tables no longer leaves extra styles such as 'Grid Table 51' in the Word document. Applies to every table-producing macro.
The 'repeatHeaderPerPage' parameter now works as expected (now honours the false setting).
Added the JArray.Table macro.
Behaviour (8)1 additional
| Parameter | Type | Presence | Purpose | Options | Default |
| List<ExecutionResult> | Optional | If specified, asserts the expected execution result of the macro. Accepts a single value or a semicolon-separated list of acceptable values (e.g. 'Success;Warning'). The macro executes normally; if the actual result matches any of the desired values, the result is converted to Success. If the actual result does not match, the result is converted to MacroError with a descriptive message. This is primarily used for testing and diagnostic purposes. Valid values are: 'Unknown', 'Success', 'MacroError', 'WorkerStopped', 'Running', 'Warning', 'NeverRun', 'Cancelled', 'Pending', 'Paused', 'SystemError', 'Deferred' and 'Stopped'. |
|
N/A | |
| Boolean | Optional | Should NCalc expression evaluation throw error on Overflow |
|
true | |
| String | Optional | If specified, asserts the expected output type of the macro result. The macro executes normally; if the actual type does not match, a macro error is generated. Requires 'storeAs', 'storeAsHidden', or 'storeFormattedValueAs' to be set for typed validation. Valid types include CLR names (e.g. Int32, Int64, Single, Double, Boolean, String, JArray, JObject) and C# keyword aliases (e.g. int, long, float, double, bool, string, uint, ulong, short, ushort, byte, sbyte, decimal, char, object). The special value 'Number' matches any numeric type. | N/A | N/A | |
| String | Optional | If specified, asserts the expected output value of the macro result. The macro executes normally; if the actual value does not match, a macro error is generated. When 'storeAs' or 'storeAsHidden' is set, the stored variable value is compared. Otherwise, the document output text is compared. | N/A | N/A | |
| String | Optional | The condition that must be true in order for the macro to be executed/evaluated. Must either evaluate to true or false, for example: "3+5=8" or "contains('abcd', 'z')". | N/A | true | |
| MacroMode | Optional | The mode in which variables are stored. In legacy mode (default for Schedules), the variable created is a string and formatted. In normal mode (default for Report Studio), the output variable is stored as a strongly-typed object, e.g. an Int32 or a JArray etc., rather than a formatted string. |
|
Legacy | |
| ObfuscationType | Optional | Obfuscation type. Use obfuscation to write reports where sensitive data is hidden. When used, ReportMagic guarantees that the same input string will map to the same output string for the whole of the report (but the next time the report runs, it will most likely map to a different value). If you use obfuscation, the property in your macro will not show up and instead, you will see a fake item of the obfuscation type chosen. |
|
None | |
| String | Optional | If specified, adds a warning message for this macro. This is processed as an NCalc, and the warning message will ALWAYS be present and will be the value of the evaluated NCalc expression. | N/A | N/A |
Additional (1)
| Parameter | Type | Presence | Purpose | Options | Default |
| Boolean | Optional | If true, the table will not be written to the report. This is useful if you want to use a Table macro in PowerPoint or RM Script files (which do not support adding tables) but have XLSX output enabled on the Schedule. This way the table data will be preserved and the macro will produce a Success rather than Macro Error, and the XLSX table will be generated. Note that in RM Script or Report Studio (code mode), you must set the hidden parameter to true or a Macro Error will occur. |
|
false |
Colours (13)
| Parameter | Type | Presence | Purpose | Options | Default |
| Color | Optional | The critical cell background color to use. If omitted, the default of #C00000 is used; set it explicitly to override. Affects a cell or row based on the ThresholdAffects parameter. |
|
Color [A=255, R=192, G=0, B=0] | |
| Color | Optional | The critical cell text color to use. If omitted, no change is made. Affects a cell or row based on the ThresholdAffects parameter. |
|
N/A | |
| Color | Optional | The error cell background color to use. If omitted, the default of #F08000 is used; set it explicitly to override. Affects a cell or row based on the ThresholdAffects parameter. |
|
Color [A=255, R=240, G=128, B=0] | |
| Color | Optional | The error cell text color to use. If omitted, no change is made. Affects a cell or row based on the ThresholdAffects parameter. |
|
N/A | |
| Color | Optional | The fatal cell background color to use. If omitted, the default of #960000 is used; set it explicitly to override. Affects a cell or row based on the ThresholdAffects parameter. |
|
Color [A=255, R=150, G=0, B=0] | |
| Color | Optional | The fatal cell text color to use. If omitted, no change is made. Affects a cell or row based on the ThresholdAffects parameter. |
|
N/A | |
| Color | Optional | The info cell background color to use. If omitted, the default of #00D5D5 is used; set it explicitly to override. Affects a cell or row based on the ThresholdAffects parameter. |
|
Color [A=255, R=0, G=213, B=213] | |
| Color | Optional | The info cell text color to use. If omitted, no change is made. Affects a cell or row based on the ThresholdAffects parameter. |
|
N/A | |
| Color | Optional | The cell color to use when no issue exists. Affects a cell or row based on the ThresholdAffects parameter. |
|
N/A | |
| Color | Optional | The cell text color to use when no issue exists. Affects a cell or row based on the ThresholdAffects parameter. |
|
N/A | |
| Color | Optional | The warning cell background color to use. If omitted, the default of #F0C000 is used; set it explicitly to override. Affects a cell or row based on the ThresholdAffects parameter. |
|
Color [A=255, R=240, G=192, B=0] | |
| Color | Optional | The warning cell text color to use. If omitted, no change is made. Affects a cell or row based on the ThresholdAffects parameter. |
|
N/A | |
| Color | Optional | The colour of the worksheet tab in Excel (XLSX) output. If omitted, the tab keeps its default colour. Has no effect on Word / PDF / HTML output, which have no worksheet tabs. |
|
N/A |
Formatting (10)
| Parameter | Type | Presence | Purpose | Options | Default |
| AutoFitBehavior | Optional | The Word autofit behaviour. If omitted, no change is made. |
|
Content | |
| List<String> | Optional | The column horizontal alignments. If fewer alignments are made than the number of columns, the last given value is used for the remaining columns. If omitted, no change is made. Supported values: Left, Right and Center. Usage: columnHorizontalAlignments=Left;Right;Center;...In Excel output files, columns may be automatically aligned based on their type (e.g. numbers are always right-justified), and all column headers are ALWAYS left-justified so their text is not obscured by filter drop-down arrows in the Excel UI. | N/A | N/A | |
| List<String> | Optional | The column vertical alignments. If fewer alignments are given than the number of columns, the last given value is used for the remaining columns. If omitted, no change is made. Supported values: Top, Centre and Bottom. Usage: columnVerticalAlignments=Top;Centre;Bottom;... Applies to Word, Report Studio and Excel output. | N/A | N/A | |
| Double | Optional | Override the table style's font size. This is achieved by setting the font size for each table cell. In Report Studio and HTML this is in pixels; in a Schedule (Word) it is in points. |
|
N/A | |
| CellFormat | Optional | The cell format to use. Options are: 'AllStrings', 'Auto' or 'NumbersAsStrings'. Auto automatically sets the format for the whole column, or it can be forced to a string with AllStrings. To preserve date / time formatting (with dateTimeFormat) but treat only number columns as strings, use NumbersAsStrings. |
|
Auto | |
| TableHorizontalAlignment | Optional | The horizontal alignment of the table on the page (does not affect Excel output). |
|
Left | |
| Double | Optional | The percentage of the available page that the table should occupy. |
|
N/A | |
| Boolean | Optional | Whether to repeat the header row at the beginning of each page. |
|
true | |
| String | Optional | Use Word's built in Table Styles (such as Grid Table 2 - Accent 1), or make your own in the Report Template. Built-in styles can be used in any document. Note that any custom styles you create, or customisations to the standard styles required that the styles exist in the input template XML (because they are not saved in Word documents by default). This can be achieved by assigning the style to a table, then delete the table and save the document. | N/A | Table Grid | |
| XlsxTableStyle | Optional | The XLSX table style to use in any XLSX output document. |
|
TableStyleMedium13 |
Time & Date (1)
| Parameter | Type | Presence | Purpose | Options | Default |
| String | Optional | The date/time format to use. Use the format specified here: https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings. When the format parameter is set to AllStrings, this is ignored unless you use NumbersAsStrings. Note however that this parameter only has an effect if all the values in the column are the same type. | N/A | yyyy-MM-dd |
Filtering & Sorting (4)
| Parameter | Type | Presence | Purpose | Options | Default |
| String | Optional | The condition on which each row is included. Fields should be referred to based on the column name in curly braces, for example: includeCondition ='{CreatedOn}'>'{StartOfLastMonth}'. | N/A | N/A | |
| String | Optional | If present, sorts alphanumerically by this column. | N/A | N/A | |
| String | Optional | If present, sorts reverse alphanumerically by this column. | N/A | N/A | |
| Int32 | Optional | Only display up to this number of rows. |
|
N/A |
Output (2)4 additional
| Parameter | Type | Presence | Purpose | Options | Default |
| String | Optional | The text to display should the macro fail to execute. Note that a poorly-specified macro (e.g. omitting mandatory parameters) will still result in an error message. | N/A | N/A | |
| String | Optional | The name of a variable to create should the macro fail to execute. The variable will be a text variable, and will contain either the failure text (only if the failureText parameter is set), otherwise it will contain the exception / failure message. | N/A | N/A |
Additional (4)
| Parameter | Type | Presence | Purpose | Options | Default |
| List<String> | Optional | The column names to show. If the columns parameter is not specified, the Macro's default will be used. | N/A | N/A | |
| String | Optional | If present, and the table has no rows, the specified text will be inserted in place of the table. | N/A | N/A | |
| String | Optional | The worksheet to save the result in the output Excel document (if so configured). Excel does not allow blank names, names above 31 characters, and the following characters: :, /, \, ?, *, [, ] | N/A | Table | |
| Boolean | Optional | Whether to output the result in the output Excel document (if so configured). |
|
true |
General (2)4 additional
| Parameter | Type | Presence | Purpose | Options | Default |
| JArray | Mandatory | The JArray to insert. | N/A | N/A | |
| String | Optional | Add a comment to make your document template more readable. The comment is discarded in the output document. | N/A | N/A |
Additional (4)
| Parameter | Type | Presence | Purpose | Options | Default |
| Boolean | Optional | Whether to de-camel-case the header row (i.e. convert 'MyHeaderText' to 'My Header Text'. |
|
false | |
| String | Optional | The table name (e.g. for XLSX output) | N/A | Table | |
| ThresholdAffects | Optional | What the threshold affects. |
|
Cell | |
| String | Optional | The threshold column. | N/A | N/A |
Deprecated (1)5 additional
| Parameter | Type | Preferred Parameter | Purpose | Options | Default |
| JArray | jArray | The JArray to insert. | N/A | N/A |
Additional (5)
| Parameter | Type | Preferred Parameter | Purpose | Options | Default |
| List<String> | columnHorizontalAlignments | The column horizontal alignments. If fewer alignments are made than the number of columns, the last given value is used for the remaining columns. If omitted, no change is made. Supported values: Left, Right and Center. Usage: columnHorizontalAlignments=Left;Right;Center;...In Excel output files, columns may be automatically aligned based on their type (e.g. numbers are always right-justified), and all column headers are ALWAYS left-justified so their text is not obscured by filter drop-down arrows in the Excel UI. | N/A | N/A | |
| List<String> | columnHorizontalAlignments | The column horizontal alignments. If fewer alignments are made than the number of columns, the last given value is used for the remaining columns. If omitted, no change is made. Supported values: Left, Right and Center. Usage: columnHorizontalAlignments=Left;Right;Center;...In Excel output files, columns may be automatically aligned based on their type (e.g. numbers are always right-justified), and all column headers are ALWAYS left-justified so their text is not obscured by filter drop-down arrows in the Excel UI. | N/A | N/A | |
| AutoFitBehavior | autoFit | The Word autofit behaviour. If omitted, no change is made. |
|
Content | |
| List<String> | columnHorizontalAlignments | The column horizontal alignments. If fewer alignments are made than the number of columns, the last given value is used for the remaining columns. If omitted, no change is made. Supported values: Left, Right and Center. Usage: columnHorizontalAlignments=Left;Right;Center;...In Excel output files, columns may be automatically aligned based on their type (e.g. numbers are always right-justified), and all column headers are ALWAYS left-justified so their text is not obscured by filter drop-down arrows in the Excel UI. | N/A | N/A | |
| Int32 | take | Only display up to this number of rows. |
|
N/A |
Examples (1)
Example 1
This example first creates a JArray of JObjects using the Object.Property macro, then inserts a table:
[Object.Property: value=<json>{ "Items": [ { "Property 1" : 1, "Property 2": "Apple", "Property 3" : 10.0 }, { "Property 1" : 2, "Property 2": "Banana", "Property 3" : 20.0 }, { "Property 1" : 3, "Property 2": "Cherry", "Property 3" : 30.0 }]}</json>, jsonPath="$.Items", =>A]
[JArray.Table: jArray={=A}]