Read xlsx file using React uploader

Hi, I'm trying to read xlsx file using uploader component. I followed this link: https://www.syncfusion.com/forums/147826/how-to-import-excel-data-to-angular-grid, but I couldn't catch the change event. I attached sample project so that you can reproduce it easily. Thank you.

Attachment: xlsxreader_ba90c32d.zip

1 Reply 1 reply marked as answer

JM Jeyanth Muthu Pratheeban Sankara Subramanian Syncfusion Team August 5, 2020 02:53 PM UTC

Hi Roman,

Greetings from Syncfusion support.

We have checked your query. We would like to know you that change event will be triggered only if you bind the asyncSettings property which allows you to configure endpoints for saving or removing the file to the server. So we suggest you to use asyncsettings property to resolve your issue. Kindly refer the below code snippet. We have modified the attached sample. Please find the attached sample below.



 
public asyncSettings =  
  {saveUrl: 'https://ej2.syncfusion.com/services/api/uploadbox/Save', 
  removeUrl: 'https://ej2.syncfusion.com/services/api/uploadbox/Remove' } 
 
 
<UploaderComponent 
          id="chunkUpload" 
          ref={(scope) => { 
            this.uploadObj = scope; 
          }} 
          asyncSettings = {this.asyncSettings} 
          created = {this.onCreated} 
          change={this.onChange} 
></UploaderComponent> 



You can also get files by using native change event by binding the change event of native input in the Created event of Uploader as like below.


 
onCreated = (argsany) => { 
    this.uploadObj.element.addEventListener('change',function(e){ 
      console.log("Native Change event triggered"); 
    }) 
  }; 


Also, you can restrict the other files and upload only the specific extensions(.xlsx) by configuring the allowedExtensions property. 
Jeyanth. 


Marked as answer
Loader.
Up arrow icon