xls-columns-json
v0.1.3
Published
Converting xls file to json files using nodejs
Downloads
3
Readme
node-columns-json
Fixed some bugs. Append columns select feature.
Converting xls file to json files using nodejs
Install
npm install xls-columns-json
Usage
node_xj = require("xls-columns-json");
xls_json({
input:"./ad.xls",// input xls
output:"./ad.json",// output json
sheet:"Page1",// specific sheetname
rowToSkip:1,// number of rows to skip at the top of the sheet; defaults to 0
columns:["name","price"],
filter:function(currentRow,currentIndex,rows){
if(currentRow["price"]<10) return false;
return true;
},
sort:function(rowA,rowB){
if(rowA["price"]>rowB["price"]) return -1;//Desc
if(rowA["price"]<rowB["price"]) return 1;
return 0;
},
columnMapper:{
price:function(value){//exists column price: current value -> new value
return Number(value);//attention.
},
elm:function(record){//not found column elm: current row -> extra column
return "<div>"+record["name"]+":"+record["price"]+"</div>"
}
},
callback:function(err,data){
if(err) {
console.error(err);
} else {
console.log(result);
}
}
});
In config object, you have to enter an input path. But If you don't want to output any file you can set to null
.
License
MIT @chilijung