We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Loading excel file sitting on server

Hi,

Please provide sample / documentation to load an excel file sitting on server.

Thanks

8 Replies

MV Madhan Venkateshan Syncfusion Team December 3, 2019 05:48 AM UTC

Hi Umair, 
 
Good day to you. 
 
We would like to suggest that you can open an excel file from the server using open method of spreadsheet control after http request. We have prepared a sample based on your requirement, please refer the below sample link and code snippet. 
 
 
App.component.ts 
loadExcel(args: Event) { 
    let request: XMLHttpRequest = new XMLHttpRequest(); 
    request.responseType = "blob"; 
    request.onload = () => { 
      let file: File = new File([request.response], (args.target as HTMLSelectElement).value + ".xlsx"); 
      this.spreadsheetObj.open({ file: file as any }); 
    } 
    request.open("GET", "http://localhost:53142/Files/" + (args.target as HTMLSelectElement).value + ".xlsx"); 
    request.send(); 
  } 
 
 
Regards, 
Madhan V 



UA Umair Ahmed December 4, 2019 09:44 PM UTC

Thanks Madhan, that worked.


MV Madhan Venkateshan Syncfusion Team December 5, 2019 06:06 AM UTC

Hi Umair, 
 
Thank you for your update, Please feel free to contact us if you need any further assistance on this. 
 
Regards, 
Madhan V 



UA Umair Ahmed December 24, 2019 12:40 AM UTC

Hi,

Can you please let me know what event is fired when its done loading the excel file, I found "loadComple" and "openComplete" but none of these seems to be firing, please advise.

Thanks.


AD Arunkumar Devendiran Syncfusion Team January 3, 2020 02:45 AM UTC

Hi Umair, 
 
Sorry for the inconvenience caused. 
 
We can reproduce the reported issue at our end and this is already known issue in our end. We will include the fix for this issue in our next patch release. We suggest you use our Volume 4 main release version (17.4.39) and this issue is not replicated in this version (17.4.39). We have created the sample for your reported query (17.4.39) in that we have using openComplete event. This event triggered on when data is loaded on spreadsheet, in this way you can achieve your requirement. Please refer the below sample and our documentation link. 
 
Sample Link: 
 
Api Link: 
 
Could you please check the above sample and let us know whether this is fulfilling your requirement, if not please share us more information regarding this. So, that we can analyze based on that and provide you a better solution. The information provided would be great help for us to proceed further. 
 
Regards, 
Arunkumar D 



SD Saranya Dhayalan Syncfusion Team January 8, 2020 10:46 AM UTC

Hi Umair, 
  
Good day to you. 
  
We are glad to announce that our weekly patch release (17.4.41) is rolled out. We would like to inform that we have included the openComplete event in our latest version (17.4.41). We have created the sample for your reported query in that version (17.4.41). Please refer the below sample link. 
  
Sample link: 
  
Please get back to us if you need further assistance. 
  
Regards, 
Saranya D 



AR Arno February 1, 2021 07:35 AM UTC

I get error of undefined.

loadExcel(argsEvent) {
    let requestXMLHttpRequest = new XMLHttpRequest();
    request.responseType = "blob";
    request.onload = () => {
      let fileFile = new File([request.response], (args.target as HTMLSelectElement).value + ".xlsx");      
      this.spreadsheetObj.open({ file: file as any });
    }
    request.open("GET""http://localhost:53142/Files/" + (args.target as HTMLSelectElement).value + ".xlsx");
    request.send();
  }

"this.spreadsheetObj.open({ file: file as any });" Open of undefined.

Any ideas why this would be?



SP Sangeetha Priya Murugan Syncfusion Team February 2, 2021 11:18 AM UTC

Hi Arno, 
 
Thank you for your update. 
 
We have checked your reported issue and we would like to let you know that the spreadsheet instance not getting properly based on your provided code. So, we suggest you to get the instance properly while calling the open method. For your convenience, we have prepared the sample based on your requirement, please find link below. 
 
  @ViewChild("default") 
  public spreadsheetObj: SpreadsheetComponent; 
  
created() { 
    fetch( 
      "https://js.syncfusion.com/demos/ejservices/data/Spreadsheet/LargeData.xlsx" 
    ).then(response => { 
      response.blob().then(fileBlob => { 
        var file = new File([fileBlob], "Sample.xlsx"); 
        this.spreadsheetObj.open({ file: file }); // To open the excel file 
      }); 
    }); 
  } 
 
 
 
Could you please check the above links and get back to us, if you need any further assistance on this. 
 
Regards, 
Sangeetha M 


Loader.
Live Chat Icon For mobile
Up arrow icon