xsheetjs/demos/meteor/server/main.js
2017-05-24 18:52:35 -04:00

23 lines
526 B
JavaScript

import { Meteor } from 'meteor/meteor';
const XLSX = require('xlsx');
Meteor.methods({
upload: (bstr, name) => {
/* read the data and return the workbook object to the frontend */
return XLSX.read(bstr, {type:'binary'});
},
download: () => {
/* generate a workbook object and return to the frontend */
const data = [
["a", "b", "c"],
[ 1 , 2 , 3 ]
];
const ws = XLSX.utils.aoa_to_sheet(data);
const wb = {SheetNames: ["Sheet1"], Sheets:{Sheet1:ws }};
return wb;
}
});
Meteor.startup(() => { });