function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sai prakash 14sai prakash 14 

how to read excel file data in lightning component

Best Answer chosen by sai prakash 14
sai prakash 14sai prakash 14
Thanks khan. that second link is working .

To work on this we need to use two js files. i am providing the two js link files to download and store them as static resource in your org

https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.8.0/jszip.js

https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.8.0/xlsx.js

In the second link u have to add window.xlsx=xlsx then only it will work otherwise it will show error.
where to add that is explained in this link- https://sfdcbro.com/2018/11/18/using-sheetjs-with-lightning-components/

 

All Answers

Khan AnasKhan Anas (Salesforce Developers) 
Hi Sai,

Greetings to you!

Please refer to the below links which might help you further with the above requirement.

https://developer.salesforce.com/forums/?id=9062I000000g6eLQAQ

https://developer.salesforce.com/forums/?id=9060G0000005oFvQAI

https://blogs.absyz.com/2018/01/08/csv-parsing-and-generating-charts-in-lightning-components/

https://medium.com/@nando2904/custom-csv-dataloader-lightning-component-part-1-csv-input-aef6225d9d10

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
sai prakash 14sai prakash 14
Hi khan ,
Thanks for reply, the links above u have sent those are for csv file reading i need to read excel (.xlsx) extension data.

Thanks and Regards
sai
Khan AnasKhan Anas (Salesforce Developers) 
sai prakash 14sai prakash 14
Thanks khan. that second link is working .

To work on this we need to use two js files. i am providing the two js link files to download and store them as static resource in your org

https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.8.0/jszip.js

https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.8.0/xlsx.js

In the second link u have to add window.xlsx=xlsx then only it will work otherwise it will show error.
where to add that is explained in this link- https://sfdcbro.com/2018/11/18/using-sheetjs-with-lightning-components/

 
This was selected as the best answer
sai prakash 14sai prakash 14
<aura:component implements="flexipage:availableForAllPageTypes" access="global">   
    <ltng:require scripts="{!$Resource.jszip}"/>    //create a static resource with name jszip
    <ltng:require scripts="{!$Resource.XLSX}"/>   //create another  static resource with name XLSX
    
    <aura:attribute name="FileList" type="Object"/>   
<lightning:input aura:id="file-input" type="file" files="{!v.FileList}" label="Files" 
                 name="file" multiple="true" onchange="{!c.upload}"/> 
</aura:component>

 
Tilottama Deore 5Tilottama Deore 5
Hi anas,
              I want to fetch data from columns in salesforce into the lightning component. I want fetch colums that has annual revenue of each year of a corresponding account record. I want to fetch values from columns in excel to respective account record