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
Gulnawaz Aamir 7Gulnawaz Aamir 7 

Converting excel to JSON using lightning component

I want to convert the excel sheet into json format, I succeed in converting using Vf page but I want to convert this using Lightning component. Does anyone have any idea for this
praveena y 2praveena y 2
Hi did any one  get solution for this?
Gulnawaz Aamir 7Gulnawaz Aamir 7
Yes I did that, Here is the Code:

cmp File
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" access="global" >
    <!--<ltng:require scripts="{!join(',',$Resource.First,$Resource.Second,$Resource.Third)}" afterScriptsLoaded="{!c.handleUploadFinished}"/>
    <ltng:require scripts="{!$Resource.First}" afterScriptsLoaded="{!c.handleUploadFinished}"/>
      
    <ltng:require scripts="{!$Resource.Forth}" afterScriptsLoaded="{!c.handleUploadFinished}"/>-->  
   <ltng:require scripts="{!$Resource.Third}" afterScriptsLoaded="{!c.handleUploadFinished}"/>
    <ltng:require scripts="{!$Resource.Second}" afterScriptsLoaded="{!c.handleUploadFinished}"/> 
<lightning:input type="file" label="Attachment" aura:id="file" multiple="false"  onchange="{! c.handleUploadFinished }" name="btn"/>                
</aura:component>

JS Controller
({
    handleUploadFinished: function (component, event,helper) {
        // Get the list of uploaded files
        var name = event.getSource().get("v.name");
        if(name=='btn'){
            var uploadedFiles = event.getSource().get("v.files")[0];       
        alert("Files uploaded : " + uploadedFiles.size);        
            var wb = readSarf(uploadedFiles);
            alert(wb);
        }
    }
     
})

Now you need to Upload Three JS files into your static resource, I am pasting the files as text, copy these text as save as JS file like First.js,Second.js and Third.js
First
**************************************************************************
Sorry the files are very big I can not paste here, Send me email Id I will send you on that

Regards,
Gulnawaz Aamir