Analysis and Application of Mendix Excel Import Component

I. Introduction

Enterprises will use various systems in the process of development, many of which have been used for 5-10 years. We call them legacy systems. There are many risks: time-consuming maintenance, frequent interruptions, unfriendly users, and new software. Compatibility issues, etc. One day, these massive problems will monopolize IT resources and complicate the digital transformation process. At the same time, we also found that the processes and business scenarios of many enterprises still use various office tools offline and have not been implemented in the system.

There is now a shortcut to solving the legacy of modernization. Low-code is a visual development methodology that helps organizations build custom applications to complement or replace legacy systems. Low-code platforms fast-track development by providing an environment where people of all coding skill levels can build business-critical applications that can scale and grow with an organization. Replacing legacy systems or migrating offline processes and scenarios to online can be called application modernization. Realizing application modernization for enterprises is a long-term and long-term task. In the future, we will publish articles about application modernization one after another to see how to help enterprises realize application modernization.

Back to our topic today, first of all, please think about a question, what is the most used tool in the daily work of enterprise employees? That's right, Excel. In daily work, Excel is indeed indispensable and is very suitable in many scenarios, but the excessive use of Excel can also cause various problems.

2. Demand analysis

First, let's take a look at the following two project requirements:

1. For an auto parts factory, the Planner will use Excel to fill in the forecast quantity for the whole year based on the materials that the individual is responsible for every week. Fill in the report on a monthly basis, fill in the sales forecast quantity, the factory's expected production quantity, and the factory The number of expected shipments, the number of financial audits. After the completion of the report, the price will be calculated according to the unit price and exchange rate of the material. At the same time, different product lines will be included according to different BUs. Different product lines will include different groups, and different groups will include different personnel and materials. According to this hierarchical relationship, Calculate the BU, product line, and the price of the materials that the Group is responsible for. At the same time, it will be compared with the data of last week and last week. If there is a large gap between the data of a certain month and the previous week or last week, you need to Report an exception and remind Planner to make a note.

At the same time, the management hopes to be able to flexibly view the data related to each BU, product line, and Group at any time.

Administrators also need to regularly export basic data from SAP, such as organizational structure relationships, cost data, exchange rates, and other data that need to be used for subsequent calculations. These exported data are all in the form of Excel.

2. In an electronics manufacturer, factory employees need to use Excel to report working hours every day. After completing the reporting, upload the working hours. No matter how much data is filled in, it is only created based on the last row of data, and the created data will go to SAP to check whether it matches. If it does not match, then The feedback needs to modify the data. If it matches, update the data. When updating the data, first check whether there is existing data based on the product number. If not, create new data. If there is, update the data, and bind the uploaded Excel to the current data. Other old Excels are kept on the server.

The report checks the man-hour data of different product numbers, and the displayed man-hour data is the latest data, and at the same time displays the latest uploaded related Excel, which can be downloaded with one click.

From the requirements of the above two projects, we can see that there are many similarities. First of all, the working style of ordinary employees has not changed. Whether it is a planner or a factory employee, they will still fill in the data through Excel, but after filling in the data, there will be a lot. Calculations and logic need to be processed. If we still use Excel to do it at this time, we can see that in Case1, the data of multiple Excel tables is required for combined calculations, which is very error-prone. Secondly, the calculation of the data is required every week, and the workload It is very large, and it is not easy to version management. When a calculation error is found, it is also very difficult to trace. It should be noted that there will not be a lot of planners and factory employees to fill in the data, and then use Excel to realize the following business scenarios. This kind of manpower consumption is huge.

Secondly, both projects have the need for the management to view the reports, and the management hopes to view the data they want to see through various terminals anytime and anywhere, which cannot be satisfied through Excel.

Now these two requirements can be realized very quickly through Mendix. The whole process of realization is beyond the scope of our discussion this time. This time we will focus on how to import components through Excel to perfectly migrate the offline process to the online one.

3. Excel import component

