Socket
Socket
Sign inDemoInstall

xls-columns-json

Package Overview
Dependencies
2
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    xls-columns-json

Converting xls file to json files using nodejs


Version published
Maintainers
1
Install size
12.2 MB
Created

Readme

Source

node-columns-json

Fixed some bugs. Append columns select feature.

Build Status

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

Keywords

FAQs

Last updated on 24 Dec 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc