'How to read excel file in javascript with protractor?

I need to read excel file in Javascript dynamically. want to iterate cell values using row counts and column count. Is it possible to do so? without converting it into JSON object. However, I revisited many posts in order to resolve the issue @ stackoverflow. but not succeeded.Please suggest some satisfactory solution.

thanks you



Solution 1:[1]

There's a npm package which would perfectly match with your requirements : xlsx. If you need exemple of code, feel free to ask, I often use it

Here is a basic exemple of parsing a xlsx file : I read the value of the cell 'B1' of the first sheet of the file test.xlsx

'use strict';
var XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
var sheetName = workbook.SheetNames[0];
var worksheet = workbook.Sheets[sheetName];
var redValue = worksheet['B1'];
console.log(redValue); 

Solution 2:[2]

I found one solution for reading excel use 'kexcel' npm package.I can do my work with it.But I am stuck at point,how can we get last row number from excel using it.

Solution 3:[3]

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

Solution 4:[4]

Swagger codegen is its own separate open-source project. After quickly looking at the GitHub page, it looks like the standalone project DOES cover C++. The options are as follows:

Server stubs: C++ cpprest, C++ Qt5, C++ Tizen

Client SDKs: C++ Pistache, C++ Restbed

It is also entirely possible to build your own Swagger codegen template. Folks who can't find an existing template that works for them will often create their own template. You can find more information on creating templates here: https://github.com/swagger-api/swagger-codegen/wiki/Building-your-own-Templates

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Pankaj
Solution 3 sarath
Solution 4 alex.bonstrom