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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to import an external URL excel file while initial load the spreadsheet component

Platform: JavaScript - EJ 2 |
Control: Spreadsheet |
Published Date: October 1, 2020 |
Last Revised Date: October 8, 2020

Description

This knowledge base explains to import an excel file initially from an external URL to the spreadsheet component.

You can achieve to access the remote excel file by using the created event. In this event you can fetch the excel file and convert it to a blob. Convert this blob to a file and open this file by using Spreadsheet component open method.

 

[HTML]

 

<div id="spreadsheet"></div>        

 

[TS]

 

//Initialize Spreadsheet component.
        let spreadsheet: Spreadsheet = new Spreadsheet({
            openUrl: 'https://ej2services.syncfusion.com/production/web-services/api/spreadsheet/open',
            saveUrl: 'https://ej2services.syncfusion.com/production/web-services/api/spreadsheet/save',
            created: (): void => {
                fetch("https://js.syncfusion.com/demos/ejservices/data/Spreadsheet/LargeData.xlsx") // fetch the remote url
 
                    .then((response) => {
 
                        response.blob().then((fileBlob) => { // convert the excel file to blob
 
                            let file = new File([fileBlob], "Sample.xlsx"); //convert the blob into file
 
                            spreadsheet.open({ file: file }); // open the file into Spreadsheet
 
                        })
 
                    })
            }
        });
 
        //Render initialized Spreadsheet component.
        spreadsheet.appendTo('#spreadsheet');

 

Demo Sample: https://stackblitz.com/edit/bkampd-d3xeuf?file=index.ts 

 

 

 

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile