Skip to main content

SMART Generic Excel Report

Extension – SMART Generic Excel Report, is designed to be used together with the "SMART Data Template" extension.

The SMART Generic Excel Report add-on is an extension for Microsoft Dynamics 365 Business Central that enables the generation of Excel reports based on created data templates. It uses mappings between variables in the data template and Excel report cells — without writing any code or involving a developer.

To generate Generic Excel reports, follow these configuration steps.

1. Creating a Generic Excel Report​

Page: Generic Excel Reports

You need to create a new generic Excel report by filling in the following fields:

FieldDescription
CodeUnique identifier of the report.
DescriptionDescription of the report.
Excel Template CodeSelect the Excel Template to be used for generating the report. The template must be pre-created with all relevant cells and named ranges identified for data mapping from the data templates.
Main DataItem Table IdID of the root table.
Main DataItem Table NameName of the root table (auto-filled).
Data Template CodeSelect the data template on which the report will be based. The data template must include all variables that will be exported into the Excel report. For a detailed guide on creating and configuring a data template, refer to the SMART Data Template scenario.
Multi-CompanySet to Yes to build the report from the data of several companies of the environment, one after another. See section 6.
Company SelectionHow the companies are chosen: Ask opens a filter page every time the report runs, All Companies uses every company, Filter uses the company filter below.
Company FilterA filter on the company name, for example COMPANY A|COMPANY B. With Ask, the filter page opens on the Name field with this filter, so the user confirms or changes it instead of typing it again.
On Company ErrorWhat happens to a company whose data cannot be read: Skip Company leaves it out and lists it after the export, Show Error stops the report. Choose Show Error when the workbook must be complete or not exist at all.

2. Creating Report Sections​

For the selected Excel template, you need to add sections in the Sections table part.

FieldDescription
Sheet NameName of the sheet in the Excel file selected in the Excel Template Code field — must be chosen from the dropdown list.
Section NameName of the corresponding range in the Excel template — must be selected from the dropdown list. All ranges must be pre-created in the Excel template defined in the Excel Template Code field. Examples include HEADER, LINE, FOOTER.
RepeatingSet to Yes for sections in the Excel report that should repeat.
Print OnceSet to Yes for a section that belongs to the workbook and not to a company — a report title, a column header or a footer. In a multi-company report it is written only once: a section placed before the last per-company section is written with the first company, a section placed after it is written once, after the last company. Every other section is written again for each company.

3. Configuring Cell Mappings for Excel​

For each cell in the Excel report that should receive data from the system, you must define a mapping with the variables from the data template specified in the Data Template Code field. To configure this mapping, on the Generic Excel Report card, for each section, go to the Gen. Excel Report Mapping page by clicking the Mapping button on the row for the section.

On the Gen. Excel Report Mapping page, you can use the Suggest data items function to select cells from the Excel template that need mappings (cells from the Excel template will be created automatically when user import Excel template to the system).

FieldDescription
Data Item NameName of the cell in the Excel template.
Data TypeDefine the format in which data will be exported to Excel, e.g.: Text (text format); Date (date format); Decimal (numeric format); Boolean (Yes/No).
Number FormatDefine the numeric format to be applied to the exported values.
Mapping Data CodeSpecifies the variable from the data template used in this generic report that should be exported into the defined Excel cell.

4. Running the Report​

To run the report, go to the Generic Excel Report page and trigger the Run Report action.

5. Report Selection for HRP Report Selection​

The created Generic Excel Report can be selected on the HRP Report Selection page for a specific document type. This allows the report to be generated from the corresponding source. For example, a Generic Excel Report can be created for a Vacation order, along with an Excel template, a data template, and the configured generic report. After that, the report 72835670 can be specified on the HRP Report Selection page for the Vacation Order, and the required layout can be selected. When printing from the vacation order, it will then be possible to generate this report in Excel according to the configured Generic Excel Report template.

6. Building a Report from Several Companies​

A report can collect data from several companies of the same environment into one workbook. The data template needs no change at all: the report calculates it once per company, and every table of the template is read in that company.

To set it up:

  1. On the Generic Excel Report card, set Multi-Company to Yes.
  2. Choose Company Selection — ask every time, all companies, or a stored company filter.
  3. For a company column, add a variable over the Company Information table to the data template and a mapping code that reads its Name field, then map that mapping code to the cell as usual. Company Information holds one record per company, so the engine reads the right one in each company - the column needs no special setting in the report.
  4. Set Print Once on the sections that belong to the workbook rather than to a company, such as a title, a column header or a footer. A Print Once section placed after the last per-company section is a footer: it is written once, after the last company, with the values of the last company that could be read. The report does not add the companies together; for a total across companies use an Excel formula in the template.

The report then writes its sections once per company, in the order the companies are selected. That gives both shapes of a multi-company report with the same configuration:

  • A line per company — use non-repeating sections whose values are aggregations (Sum, Count, Average) of the data template. Each company produces one line, because each calculation sees one company.
  • The detail rows of every company — use repeating sections. The rows of all companies follow each other in one table, and the company column tells them apart. A section placed before them acts as a company header.

What to keep in mind​

  • Filters are literal in every company. A filter that names an account number, a dimension value or a customer number finds nothing in a company that does not use that value. The same is true of the filters entered on the filter page when the report runs.
  • Permissions are yours, per company. A company you may not read is skipped (or stops the report, depending on On Company Error). The skipped companies and the reason for each are shown in a message after the export — a shorter report is never silent.
  • A company without the main data item record is skipped in the same way.
  • The report costs one full calculation per company. For more than a handful of companies, run it from a job queue rather than from the page.

7. Moving a Report to Another Database​

A finished report is three things: the Excel template, the data template that resolves the values, and the configuration that maps one to the other. The Export Report Package and Import Report Package actions on the Generic Excel Report page move all three as a single .json file, so a report built once can be delivered to another environment without retyping anything.

Export Report Package writes the file. It contains the report with its sections and mappings, the Excel workbook itself, the sheets, sections and named cells that were read out of it, and the whole data template.

Import Report Package reads it back. Nothing is written until the file has been checked, and whatever is wrong with it is shown in a list first:

FindingMeaning
PKG-KINDThe file is not a report package. Choose the file that Export Report Package produced.
PKG-ROOT-TABLEThe main data item table does not exist here. The extension that owns it is probably not installed.
PKG-REPORT-EXISTSA report with that code is already here and replacement was not confirmed.
PKG-CELL-MISSINGA mapping points at an Excel cell that will not exist after the import.
PKG-TEMPL-KEPT / PKG-TEMPL-REPLACEDWhat happened to an Excel template that was already here.
PKG-COMPANY-FILTERThe company filter in the file matches no company here — correct it after the import.
IMP-…A finding about the data template inside the package, reported by SMART Data Template.

What to keep in mind​

  • The import needs no internet connection to the Excel service. Importing an .xlsx normally sends it away to be analysed; a package already carries the result of that analysis, so it can be imported on an environment where the Excel Report Builder service was never set up.
  • An Excel template that is already here is kept, not overwritten. Excel templates are shared by every report that names them, so replacing one changes other reports too. You are asked before that happens.
  • Company names are not the same in another database. A Company Filter is carried across as it was written and is reported when it matches nothing — check it after the import.
  • Report Selections are not carried. A report used for printing documents has to be attached to the document again in the target database.
© 2008 - 2026 SMART business