Skip to main content
OutSystems

How to customize the export to Excel

How can I customize the name and order of columns/Attributes when exporting to an Excel file?

For example: I want to export a list of receipts to an Excel file. The original list of receipts (ReciptTable.List) is fed by the following Aggregate:

Aggregate

I want my Excel file to have "Store" (originally "Name"), "Date and Time" (originally "DateTime"), "Customer" (originally "ClientName") and "Order Total" (originally "Total") columns.

Answer

To customize the name and order of columns/Attributes when exporting a List to an Excel file follow these steps:

  1. Create a Structure (ReceiptsExport) and add the following Attributes:

    • Store: set the Data Type to Text.
    • DateandTime: set the Label to Date and Time and the Data Type to Date Time.
    • Customer: set the Data Type to Text.
    • OrderTotal: set the Label to Order Total and the Data Type to Decimal.

    This Structure defines the final labels and order of the columns in the Excel file.

  2. Create an ExportToExcel Action and add a ListToExport Local Variable and set the Data Type to ReceiptsExport List by selecting Other>List... and then ReceiptsExport.

  3. Add an Assign node with the assignment ListToExport = ReceiptTable.List and set the Mapping to ReceiptsExport as:

    • Store : Name
    • DateandTime : DateTime
    • Customer : ClientName
    • OrderTotal : Total

    This defines the relation between the original List Attributes and the Structure Attributes.

  4. After the Assign node add a Record List To Excel Widget, set the source Record List as the ListToExport Structure and in Attribute Selection tick the (All Attributes) check box.

  5. Replace the End node with a Download node and define the following properties:

    • File Content : RecordListToExcel1
    • File Name : "Receipts.xlsx"
    • Mime-Type : "application/x-msexcel"

After these steps, calling the ExportToExcel Action will generate an Excel file with the desired column names and order:

Excel File

  • Was this article helpful?