Created
February 2, 2015 20:25
-
-
Save debasreedash/33efd4473ba8b344a5ac to your computer and use it in GitHub Desktop.
conversion from excel to json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var convertJson = require('convert-json'); | |
exports.convertXLSXToJson = function(req, res) { | |
var path = fileServerPath + req.body.name; | |
console.log("in method req.body: " + path); | |
try | |
{ | |
console.log("Going to convert..."); | |
convertJson.xlsx(path, {header:true}, function(err, result) { | |
console.log("In convert callback"); | |
try | |
{ | |
console.log("Testing 'err'"); | |
if(err) | |
{ | |
console.log(err); | |
res.send(err); | |
console.log("Sent 'err' in response"); | |
} | |
else | |
{ | |
console.log("No 'err'"); | |
res.send(result); | |
console.log("Sent 'result' in response"); | |
} | |
} | |
catch (ex) | |
{ | |
console.log("Inner try"); | |
res.send(ex); | |
console.log("Sent 'ex' from inner try"); | |
} | |
// result should be a json object or array. | |
}); | |
console.log("Doing convert..."); | |
} | |
catch (ex) | |
{ | |
console.log("Error in outer try"); | |
res.send(ex); | |
console.log("Sent 'ex' from outer try"); | |
} | |
console.log("Leaving function"); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment