0

I am trying to read an excel file from node js, But I am getting succeed, Now am working with below set of code

var xlsx = require('node-xlsx');

var obj = xlsx.parse(__dirname + '/productExcell.xlsx'); // parses a file 

console.log(obj);

The console doesn't print anything for me and also no console executes after parsing statement.

1 Answer 1

1

The node-xlsx module requires the excel module to be installed.

Ensure you have this by running npm install excell.

Also make sure that the file you are trying to parse actually exists at the given path. You could do something like the following:

var fs = require("fs");
var xlsx = require('node-xlsx');
var xlsFile = __dirname + '/productExcell.xlsx'

fs.exists(xlsFile, function(exists){
  if (exists) {
    var obj = xlsx.parse(xlsFile);
    console.log(obj);
  } else {
    console.log('File does not exist');
  }
});
Sign up to request clarification or add additional context in comments.

1 Comment

installing excel seems very hard in windows, It requires lot of dependencies

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.