Here in this code, i want to achieve to calculate the sum of particular data that i took from excel file by this line :
" sumofKoli += JSON.stringify(row.values[4]);".
My problem is that even this line of code :
console.log(JSON.stringify(row.values[3])+" Sold number of :"+ JSON.stringify(row.values[4]));
Gives what i want like "47" which i exactly want as an integer, when i try to sum all the data i am having a result which is like "94559129995555.5.2556149.9". It adds it as a string value, i want it to sum as integer. Can you help me ?
Here is the full code :
Reader.prototype.readExcel = function(chartType,callback){
// read from a file
var workbook = new Excel.Workbook();
var sumofKoli=0;
var sumPrice =0;
workbook.xlsx.readFile(filename)
.then(function(err,results) {
var worksheet = workbook.getWorksheet('Sayfa1');
worksheet.eachRow({ includeEmpty: true }, function(row, rowNumber) {
console.log("----------");
console.log(JSON.stringify(row.values[3])+" Sold number of :"+ JSON.stringify(row.values[4]));
console.log("----------");
sumofKoli += JSON.stringify(row.values[4]);
console.log(JSON.stringify(row.values[3])+" Sold in price of :"+ JSON.stringify(row.values[5]));
sumPrice += JSON.stringify(row.values[5]);
console.log("----------");
});
results = { sumofKoli : sumofKoli, sumTutar : sumPrice};
if (err){callback(err,null);}
callback(null,results);
});
stringwith variable of typeinteger.