rikkertkoppes / json2xls

canonically transform json to an excel document
278 stars 85 forks source link

File is always empty #11

Closed hazemhagrass closed 8 years ago

hazemhagrass commented 8 years ago

I tried the code in your example:

  var json = {
        foo: 'bar',
        qux: 'moo',
        poo: 123,
        stux: new Date()
    }

    var xls = json2xls(son);

    fs.writeFileSync(path, xls, 'binary');

but unfortunately the file in path is always empty

kvermeille commented 8 years ago

+1

brightloudnoise commented 8 years ago

looks like you have a typo on line 8.

var xls = json2xls(son);

should be:

var xls = json2xls(json);

rikkertkoppes commented 8 years ago

See comment by @brightloudnoise

For reference, this would be a complete working example:

var json2xls = require('../lib/json2xls');
var fs = require('fs');

var json = {
    foo: 'bar',
    qux: 'moo',
    poo: 123,
    stux: new Date()
}

var xls = json2xls(json);

fs.writeFileSync('output.xlsx', xls, 'binary');

Which results in the following excel sheet: image