Rajeev Akotkar
Rajeev Akotkar

Reputation: 1397

Excel to JSON conversion using Node JS

I have been trying to convert excel sheet data to json format and I have already various modules like "xls-to-json","xls-to-json-lc","node-excel-to-json", So far I have got empty response.

My sample code goes like this :

var node_xj = require("xls-to-json");
node_xj({
    input: req.file.path,  // input xls
    output: "output.json", // output json
    sheet: "a"             // specific sheetname
}, function(err, result) {
    if(err) {
        console.error(err);
    } else {
        console.log("--------result----");
        console.log(result);
    }
});

My excel sheet contains very simple data :

enter image description here

What am i doing wrong in this , I am getting file and its valid path .

Upvotes: 1

Views: 1233

Answers (1)

Rajeev Akotkar
Rajeev Akotkar

Reputation: 1397

got the solution , all the libraries consider first row as header , so it was not getting displayed , it got displayed when i added 2nd row and every module has got its own structure of output/ response. some modules consider excel headers in output and skip the first row and few include first row .

Upvotes: 1

Related Questions