nicolaslopezj / excel-export Goto Github PK
View Code? Open in Web Editor NEWExport excel files with Meteor
License: MIT License
Export excel files with Meteor
License: MIT License
Hi i'm trying to export mongodb records to xlsx since client side in my meteor app, but when i run the code, the console shows me the below message:
Uncaught ReferenceError: Excel is not defined at Object.click .exportar
NOTE: I installed the package in my project: meteor add nicolaslopezj:excel-export
Could you tell me what goin up with this? Thank you so much. i'll be hoping for any advance or help
...<div class="col-md-2 col-md-offset-7 col-xs-2 col-xs-offset-3">
<button type="button" class="btn exportar">Exportar a XLSX</button>
</div>...
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');
}
}, {where : 'client'});
Could I use any style such as "border, color, merge...."?
How to merge the cell?
ERROR - Meteor.userId can only be invoked in method calls. Use this.userId in publish functions.
How can solve this ?
Thanks a lot for this package. Very helpful to me. Wondering how to render an array of strings and treating objects (which structure varies based on user). example below, i want to convert the contents of the array to string using arr.toString()
"preferred_industries" : [
"Accountancy",
"Agriculture",
"fashion",
"music",
"ministry"
]
I tried this.
{
key: "preferences.preferred_industries",
title: "Industries",
type: "string",
transform: function(val, doc) {
return val.toString();
}
}
how can i achieve this type of thing. Thanks
Hi, thanks for this package
I have a download route in my app using your package, which i want to restrict access to. The route code is as follows
Router.route("/download-data", function() {
var data = Meteor.users.find({ "profile.user_type": "employee" }).fetch();
var fields = [...fields];
var title = "Employee - Users";
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");
},
{ where: "server" }
);
The route automatically downloads a file. This is currently working but I want to restrict access to the route. I only want admins to be able to download it.
I have created an onBeforeAction
Hook as below
Router.onBeforeAction(
function() {
//using alanning:roles
if(Roles.userIsInRole(this.userId, "admin"){
console.log('message') //testing
}
},
{
only: ["downloadData"]
}
);
and renamed my route as below
//code above
this.response.writeHead(200, headers);
this.response.end(file, "binary");
},
{ where: "server", name: "downloadData" }
);
The onBeforeAcion
hook does not take any effect
Also I noticed neither this.userId
nor Meteor.userId
works on the route
Hi,
I've tried to use this component in a Meteor method but I'm struggle with the Excel namespace not recognized:
import { DocumentCollection } from '../both/collections/document.collection';
Meteor.methods({
exportDocuments: function () {
var data = DocumentCollection.find({}).fetch();
var fields = [
{
key: 'id',
title: 'URL',
},
{
key: 'message',
title: 'Message'
},
{
key: 'viewsCount',
title: 'Views',
type: 'number'
}
];
var title = 'Posts';
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');
}
});
Even when I try to import import {Excel} from 'meteor/nicolaslopezj:excel-export' it says that import meteor/nicolaslopezj:excel-export cannot be find. I did the meteor add meteor/nicolaslopezj:excel-export. I don't know what need to be done.
Can you help?
Hi!
Does it supports more than 1760 rows? I have over 3k documents in collection, but it only writes 1760 rows if i put even more than this count.
please see bottom of this page meteor/meteor#10264. your package appears to be in conflict with accounts-base on meteor 1.8 and users are being logged out.
thanks for this package! after following the docs I am getting an error which is "Excel is not defined". what could be the problem here?
Can we export an Excel file with multiple sheets ?
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');
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.