Load Excel document (base64 or File) in spreadsheet control

I am using SpreadSheet control (replacing kendo) in Apex application. On page load, I am initializing spreadsheet control, and on document ready, I am invoking apex (web service) call to return base 64 excel document.

(In kendo spreadsheet I converted base64 to File Object). When I try to open File by

spreadsheet.open({ file: file }); and document is not rendered. For reference following is my sample code

imported ej2.min.js and material.css only.

    var spreadsheet = new ej.spreadsheet.Spreadsheet(
    {
        allowDelete: false,
        allowEditing: false,
        showRibbon: false,
        allowOpen: true
    });
    spreadsheet.appendTo('#htmlout');
    apex.server.process(
    'GET_ATTACHMENT_CONTENT_BY_ID'
        , { x01: attachFileId}
        , { dataType: "text",
            async: false,
            complete: function(ajaxResponse)
            {
            var response = ajaxResponse.responseText;
            var file = dataURLtoFile('data:'+mimeType+';base64,'+response,fileName);
            // file working fine with kendo and SheetJs constrol.


            console.log(spreadsheet);


            spreadsheet.open({ file: file });
            }
        }
    );

Here I want to mention that complete function is working fine, and Kendo/SheetJs rendered document successfully.

Can you give me any example where I can simple browse excel file from openDialog and render do


3 Replies

SP Sangeetha Priya Murugan Syncfusion Team August 1, 2022 02:20 PM UTC

Hi Kamran,


We suspect that you need to load the excel file in the HTTP server call and we would let you know that we have used our Syncfusion XLSIO library to open/save the excel file. And you need to host your own web service for import/export actions and provide it in openUrl and saveUrl property.


We have done the Open/ Save (server side) functionality in ASP.NET only. And we have published our API services in the GitHub location, for more details please refer the below links.


Service sample Locationhttps://github.com/SyncfusionExamples/EJ2-Spreadsheet-WebServices/


To save/open the excel file in server, please refer the below link.


Knowledge base link: https://www.syncfusion.com/kb/11970/how-to-open-and-save-an-excel-file-to-server-in-the-spreadsheet


In the above link, we have done the open/save functionality in a button click event.


To create the local web service, please refer the below link.


https://www.syncfusion.com/kb/13200/how-to-remove-trial-version-tab-created-in-spreadsheet


Documentation Link: https://ej2.syncfusion.com/javascript/documentation/spreadsheet/open-save/


Could you please check the above links and get back to us, if you need any further assistance on this.


Regards, 

Sangeetha M 



KA Kamran replied to Sangeetha Priya Murugan August 2, 2022 05:58 AM UTC

Thanks  Sangeetha for your response.

We are connected to http services, but this service is written in Oracle apex. i.e. we are only able to read base64 of excel document. There is no implementation of Syncfusion FileIO processing. 


In other word, I am looking for example to load xml document from client machine by using Open Dialog. We do not want to implement server urls i.e. OpenUrl, SaveUrl.


For reference can you please have a look of our requirements.

https://docs.telerik.com/kendo-ui/api/javascript/ui/spreadsheet/methods/fromfile


Appreciate if you can provide me details. 



SP Sangeetha Priya Murugan Syncfusion Team August 3, 2022 10:03 AM UTC

Hi Kamran,


As we have stated previously, we have done open/save functionality in ASP.NET only. While open the excel file using File-> open option or open method, we have sent the request to the server. In that sever we have converted the excel file to spreadsheet supported JSON format and load into the spreadsheet. While saving, we have sent the JSON to server and convert into excel using XLSIO library.


So, we suggest you to use local ASP.NET web service and provide that hosted server action link in openUrl and saveUrl respectively. And we have provided support to load excel file in JSON format and Blob file. We don’t have support to load XML format. For more details, regarding open/save action. Please refer the below link.


https://ej2.syncfusion.com/javascript/documentation/spreadsheet/open-save/


To load the online hosted, excel file as blob format. Please refer the below link.


https://www.syncfusion.com/kb/11955/how-to-import-an-external-url-excel-file-while-initial-load-the-spreadsheet-component


To save/open the excel file in server in JSON format, please refer the below link.


Knowledge base link: https://www.syncfusion.com/kb/11970/how-to-open-and-save-an-excel-file-to-server-in-the-spreadsheet


Could you please check the above links and get back to us, if you need any further assistance on this.


Regards,

Sangeetha M



Loader.
Up arrow icon