title | category | tags |
---|---|---|
Using the Excel Exporter |
Integration |
Each application can export items to Excel format from a Data Grid as standard functionality in the platform (add an Export to Excel button on a Data Grid). However, in instances where more customized Excel documents are required, applications can leverage Mendix App Store content to create custom Excel documents based off of configurable templates. To achieve this, the app will require two Mendix App Store modules and the subsequent configuration of the documents.
In this part of the how to you will learn how to download the necessary modules from the Mendix App Store. This is a very quick process, in that in just a few clicks the modules will be imported into your project. The modules that are required for this process are 'MxModelReflection' and 'Excel Exporter'.
{{% alert type="info" %}}
The MxModelReflection module is a commonly used module in most apps. The purpose of this module is to allow the app to reflect into the domain model (entities and attributes) and microflow definitions at runtime.
{{% /alert %}}
- Open the Mendix App Store from within the modeler.
- Search for the keyword Reflection.
- Click the Download button and include the module as a new module.
- Ensure the module has downloaded successfully and is now a new module in your project.
- Open the Mendix App Store from within the modeler.
- Search for the keyword Excel.
- Click the Download button and include the module as a new module.
Ensure the module has downloaded successfully and is now a new module in your project.
{{% alert type="warning" %}}
Depending on the layout selected when the project was created, errors in the modeler may arise due to the new module's default layouts. To correct this, open each page that has an error and update the layout to the desired layout within the app.
{{% /alert %}}
In this part of the how to you will learn how to add the required pages into the Project Navigation that are needed to configure both the Mx Model Reflection and the Excel Export templates that will be used within the application.
- Open Navigation within the project.
- Add a new item to the Navigation for Administrator to access MxModelReflection.MxObjects_Overview.
- Add a new item to the Navigation for Administrator to access XLSReport.Excel_Document_Overview.
In this part of the how to you will learn how to run the MxModelReflection synchronization and so the app can leverage the output from that process to create the highly customizable Excel Export templates.
- Open the MxModelReflection overview page via the Navigation item configured to MxModelReflection.MxObjects_Overview.
- Highlight each module the app needs to synchronize and click the Toggle Module Sync button (the Sync this Module should now be 'Yes').
- Click the Synchronize Objects button to execute the synchronization process.
In this part of the how to you will learn how to create a basic Excel Export template within your app. This section will cover an overview of the various configuration items to enable you to start building the desired templates.
{{% alert type="info" %}}
This module has many moving pieces that allow the configurations to be as simple or complex as the user desires. This tutorial will go over the basics to get you started, but building the desired template will take a varying degree of configuration options.
{{% /alert %}}
- Open the Domain Model and add an Entity to serve as a "Master Export" entity that is of specialization FileDocument.
- Create an association between the newly created entity and the entity(ies) that you will want to serve as a base for the Excel Export.
-
Open the Excel Exporter Overview via the Navigation item configured to XLSReport.Excel_Document_Overview.
-
Click the New button to create a new template.
-
Configure the Filename (without extension) to be the default file name when the template is used.
{{% alert type="info" %}}
The file name can always be changed when the template is used within a microflow.
{{% /alert %}}
-
Configure the Input Object to be the file document entity that is associated to your entity to be exported.
-
Provide a Description for identifying and documenting what this exact template is used for.
-
Specify the Date time export format for how the dates and times should appear in the Excel file once exported.
-
Under the Worksheets section, select New to create a new sheet template.
-
Specify the Name that will be given to the sheet when the file is exported.
-
Configure the Row Object that you want to export and set the reference to the template input object (if input object is used).
-
Configure the Start retrieved data at row to set the ordinal number in which the data should be exported.
{{% alert type="info" %}}
This setting will possibly trim the result set being exported, as the export will go from this value to the end of the list of data
{{% /alert %}}
-
Select if the export should export distinct only or allow duplicate data
-
Specify the Column and Row Settings for height and width, or leave as default
-
Specify if the extract will Use Static Data or not.
{{% alert type="info" %}}
If static data is used, that will be configured in Section 4.6.
{{% /alert %}}
-
Specify if the Default text style that will denote the pre-defined style to be applied to the exported data.
-
Specify if the Default header text style that will denote the pre-defined style to be applied to the header data.
{{% alert type="info" %}}
Specifying styles are addressed in Section 4.5.
{{% /alert %}}
-
Open the Column Data tab and select New to create a new export column
-
The Column number will be set automatically, but can be overwritten to the desired ordinal number.
-
Define a Name for the column and specify if that Name should be the Column Header as well when exported.
-
Specify the Retrieve type to identify if this column will be an attribute or a reference.
-
Specify the Select attribute to identify the exact attribute on the row entity in which this column corresponds to.
-
Specify if the column should result in an aggregate.
{{% alert type="info" %}}
Only types of Decimal, Integer, and Long can be aggregated
{{% /alert %}}
- Open the Static Data tab and select New to create a new export column.
- Specify the Row and Column that the static value should be placed.
- Enter a name for the cell in the Name field.
- Specify the Type by denoting if the cell is Static Text, Object Data, or Aggregate Function.
- Specify the Style that should be applied to the cell.
- Specify the Text if the field Type is listed as Static Text.
- Open the main NewEdit page for the Excel Export Template and find the Styles section
- Select New to create a new style that can be applied to any of the data in the Excel Export.
- Specify the properties of the style that will be applied to the cells.
- Upon Save the style will now be available to be used for dynamic columns, static columns, and headers.
In this section you will learn how to call the newly created Excel Export template in your application.
{{% alert type="info" %}}
This module has many steps that must be configured in order for the template to be used correctly. Please review all steps.
{{% /alert %}}