Component download

Enter Excel search in Mendix Marketplace, and find the Excel importer component download

Find the Model Reflection  component download, in order to configure the mapping between Excel columns and domain models

 Locate the Community Commons Function Library component installation to ensure that BigDecimal values ​​can be imported

After downloading these modules, they can be found under the Marketplace module.

After importing the module, configure the Templates_Overview or ExcelImporter.ExcelImportOverview page to the navigation bar. This is the starting point for defining the Excel mapping.

Before we officially start, let's understand the various definitions of the Excel template, which will help us to configure it according to different business scenarios. https://docs.mendix.com/appstore/modules/excel-importer/#413-header-row-nr

Let's start how to import an Excel

Import Excel document

1 Introduction

Adding large amounts of data to an application (for example, reference data or data from external applications) can be time-consuming. To save time and effort, this can be achieved using the Excel import component. In this how-to, import settings into a template and use this module to import data into an application.

2 Prerequisites

Before starting this how-to, make sure you know how to:

3 Prepare data structures, GUI and modules

Before you start importing data into your application, you first need to set up the data structure and GUI by following these steps:

1. Create the following domain model:

Create an enumeration for the OrderStatus property with values ​​Open  ,  Processing , and Complete  .

Configure the XLSFile object to inherit from the FileDocument object.

2. Create overview and detail pages to manage objects of type Customer and Order .

3. Create menu items to access the order and customer overview pages.

4. Create menu items for the ExcelImportOverview and MxObjects_Overview pages (these pages already exist in the _USE_ME folder of the downloaded module).

5. Configure the Administrator user role to have the Configurator module role of the ExcelImporter module , and the ModelAdministrator module role of the Mx model reflection module.

4 Prepare the logic for data import

Because the enumeration is used for the OrderStatus property, you need to create a microflow to determine the property's enumeration value based on the input from the Excel file. If the imported data is not enumerated, this step can be ignored.

1. Create the following microflow and name it IVK_ParseStatus .

2. Set the return value as follows:

if $Unformatted = 'open' then MyFirstModule.OrderStatus.Open

else if $Unformatted = 'processing' then MyFirstModule.OrderStatus.Processing

else if $Unformatted = 'complete' then MyFirstModule.OrderStatus.Complete

else MyFirstModule.OrderStatus.Complete

3. Save the microflow.

5 Using application model metadata on the client side

In order to set up an import template for importing data, your application model metadata should be reflected on the client side. This can be achieved by using the Mx model reflection module. Follow the steps below to do this:

  1. Click the play button ( run locally ) to start the application.
  2. Click View Application to open your application in a browser.
  3. Log in as an administrator .
  4. Click on the menu item of MxObjects_Overview in the navigation .
  5. Select the module containing the objects to be used in the client by checking the box on the left - in this case MyFirstModule :
  6. Click the button next to Synchronize all entities and microflows of checked modules on the left . The two object and parsing microflows from the MyFirstModule module can now be seen and used on the client side .

6 Manually create import templates

Before data from an Excel file can be imported into the application, an import template must be set up. In this template, configure the object to which the data should be mapped, whether the object is related to another object, from which row in the Excel file the import should start, and which columns should be imported.

Data will be imported from a simple example Excel file that can be downloaded here:

download example

Depending on the structure of the file to be imported, the template needs to be set up manually as follows:

  1. Click the ExcelImportOverview menu item in the app home navigation .
  2. Click New Template :

     3. Name the template.

     4. Click the arrow next to the Mendix object box.

     5. Double-click the customer object:

     6. Click the arrow next to the Reference to Import Object box.

     7. Select the Customer_XLSFile association. Save the XLS file on disk and join the imported data to the source file by setting up an association with the XLS file.

     8. Make sure that the import operation is set to Synchronize Objects :

