Excel to JSON Operator

Prev Next

The Excel to JSON operator reads the contents of an Excel file and parses them into JSON. This operator is useful for using your Excel data in Unqork. You can also upload Excel files from a single tab or multiple tabs using this operator. This operator uses the Base64 of an Excel file (xlsx, CSV, XML) and converts the data into two attributes: headings and JSON. Headings are the header fields of the file (the labels of your columns). The JSON includes the actual contents of your file, where each row has an index. And in each index, you'll see a key/value pair for each data point. If a cell is empty, you'll see a null value for that key.

Here's an example of how this might look in the DevTools Console:

For the Excel to JSON operator to work, you must input the Base64 of your Excel file because the operator cannot read your entire Excel file. If you’re using a File component, you'll use a Get operator to retrieve the Base64 of the uploaded file. If you don't use a Base64 input, you'll receive a circular reference error. Similarly, when using a File component, the component’s Parse Files on Upload setting must be set to (ON). If the setting is set to (OFF), you'll receive a circular reference error.

You’ll find the Excel to JSON operator under the Value/String group to the left of the Data Workflow canvas.

About the Info Window

Here's a breakdown of each setting in the Info window:

Setting

Description

Category

Grayed out and non-adjustable setting indicating the operation type.

Label

Sets the label for your operator, displaying below the operator on your Data Workflow canvas.

This field is optional, but set a label if you use more than one of the same operator type. A label helps you identify your operators without opening any Info windows.

Preserve Argument Type

When selected, this setting ensures the argument data type is respected when the operator executes.

multiTabExcel

Tells the operator if the Excel file has a single tab or multiple tabs. When set to Yes, the operator creates a separate array for each tab in the file. The name or key of each array will be the name of the original Excel tab.  

Delimiter

Specify a delimiter to use to separate your values. For example, a space ( ), comma (,), ampersand (&), or even a combination of characters. If you don’t set a delimiter, the function concatenates all values without a delimiter. You must surround the delimiter in quotation marks. If you use a number as a string delimiter, the Calculator treats the number as text.

Adding an Excel to JSON Operator

In this example, you’ll import a list of application IDs into your module. You have these IDs in an Excel file, and you can use the Excel to JSON operator to convert the data.

To complete this example, you'll need a sample Excel file to upload. This configuration can accept any single-tab Excel file you have on hand. The end result you see in the DevTools Console varies depending on the data you upload.

These instructions assume you have a new module open, saved, and with a title.

Configure the File Component

Begin by adding a File component to handle the file upload.

  1. In the Module Builder, drag and drop a File component onto your canvas.

  2. In the Property ID field, enter fileUpload.

  3. In the Label Text field, enter Single Tab Excel Upload.

  4. Click Save Component.

Configure the Data Workflow Component

Next, configure the Data Workflow component. Here, you'll include an Input operator to bring the data from your File component into the Data Workflow. You'll also use a Get operator to retrieve the Base64 of your Excel file because the Excel to JSON operator cannot accept the Excel file. From there, you'll pass that data to the Excel to JSON operator and to a Console operator to view the output in the DevTools Console.

  1. Drag and drop a Data Workflow component onto your canvas, placing it below your fileUpload File component.

  2. In the Property ID and Canvas Label Text fields, enter dwfExcelToJSON.

Configure the Input Operator

  1. Drag and drop an Input operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Input

    Component

    fileUpload

    Required

    Yes

    Source

    Default

Configure the Get Operator

  1. Drag and drop a Get operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Get

    Label

    [0].data

    Path

    [0].data

  3. Connect the output port (right) of the fileUpload Input operator to the input port (left) of the [0].data Get operator.

Configure the Excel to JSON Operator

  1. Drag and drop an Excel to JSON operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Excel to JSON

    Label

    Single Tab

    mutliTabExcel

    No

  3. Connect the output port (right) of the [0].data Get operator to the input port (left) of the Single Tab Excel to JSON operator.

Configure the Console Operator

  1. Drag and drop a Console operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Console

    Label

    Output

  3. Connect the output port (right) of the Single Tab Excel to JSON operator to the input port (left) of the Output Console operator.

  4. Click Save Component.

Configure the Button Component

Lastly, configure a Button component to trigger your Data Workflow.

  1. Drag and drop a Button component onto your canvas, placing it between your fileUpload File and dwfExcelToJSON Data Workflow components.

  2. In the Property ID field, enter  btnExcelToJSON.

  3. In the Label Text field, enter Single Tab Excel to JSON.

  4. From the Action Type drop-down, select Event.

  5. From the Triggers On Click drop-down, select dwfExcelToJSON .

  6. Click Save Component.

  7. Save your module.

Here's how the completed example looks in the Module Builder:

Preview your module in Express View and upload a single-tab Excel file. Open the DevTools Console and click the Single Tab Excel to JSON button. You'll see a new JSON populated with the data from your Excel file. In the example below, you'll see data pulled from an Excel file with a single column labeled applicationId.

Different results occur depending on what data is in your Excel file. Try uploading different types of Excel data to understand the output. From there, you can change settings in your Data Workflow to get the output you want. Once you have the JSON data you need, you can pass it into another process.

