🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

node-json-xlsx

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-json-xlsx

canonically transform json to an excel document

latest
Source
npmnpm
Version
0.2.2
Version published
Weekly downloads
1.1K
44.78%
Maintainers
1
Weekly downloads
 
Created
Source

node-json-xlsx

utility to convert json to a excel file, based on Node-Excel-Export

Installation

npm install node-json-xlsx

Usage

Use to save as file:

var json2xlsx = require('node-json-xlsx');
var json = {
    foo: 'bar',
    qux: 'moo',
    poo: 123,
    stux: new Date()
}

var xlsx = json2xlsx(json);

fs.writeFileSync('data.xlsx', xlsx, 'binary');

Options

As a second parameter to json2xlsx or a third parameter to res.xlsx, a map of options can be passed:

var xlsx = json2xlsx(json, options);
res.xlsx('data.xlsx', jsonArr, options);

The following options are supported:

- style: a styles xml file, see <https://github.com/functionscope/Node-Excel-Export>
- fields: either an array or map containing field configuration:
    - array: a list of names of fields to be exported, in that order
    - object: a map of names of fields to be exported and the types of those fields. Supported types are 'number','string','bool'

Example:

var json2xlsx = require('node-json-xlsx');
var json = {
    foo: 'bar',
    qux: 'moo',
    poo: 123,
    stux: new Date()
}

//export only the field 'poo'
var xlsx = json2xlsx(json,{
    fields: ['poo']
});

//export only the field 'poo' as string
var xlsx = json2xlsx(json,{
    fields: {poo:'string'},
    fieldNames: ['Poo']

});

fs.writeFileSync('data.xlsx', xlsx, 'binary');

FAQs

Package last updated on 29 Mar 2017

Did you know?

Socket

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