nicolaslopezj / excel-export

Export excel files with Meteor
MIT License
8 stars 4 forks source link

Uncaught TypeError: Cannot read property 'export' of undefined #7

Open beriliox opened 7 years ago

beriliox commented 7 years ago

Hello @nicolaslopezj : I've a app that has one button when is pressed, it should export any records of my collections in mongodb. But when i press it, the console show me the below message:

Uncaught TypeError: Cannot read property 'export' of undefined

Can you help me whit this please? Thanks

import {Excel} from 'meteor/nicolaslopezj:excel-export'

Template.tree.events({ 'click .exportar': function() { var data = Scrapers.find({id_usuario : Busquedas.findOne({sec : Busquedas.find().count()}).id_investigador}).fetch(); var fields = [ { key: 'autor', title: 'Autor', }, { key: 'institucion', title: 'Institucion' }, { key: 'campos', title: 'Campos de Investigacion' }, { key: '#', title: 'Publicaciones', }, , { key: '#', title: 'Coautores', }, { key: 'citas_totales', title: 'Citas totales', }, { key: 'citas_2012', title: 'Citas 2012', }, { key: 'indice_h_totales', title: 'Indice h totales', }, { key: 'indice_h_2012', title: 'Indice h 2012', }, { key: 'indice_i10_totales', title: 'Indice i10 totales', }, { key: 'indice_i10_2012', title: 'Indice i10 2012', } ];

var title = 'Scrapers';
var file = Excel.export(title, fields, data);
var headers = {
  'Content-type': 'application/vnd.openxmlformats',
  'Content-Disposition': 'attachment; filename=' + title + '.xlsx'
};

this.response.writeHead(200, headers);
this.response.end(file, 'binary');

}

rubenlpz commented 7 years ago

The same issue here. Did you find any solution?

rubenlpz commented 7 years ago

For those looking for workarounds, you can download your data to a CSV or JSON files using other packages available in atmospherejs.com

beriliox commented 7 years ago

yes, I used json2csv