For this example, a simple Excel file will be used that has only one worksheet and column headings on the first row. If using a more comprehensive Excel file, these values ​​can be changed via the Sheet nr  ,  Header row nr , and Import from row nr fields.

     9. In the Connect Columns to Attributes section, click New to create a mapping from the Excel worksheet columns to the correct Mendix attributes.

     10. Add the column numbers that correspond to the column numbers in the Excel file that you want to map.

The first column in Excel is numbered 0, the second is 1, and so on.

     11. Define the Excel column heading as the Caption value.

12. Select Properties      for Type .

     13. Click the arrow next to the Properties box:

14. Double-click the attribute      to map the Excel value to :

     15. Repeat steps 9 through 14 above for each property of the Customer object.

  • For the mapping of the Name property, set the Key value to Yes to prevent duplicate customers.

 If the mapping is set correctly, a green checkmark will appear in front of the row.

     16. Now you need to create mappings for the Order object properties. However, because the Order object is associated with the Customer object, the mapping setup will be slightly different. Perform the following steps for each property of the Order object:

  1. Add the column numbers that correspond to the column numbers in the Excel file that you want to map.
  2. Define Excel column headings as Caption values.
  3. Select Reference for Type .
  4. Click the arrow next to the reference box, where you can choose the association that links the order to the customer - in this case it should be Order_Customer .
  5. Click the arrow next to the property box, and then double-click the property to which you want to map the Excel value .
  6. For the mapping of the property Number , set the Key value to Yes, only for the associated object , to prevent duplicate orders.
  7. Click Save .

     17. For the mapping of the OrderStatus attribute, the Excel file value needs to be parsed into an enumeration value. To do this, you can use the IVK_ParseStatus microflow (created in the Prepare Data Import Logic section above). Click the arrow next to the Parse with box and select the IVK_ParseStatus microflow:

     18. Save the import template.

6.1 Import Excel file

Now that the template is set up, you can start importing data from the Excel file into your application. You can use the example files downloaded in the Create Import Template section above .

Follow the steps below to import an Excel file:

  1. Click the ExcelImportOverview menu item in the app home navigation .
  2. Go to Import Files tab and click New:

   

     3. Select the template you just created.

     4. Click Browse :

    

     5. Select the sample Excel file you downloaded and click Save .

     6. Click the Excel file under Filename to select it, then click Import file :

     7. Click OK when the import is complete .

In this way, the Excel data import is completed. As for the subsequent logical processing, it can be realized through microflow, which is not within the scope of this introduction.

4. Application display

After completing the configuration of the Excel component, let us see the actual application effect for the previous two customer requirements.

project one

Excel upload template

 Data generated after uploaded by Planner

 Display different BU, product line, and Group data after calculation

Master data imported via Excel

project two

Excel working hours template imported by factory employees

Fill out the form and upload Excel

Final data display

5. References

  1. Excel component Marketplace introduction https://marketplace.mendix.com/link/component/72
  2. MX Model Reflection component MarketPlace introduction https://marketplace.mendix.com/link/component/69
  3. Community Common component introduction https://marketplace.mendix.com/link/component/170
  4. Excel import specific documents refer to https://docs.mendix.com/appstore/modules/excel-importer/#413-header-row-nr  and Import Excel Documents | Mendix Documentation

About Mendix

Mendix, a Siemens business and the global leader in enterprise low-code, is fundamentally reshaping the way digital enterprises build applications. Enterprises can use the Mendix low-code software rapid development platform to expand their own development capabilities and break the bottleneck of software development. With the help of the Mendix development platform, enterprises can create intelligent applications with native experience such as intelligence, initiative and human-computer interaction, modernize core systems and achieve large-scale application development to keep up with the speed of business growth. The Mendix low-code software rapid development platform can promote close cooperation between business and IT teams under the premise of maintaining the highest security, quality and governance standards, greatly shorten the application development cycle, and help enterprises confidently move towards the digital future. Mendix's "Go Make It" platform is used by more than 4,000 leading companies worldwide.

Guess you like

Origin blog.csdn.net/Mendix/article/details/131674904