You need to sign in to do that
Don't have an account?

Lightning web component using third party JS libraries
Hi I am trying to use the XLSX JS libraries to parse a CSV convert to JSON and upload into salesforce object. I had done this in Visual force and wanted to do the same in LWC.
But I am stuck in calling the 3rdd party JS lib method. My question is how do you call a method in the 3rd lib.
But I am stuck in calling the 3rdd party JS lib method. My question is how do you call a method in the 3rd lib.
import shimlatest from '@salesforce/resourceUrl/shimlatest'; import dropsh from '@salesforce/resourceUrl/DropSheet'; import xlsxfull from '@salesforce/resourceUrl/xlsxfull'; Promise.all([ loadScript(this, shimlatest), loadScript(this, xlsxfull), ]) .then(() => { X = XLSX; / THIS ONE ALWAYS COMES AS undefind console.log('XLSX Value of ' + X); if(X !== undefined) X = ''; this.initializePage(); }) .catch(error => { this.dispatchEvent( new ShowToastEvent({ title: 'Error loading XLSX modules', message: error.message, variant: 'error', }), ); });
We can not directly import the third party scripts in Lightning web components because Security purpose Salesforce restrict the importing scripts from third-party content delivery sites like cdnjs, jsdelivr, etc
1. First, you need to download the scripts from third-party sites.
2. Then upload the scripts in static resources.
check below link how to import static resources in Lightning web components
https://www.salesforcecodecrack.com/2019/01/how-to-access-static-resources-in.html
and for syntax check out the given link :
https://www.salesforcecodecrack.com/2019/03/how-to-import-third-party-libraries-in.html
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha
I have got the same error message during using XLSX, have you got the solution ? If so please advise thanks