Created
June 17, 2021 10:36
Revisions
-
dalmo3 created this gist
Jun 17, 2021 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ export const downloadSheet = (workbook: ExcelJS.Workbook) => { workbook.xlsx .writeBuffer() .then((buffer) => { // buffer --> blob const blob = new Blob([buffer], { type: 'application/vnd.ms-excel' }); const link = document.createElement('a'); link.download = 'download.xlsx'; link.target = 'blank'; // blob --> url link.href = URL.createObjectURL(blob); link.click(); }) .catch((err) => { throw err; }); };