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
Updates
In reports with an HTML input document, a one-row table saved with 'saveAsExcelTable' set to false and 'emptyTableText' set now keeps its row, instead of being treated as an empty table and discarded.
History (13)
In Word reports with 'emptyTableText' set, a table whose rows contain only images is no longer discarded as empty, a genuinely blank table now writes the empty-table text as designed, and a one-row table saved with 'saveAsExcelTable' set to false keeps its row.
In Word reports, pictures in table cells transfer to the Excel worksheet again, scaled with 'imageScalePercent' and capped to Excel's cell limits as the help describes. Picture transfer had been broken since January 2026.
A 'tableName' that differs only by letter case from one already used elsewhere in the workbook (for example 'tableName=Region' when 'region' is taken) no longer fails with 'Tablename is not unique'. Excel treats the two as the same name, so the table is saved under an automatically numbered name and the existing warning reports which name was used.
A 'worksheetName' that differs only by letter case from one already used in the workbook (for example 'worksheetName=Sales' followed by 'worksheetName=SALES') no longer fails the report with 'A worksheet with this name already exists in the workbook'. Excel treats the two as the same name, so the worksheet is created under an automatically numbered name. A warning is now also produced whenever a worksheet has to be created under a different name to the one requested, including when the two names match exactly, which was previously silent.
A table containing merged cells that span ROWS but not columns now keeps them when saved with 'saveAsExcelTable' set to false. Previously those merges were dropped entirely unless the same table also happened to contain a merge spanning columns.
A table where a merge spanning rows crosses a merge spanning columns now saves correctly with 'saveAsExcelTable' set to false. Previously, when the two crossed anywhere other than at the first or last row of the row span, the macro failed with 'A range is partly merged with the another merged range'.
When the 'columns' and 'excludeColumns' parameters between them remove every column, the macro now writes the 'emptyTableText' text instead of failing with an Excel cell range error, and gives a clear error when that parameter is not set.
A short 'tableName' of one to three letters (for example 'tableName=abc') no longer fails with 'Tablename is not valid', and a warning is now produced whenever the table has to be saved under a different name to the one requested.
Naming the same column twice in the 'columns' parameter now gives a clear macro error, instead of silently producing duplicate column headings that stopped the whole XLSX document from being saved.
The 'columns' and 'excludeColumns' parameters no longer fail when the table has rows containing fewer cells than the header row. Any missing cells are now treated as empty.
Using the 'columns' or 'excludeColumns' parameters when 'saveAsExcelTable' is false now explains that the combination is not supported, instead of incorrectly reporting that the columns do not exist.
An empty table saved with 'saveAsExcelTable' set to false no longer fails with 'Sequence contains no elements'.
When the 'emptyTableText' and 'excludeColumns' parameters are used, and the specified columns do not exist, the macro now produces a warning instead of an error.
Behaviour (8)
| 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 |
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). If this parameter and 'columns' between them remove every column, the result is treated as an empty table (see 'emptyTableText'). This parameter cannot be used when 'saveAsExcelTable' is false. Specify multiple columns joined by a semi-colon e.g. excludeColumns=Column A;Column B | N/A | N/A |
Output (6)
| 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). If this parameter and 'excludeColumns' between them remove every column, the result is treated as an empty table (see 'emptyTableText'). Each column may only be named once, and this parameter cannot be used when 'saveAsExcelTable' is false. Specify multiple columns joined by a semi-colon e.g. columns=Column A;Column B | N/A | N/A | |
| 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, as is a table where the 'columns' and 'excludeColumns' parameters have between them removed every column. | 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). Note that the 'columns' and 'excludeColumns' parameters cannot be used when this is false, because removing a column is not meaningful once a table contains merged cells. |
|
true |
General (3)
| Parameter | Type | Presence | Purpose | Options | Default |
| String | Optional | Add a comment to make your document template more readable. The comment is discarded in the output document. | 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). Excel does not allow a table name that could be read as a cell reference (for example 'abc1', which is column ABC row 1), so an underscore is appended automatically if the name would otherwise clash. 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]