To read from an excel file you can use 2 different methods,
The first one is using the package xlsx,
Inside the project folder run the command 'npm i xlsx' on the terminal which will install the necessary packages
var XLSX = require('xlsx');
var UserCred = XLSX.readFile('ExcelFile/UserLogin.xlsx');
var UserLoginWorksheet= UserCred.Sheets['Sheet1'];
var BaseUrl=UserLoginWorksheet['B1'].v;
console.log(BaseUrl);
Here 'BaseUrl' holds the value at column B1 in the excel file
The second one is using the package exceljs,
Inside the project folder run the command 'npm i excel' on the terminal which will install the necessary packages.
var Excel = require("exceljs");
var filePath = 'ExcelFiles/StaffDetails.xlsx';
var workbook = new Excel.Workbook();
await workbook.xlsx.readFile(filePath).then(function () {
//Use sheetName in getWorksheet function
worksheet = workbook.getWorksheet("Sheet1");
let cellValue1 = worksheet.getRow(1).getCell(1).value;
console.log(emptyCell1+"4");
})
let cellValue2 = worksheet.getRow(2).getCell(2).value;
Here cellvalue1 holds A1 columns value and cellvalue2 holds B2 column value