Convert Excel data to JSON Data in SAP UI5

by | Jul 26, 2023 | SAP, UI5, UI5 Integrations

Home » SAP » UI5 » UI5 Integrations » Convert Excel data to JSON Data in SAP UI5


Welcome to our comprehensive guide on ‘Converting Excel Data to JSON Data in SAP UI5.’ This practical approach simplifies the way we manage and interpret large Excel data sets, translating them into compact, easy-to-handle JSON files within the SAP UI5 framework. With this strategy, we aim to improve your data integration processes and quicken application development, allowing for more efficient and streamlined operations. We will learn how to Upload an excel file and convert it into JSON and bind it to the table or any other component.

Excel to JSON in JavaScript

Converting Excel data to JSON format in JavaScript typically involves parsing the Excel file, reading its data, and then transforming it into JSON format. Here is a simple step-by-step process using the ‘xlsx’ library, a popular JavaScript library to read, write and parse various spreadsheet formats.

1. Create an HTML input element of type ‘file’ that accepts Excel files, allowing the user to select an Excel file from their device.

2. Use the FileReader API to read the content of the selected file. The FileReader API is part of the web API and allows you to read file content in JavaScript.

3. Use a library like `xlsx` to parse the Excel data. The parsing process converts the raw file data into a format that the library can work with.

4. Extract a specific worksheet from the workbook. If you’re unsure, you can simply extract the first sheet.

5. Use a function provided by the `xlsx` library to convert the worksheet data into JSON format.

6. At this point, the Excel data has been converted into an array of JavaScript objects (JSON format). You can now use this data in your application.

xlsx.js library

The xlsx.js library is a robust and comprehensive JavaScript library that is designed to simplify the process of parsing and manipulating Excel files within the browser and Node.js. The library provides the capability to read and write various spreadsheet formats such as XLSX, XLSM, XLSB, and ODS.

Convert Excel data to JSON Data in SAP UI5


<!DOCTYPE html>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>My Project Ideas</title>
        <link rel="icon" type="image/x-icon" href=""/>
        <script id="sap-ui-bootstrap"
            data-sap-ui-resourceroots='{"exceltoJson.exceltoJson": "./"}'
        <script src=""></script>
    <body class="sapUiBody">
        <div data-sap-ui-component data-name="exceltoJson.exceltoJson" data-id="container" data-settings='{"id" : "exceltoJson"}'></div>



<mvc:View controllerName="exceltoJson.exceltoJson.controller.Main" xmlns:mvc="sap.ui.core.mvc" displayBlock="true" xmlns="sap.m"
    <Shell id="shell">
        <App id="app">
                <Page id="page" title="My Project Ideas: Converting Excel data to JSON Data in UI5">
                        <u:FileUploader id="fileUploader" change="onFileUpload"/>
                        <TextArea id="textArea" rows="10" width="100%" editable="false"/>



], function (Controller) {
    "use strict";
    return Controller.extend("exceltoJson.exceltoJson.controller.Main", {
        onInit: function () {
        onFileUpload: function (event) {
            var that = this;
            var file = event.getParameter("files")[0];
            var reader = new FileReader();
            reader.onload = function (e) {
                var data = new Uint8Array(;
                var workbook =, {
                    type: 'array'
                // Extract data from the first sheet
                var worksheet = workbook.Sheets[workbook.SheetNames[0]];
                var jsonData = XLSX.utils.sheet_to_json(worksheet);
                // Use the jsonData as desired (e.g., display in a table, perform operations, etc.)




1 Comment

  1. Sonali

    very helpful blog..Can you please provide an example of setting the data to table as well


Submit a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.