Meteor Promises
Rob Fallows
475

Now I have problem with `XlsxPopulate` npm to generate excel file and download.

// methods
Meteor.methods({
async writeExcel(){
if (!this.isSimulation) {
console.log('write method');

let wb = await XlsxPopulate.fromBlankAsync();
wb.sheet("Sheet1").cell("A1").value("This is neat!");
            return wb.outputAsync();               
}
},
----------
// client to download
handleWrite(){
Meteor.call('writeExcel', function (err, res) {
console.log(res);
        res.then(function (blob) {
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
window.navigator.msSaveOrOpenBlob(blob, "out.xlsx");
} else {
var url = window.URL.createObjectURL(blob);
var a = document.createElement("a");
document.body.appendChild(a);
a.href = url;
a.download = "out.xlsx";
a.click();
window.URL.revokeObjectURL(url);
document.body.removeChild(a);
}
})
});

But don’t work

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.