-
-
Save TheShubhamVsnv/c03f65de8152472c48575a5535e57a83 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
import { LightningElement } from 'lwc'; | |
import { loadScript } from 'lightning/platformResourceLoader'; | |
import workbook from '@salesforce/resourceUrl/JSExcel'; | |
import { ShowToastEvent } from 'lightning/platformShowToastEvent'; | |
export default class FullProfileDetailTab extends LightningElement { | |
connectedCallback() { | |
// Load the exceljs library as a static resource | |
Promise.all([loadScript(this, workbook + "/exceljs/dist/exceljs.js")]) | |
.then(() => { | |
console.log('Library loaded successfully'); | |
}).catch(error => { | |
console.error('Error loading library: ' + JSON.stringify(error)); | |
}); | |
} | |
// ... (Other helper methods, if any) | |
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