Select Page
Automation Testing

Reading Excel File Using JavaScript

In this blog post, you will learn how to read Excel file using JavaScript. exceljs - JavaScript Excel Library reads, manipulates and writes spreadsheet data and styles to XLSX and JSON.

Reading Excel File Using JavaScript
Listen to this blog

In this blog post, you will learn how to read Excel file using JavaScript. exceljs – JavaScript Excel Library reads, manipulates and writes spreadsheet data and styles to XLSX and JSON.

We have used Apache POI, Fillo, JXL, and pyxll Excel Java & Python libraries for automation testing services. However, Reading and manipulating Excel file in JavaScript is very interesting.

Installation

You can install exceljs Excel Workbook Manager with the below npm install command.
`npm install exceljs`

Code

//Read a file
var workbook = new Excel.Workbook();
workbook.xlsx.readFile("data/Sample.xlsx").then(function () {
            
//Get sheet by Name
var worksheet=workbook.getWorksheet('Sheet1');
            
//Get Lastrow
var row = worksheet.lastRow
            
//Update a cell
row.getCell(1).value = 5;

row.commit();

//Save the workbook
return workbook.xlsx.writeFile("data/Sample.xlsx");

});  

You can also read and write CSV file. Refer: Reading CSV and Writing CSV

Comments(0)

Submit a Comment

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

Talk to our Experts

Amazing clients who
trust us


poloatto
ABB
polaris
ooredo
stryker
mobility