Skip to Content
Technical Articles

Read Data From Excel File (.XLSX) In SAP UI5 App And Display Contents In Table


Hello everyone. Hope you all are fine in this pandemic. Today, i am writing this blogpost to highlight the steps that can be used to read the data from an Excel file. It is easy to read the data from a csv file but reading data from XLSX file is somewhat different and require external libraries.

We would be using the SheetJS library to read the file and display the content in the sap.m.Table.

The Github repo of the SheetJS is here.


Firstly, we will create a simple project with a single view. I have created the Project with name ReadFromExcel and namespace com.test.

Now i am adding a file uploader and sap.m.Table in my view. Following is the code:

<mvc:View controllerName="com.test.ReadFromExcel.controller.MainView" xmlns:mvc="sap.ui.core.mvc" displayBlock="true" xmlns="sap.m"
	<Shell id="shell">
		<App id="app">
				<Page id="page" title="Read From Excel">
								<Label text="Read Data From Excel"/>
								<u:FileUploader id="FileUploaderId" sameFilenameAllowed="true" iconOnly="false" buttonOnly="true" fileType="XLSX,xlsx"
									icon="sap-icon://upload" iconFirst="true" style="Emphasized" change="onUpload"/>
						<Table items="{localModel>/items}">
									<Label text="Name"/>
									<Label text="Age"/>
									<Label text="Job"/>
									<Label text="Address"/>
										<Text text="{localModel>Name}"/>
										<Text text="{localModel>Age}"/>
										<Text text="{localModel>Job}"/>
										<Text text="{localModel>Address}"/>

The Output of the page looks like this:

As per the code, i have registered the change event of FileUploader as onUpload which will trigger when the file is selected.

Also we need a JSON model to store the data of the excel and display in the sap.m.Table. I am creating the JSON model as localModel.

Below is the code for controller file:

	onInit: function () {
			this.localModel = new sap.ui.model.json.JSONModel();
			this.getView().setModel(this.localModel, "localModel");
		onUpload: function (e) {
			this._import(e.getParameter("files") && e.getParameter("files")[0]);

		_import: function (file) {
			var that = this;
			var excelData = {};
			if (file && window.FileReader) {
				var reader = new FileReader();
				reader.onload = function (e) {
					var data =;
					var workbook =, {
						type: 'binary'
					workbook.SheetNames.forEach(function (sheetName) {
						// Here is your object for every sheet in workbook
						excelData = XLSX.utils.sheet_to_row_object_array(workbook.Sheets[sheetName]);

					// Setting the data to the local model 
						items: excelData
				reader.onerror = function (ex) {


But to make this run, we need to add the JS files of the SheetJS which i am picking from the CDN of the same and have linked in index.html file:

<!DOCTYPE html>
		<script src=""></script>
		<script src=""></script>
	<body class="sapUiBody">

We need to use two files here. JSZIP.js and XLSX.js as clearly visible above.

Now we will run the application and use the file uploader to show the contents in sap.m.Table

Select the file:

After selection data is shown in the sap.m.Table:

The contents of the file are:



There are times where we need to read the data from XLSX file in the SAPUI5 application. You can follow the above steps for the same.


Suggestions and Questions are most welcome.


Anmol Chadha

You must be Logged on to comment or reply to a post.
    • Hi,


      Below is the code:


      <!DOCTYPE html>
      		<script src=""></script>
      		<script src=""></script>
      		<meta charset="utf-8">
      	    <meta name="viewport" content="width=device-width, initial-scale=1.0">
      		<script id="sap-ui-bootstrap"
      			data-sap-ui-resourceroots='{"com.test.ReadFromExcel": "./"}'
      	<body class="sapUiBody">
      		<div data-sap-ui-component data-name="com.test.ReadFromExcel" data-id="container" data-settings='{"id" : "ReadFromExcel"}'></div>
  • /
  • Hi Anmol,

    Thanks for blog.

    I tried uploading the excel file into SAPUI5 table. Excel file is having 26 columns and it has 2 rows of data. When i tried getting JSON data from Excel, in the ExcelData array, if any of the row cell is empty that header data also not coming in the JSON data. In the Excel sheet Account Holder field is empty due to that i am not getting Account Holder parameter itself for excelData[1]. Could you please let me know how to get the parameter if it does not have any values also.


    Manimaran R.

    • Hi


      For this, if you have a fixed set of columns, you can use a JSON object with all the fields and map and check with data received from excel.