The Excel to JSON operator reads the contents of an Excel file and parses them into JSON. This operator is useful for using your Excel data in Unqork. You can also upload Excel files from a single tab or multiple tabs using this operator. This operator uses the Base64 of an Excel file (xlsx, CSV, XML) and converts the data into two attributes: headings and JSON. Headings are the header fields of the file (the labels of your columns). The JSON includes the actual contents of your file, where each row has an index. And in each index, you'll see a key/value pair for each data point. If a cell is empty, you'll see a null value for that key.

Here's an example of how this might look in the DevTools Console:

For the Excel to JSON operator to work, you must input the Base64 of your Excel file because the operator cannot read your entire Excel file. If you’re using a File component, you'll use a Get operator to retrieve the Base64 of the uploaded file. If you don't use a Base64 input, you'll receive a circular reference error. Similarly, when using a File component, the component’s Parse Files on Upload setting must be set to (ON). If the setting is set to (OFF), you'll receive a circular reference error.

You’ll find the Excel to JSON operator under the Value/String group to the left of the Data Workflow canvas.

About the Info Window

Here's a breakdown of each setting in the Info window:

Setting

Description

Category

Grayed out and non-adjustable setting indicating the operation type.

Label

Sets the label for your operator, displaying below the operator on your Data Workflow canvas.

This field is optional, but set a label if you use more than one of the same operator type. A label helps you identify your operators without opening any Info windows.

Preserve Argument Type

When selected, this setting ensures the argument data type is respected when the operator executes.

multiTabExcel

Tells the operator if the Excel file has a single tab or multiple tabs. When set to Yes, the operator creates a separate array for each tab in the file. The name or key of each array will be the name of the original Excel tab.  

Delimiter

Specify a delimiter to use to separate your values. For example, a space ( ), comma (,), ampersand (&), or even a combination of characters. If you don’t set a delimiter, the function concatenates all values without a delimiter. You must surround the delimiter in quotation marks. If you use a number as a string delimiter, the Calculator treats the number as text.

Adding an Excel to JSON Operator

In this example, you’ll import a list of application IDs into your module. You have these IDs in an Excel file, and you can use the Excel to JSON operator to convert the data.

To complete this example, you'll need a sample Excel file to upload. This configuration can accept any single-tab Excel file you have on hand. The end result you see in the DevTools Console varies depending on the data you upload.

These instructions assume you have a new module open, saved, and with a title.

Configure the File Component

Begin by adding a File component to handle the file upload.

  1. In the Module Builder, drag and drop a File component onto your canvas.

  2. In the Property ID field, enter fileUpload.

  3. In the Label Text field, enter Single Tab Excel Upload.

  4. Click Save.

Configure the Data Workflow Component

Next, configure the Data Workflow component. Here, you'll include an Input operator to bring the data from your File component into the Data Workflow. You'll also use a Get operator to retrieve the Base64 of your Excel file because the Excel to JSON operator cannot accept the Excel file. From there, you'll pass that data to the Excel to JSON operator and to a Console operator to view the output in the DevTools Console.

  1. Drag and drop a Data Workflow component onto your canvas, placing it below your fileUpload File component.

  2. In the Canvas Label Text and Property Name fields, enter dwfExcelToJSON.

Configure the Input Operator

  1. Drag and drop an Input operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Input

    Component

    fileUpload

    Required

    Yes

    Source

    Default

Configure the Get Operator

  1. Drag and drop a Get operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Get

    Label

    [0].data

    Path

    [0].data

  3. Connect the output port (right) of the fileUpload Input operator to the input port (left) of the [0].data Get operator.

Configure the Excel to JSON Operator

  1. Drag and drop an Excel to JSON operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Excel to JSON

    Label

    Single Tab

    mutliTabExcel

    No

  3. Connect the output port (right) of the [0].data Get operator to the input port (left) of the Single Tab Excel to JSON operator.

Configure the Console Operator

  1. Drag and drop a Console operator onto your Data Workflow canvas.

  2. Configure the operator's Info window as follows:

    Setting

    Value

    Category

    Console

    Label

    Output

  3. Connect the output port (right) of the Single Tab Excel to JSON  operator to the input port (left) of the Output Console operator.

  4. Click Save.

Configure the Button Component

Lastly, configure a Button component to trigger your Data Workflow.

  1. Drag and drop a Button component onto your canvas, placing it between your fileUpload File and dwfExcelToJSON Data Workflow components.

  2. In the Property ID field, enter  btnExcelToJSON.

  3. In the Label Text field, enter Single Tab Excel to JSON.

  4. Under Action Type, select Event.

  5. In the Triggers On Click field, enter dwfExcelToJSON .

  6. Click Save & Close.

  7. Save your module.

Here's how the completed example looks in the Module Builder:

Preview your module in Express View and upload a single-tab Excel file. Open the DevTools Console and click the Single Tab Excel to JSON button. You'll see a new JSON populated with the data from your Excel file. In the example below, you'll see data pulled from an Excel file with a single column labeled applicationId.

Different results occur depending on what data is in your Excel file. Try uploading different types of Excel data to understand the output. From there, you can change settings in your Data Workflow to get the output you want. Once you have the JSON data you need, you can pass it into another process.