Created
May 4, 2022 13:16
-
-
Save mjschutz/4bbf89a37183fb63e649bcfe1ca8204a to your computer and use it in GitHub Desktop.
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 characters
<script src="http://cdn.jsdelivr.net/g/filesaver.js"></script> | |
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/exceljs.min.js" integrity="sha256-wJUdjGj95YIQF7RrY8E0M/aU998QyfG6xYKtQLp05/I=" crossorigin="anonymous"></script> | |
<script> | |
function SaveAsFile(t,f,m) { | |
try { | |
var b = new Blob([t],{type:m}); | |
saveAs(b, f); | |
} catch (e) { | |
window.open("data:"+m+"," + encodeURIComponent(t), '_blank',''); | |
} | |
} | |
async function saveAsExcel() { | |
const wb = new ExcelJS.Workbook() | |
const ws = wb.addWorksheet() | |
const row = ws.addRow(['a', 'b', 'c']) | |
row.font = { bold: true } | |
const buf = await wb.xlsx.writeBuffer() | |
SaveAsFile(buf,"abc.xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment