Import a Large Excel File

Last modified: April 18, 2024

1 Introduction

Use XML-to-domain mapping to create a new import entity from an Excel sheet in a quick, semi-automated way.

This how-to teaches you how to do the following:

  • Import a large Excel file with a lot of columns

2 Prerequisites

Before starting this how-to, make sure you have completed the following prerequisite:

3 Modifying Your Excel Sheet

The Excel sheet you receive in this scenario contains almost every country in the world, as well as some supporting data. This data has to be imported into your application.

You can find the Excel sheet here: Countries.

You are going to make an XSD schema from the headers in the Excel sheet so you can import the data into the model.

To modify your Excel sheet, follow these steps:

  1. Select the header row with all the country names.

  2. Copy and paste them in a new sheet using the transpose function:

    Your headers should be listed vertically and your sheet should look like this: Countries Transposed.

    You are now ready to add some tags around the column.

  3. Add one column to the left.

  4. Place the following string in cell A1:

    <xs:element type="xs:string" name="
    
  5. Drag the string all the way down to the last country.

  6. In cell C1, enter the following string:

    "/>
    
  7. Like you did with the previous string, drag it down to the last country. The Excel sheet should now look like this: Countries with Tags.

    Now, group the three different columns into one column. This is necessary to copy the whole column into an XSD file.

  8. Select cell D1 and type in the following into the formula box:

    =(A1&B1&C1)
    
  9. Drag the cells down like you’ve done with column A1 and C1. Now, column D should have columns A, B, and C combined into one, and your sheet should look like this: Countries with Tags and Column D.

4 Preparing Your XSD File

You have used some of Excel’s basic functionalities to create the first part of the XSD structure. For a proper XSD file, it needs a header and a footer. To prepare your XSD file, follow these steps:

  1. Open a new file and name it CountriesImport.xsd.

  2. Place the following text as the header of your XSD file:

    1
    2
    3
    4
    5
    
    <?xml version="1.0"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified">
    <xs:element name="CountriesImport">
    <xs:complexType>
    <xs:sequence>
    
  3. Go back to your sheet, copy the content from column D, and paste it underneath the header.

  4. Place the following text as the footer:

    1
    2
    3
    4
    
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:schema>
    

    Your file should look like this: Country Import.

  5. Click Save.

5 Importing into Your Application Project

The XSD file is ready to be imported into your app. To import it, follow these steps:

  1. Open your app and create a new XSD schema:

  2. With the new XSD schema, create the XML-to-domain mapping. Do this by right-clicking the module > Add other > Import mapping.

  3. Check all the attributes listed. After clicking OK, you see a mapping entity with all your countries.

  4. You will now generate a real entity from it that you can use as an import table for your Excel sheet. Click Map automatically:

    There’s your entity!

  5. Go to your domain model and set the entity’s Persistable property to Yes.

The data is imported to the page, as seen in the image below:

To keep your application clean, you can delete the XSD schema and XML-to-domain files from your app.

A video demonstrating this technique can be viewed below: