Skip to content

Instantly share code, notes, and snippets.

@TheShubhamVsnv
Created January 4, 2024 06:23
Show Gist options
  • Save TheShubhamVsnv/9dc3c72a35568a4f18aaf3161bc1f4f2 to your computer and use it in GitHub Desktop.
Save TheShubhamVsnv/9dc3c72a35568a4f18aaf3161bc1f4f2 to your computer and use it in GitHub Desktop.
exportExcelData() {
// Create a new Excel workbook
const workbook = new ExcelJS.Workbook();
// ... (Sheet creation logic for 'Index', 'Sheet 1', 'Sheet 2', 'Sheet 3')
// Write the workbook to a buffer and initiate download
workbook.xlsx.writeBuffer().then(buffer => {
var link = document.createElement("a");
link.href = 'data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,' + buffer.toString('base64');
link.download = 'FullProfileDetails.xls';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
});
// Show success message
const evt = new ShowToastEvent({
title: 'Download Successful',
message: 'Multiple Sheet Data downloaded successfully',
variant: 'success',
mode: 'dismissable'
});
this.dispatchEvent(evt);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment