Stores the previous table in a new tab in XLSX output documents.
Purpose
Use the [Table.Save:] macro to store the previous table in a new tab in XLSX output documents.
Compatibility
The macro can be used in the highlighted input document types only. A greyed-out icon indicates not supported.
Usage
The new tab will have name
Behaviour (5)
| Parameter | Type | Presence | Purpose | Options | Default |
| Boolean | Optional | Should NCalc expression evaluation throw error on Overflow |
|
true | |
| 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 the legacy mode (default for Schedules), the variable created is a string and formatted. In the normal mode (default for Report Studio), the output variable is stored as a strongly-typed theObject, e.g. an Int32 or a List |
|
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 |
Formatting (3)
| Parameter | Type | Presence | Purpose | Options | Default |
| Boolean | Optional | Whether to hide grid lines (for both View and Print modes) in the worksheet. In an XLSX document, each worksheet can have different settings for this. In Excel, these settings can be found in Page Layout -> Gridlines. |
|
false | |
| Int32 | Optional | The percentage size of images in tables when 'saveAsExcelTable' is true. Useful to tweak output image sizes in cells. |
|
100 | |
| XlsxTableStyle | Optional | The XLSX table style to use. This is ignored when 'saveAsExcelTable' is false. |
|
TableStyleMedium13 |
Filtering & Sorting (1)
| Parameter | Type | Presence | Purpose | Options | Default |
| List<String> | Optional | When used, the specified columns names (values in the first row) or any that remain if 'columns' is used, are removed. An error will be generated if any of the specified columns do not exist in the original table (or, if 'columns' was used, those that do not exist in the columns that remained). Do not use with tables that have merged cells or the results will be unpredictable (or an error may occur). Specify multiple columns joined by a semi-colon e.g. excludeColumns=Column A;Column B | N/A | N/A |
Output (4)
| Parameter | Type | Presence | Purpose | Options | Default |
| String | Optional | The text for the single cell (default A1 unless changed with 'firstCellName') in the new tab in the XLSX document if the table is empty. No formatting is applied. A header row only is considered an empty table. | N/A | N/A | |
| 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 | |
| Boolean | Optional | Whether to save as an actual Excel table. This should be set to false if the input table contains merged cells. ReportMagic will automatically set this to false if any merged cells are encountered. This also lets you have column headings with the same values (normally not allowed in a proper table). |
|
true |
General (8)
| Parameter | Type | Presence | Purpose | Options | Default |
| String | Mandatory | The name of the worksheet in the XLSX document. Also used for the table name, unless one is specified. Excel does not allow blank names, names above 31 characters, and the following characters: :, /, \, ?, *, [, ] | N/A | N/A | |
| List<String> | Optional | When used, only the specified column names (values in the first row) will be saved and in the specified order. An error will be generated if any of the specified columns do not exist in the original table. Do not use with tables that have merged cells or the results will be unpredictable (or an error may occur). Specify multiple columns joined by a semi-colon e.g. columns=Column A;Column B | 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 | |
| ExecutionResult | Optional | If specified, asserts the expected execution result of the macro. The macro executes normally; if the actual result matches the desired value, 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, Stopped. |
|
N/A | |
| 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 first cell name (the position of the upper-left cell of the table), such as A5. Note: Excel has a maximum of 1,048,576 rows and 16,384 columns (cell XFD1048576), and you should take into account the number of columns expected in the output table. | N/A | A1 | |
| String | Optional | The name of the table in the XLSX document. Table names must be unique across all worksheets (for example, you cannot have a table called 'table1' in worksheet A and another table called 'table 1' in worksheet B). When 'saveAsExcelTable' is false, this parameter is ignored. | N/A | N/A |
Deprecated (2)
| Parameter | Type | Preferred Parameter | Purpose | Options | Default |
| String | worksheetName | The name of the worksheet in the XLSX document. Also used for the table name, unless one is specified. Excel does not allow blank names, names above 31 characters, and the following characters: :, /, \, ?, *, [, ] | N/A | N/A | |
| String | worksheetName | The name of the worksheet in the XLSX document. Also used for the table name, unless one is specified. Excel does not allow blank names, names above 31 characters, and the following characters: :, /, \, ?, *, [, ] | N/A | N/A |
Examples (5)
Example 1
Saves the last table:
[Calculate: value=`list(list('Month', 'London', 'Manchester', 'Cardiff', 'Newcastle'), list('October', 1, 2, 3, 4), list('September', 5, 6, 7, 8))`, =>Values][List.Table: values={=Values}][Table.Save: worksheetName=My Worksheet Name 1]Example 2
Saves the last table and hides the grid lines:
[Calculate: value=`list(list('Month', 'London', 'Manchester', 'Cardiff', 'Newcastle'), list('October', 1, 2, 3, 4), list('September', 5, 6, 7, 8))`, =>Values][List.Table: values={=Values}][Table.Save: worksheetName=My Worksheet Name 2, hideGridLines=true]Example 3
Saves the last table and inserts at a specific cell:
[Calculate: value=`list(list('Month', 'London', 'Manchester', 'Cardiff', 'Newcastle'), list('October', 1, 2, 3, 4), list('September', 5, 6, 7, 8))`, =>Values][List.Table: values={=Values}][Table.Save: worksheetName=My Worksheet Name 3, firstCellName=B2]Example 4
Saves the last table but includes specific columns:
[Calculate: value=`list(list('Month', 'Priority', 'Assignee', 'Date', 'Amount'), list('October', 1, 2, 3, 4), list('September', 5, 6, 7, 8))`, =>Values][List.Table: values={=Values}][Table.Save: worksheetName=My Worksheet Name 4, columns=Date;Amount]Example 5
Saves the last table but excludes specific columns:
[Calculate: value=`list(list('Month', 'Priority', 'Assignee', 'Date', 'Amount'), list('October', 1, 2, 3, 4), list('September', 5, 6, 7, 8))`, =>Values][List.Table: values={=Values}][Table.Save: worksheetName=My Worksheet Name 5, excludeColumns=Priority;Assignee]