sheetjs_sheetjs/demos/meteor/server/main.js

23 lines
526 B
JavaScript
Raw Normal View History

2017-05-24 22:52:35 +00:00
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(() => { });