-1

I am writing Protractor e2e testing .I need to Dynamically read the values from Excel .Can anyone help me out from this..

Noor
  • 9
  • 5
  • 4
    possible duplicate of [How to read/write from/to an excel using NodeJS - Protractor?](http://stackoverflow.com/questions/26616522/how-to-read-write-from-to-an-excel-using-nodejs-protractor) – alecxe Sep 16 '15 at 16:56
  • 1
    Also do take a look at [xlsjs npm module](https://www.npmjs.com/package/xlsjs). It works well too. – giri-sh Sep 16 '15 at 17:47

1 Answers1

0

Inititally add xlsjs to node, and then try this code

var sheetNumber = 0;
    //Define file Path name
    var path = require('path');
    var fileNamePath = path.resolve(__dirname, 'E:/excel.xls');
    //NodeJs read file
    var XLS;
    if (typeof require !== 'undefined') {
        XLS = require('E:/node/node_modules/xlsjs');
    }
    //Working with workbook
    var workbook = XLS.readFile(fileNamePath);
    var sheetNamelist = workbook.SheetNames;
    var value = workbook.Sheets[sheetNamelist[sheetNumber]][cellId].v;

In the above sheet number means, in the Excel sheet your data is located in which sheet and cellId is in that sheet which shell data do you want. your data was stored in the variable value, you can use that data in any type.

rajana sekhar
  • 511
  • 5
  • 21