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

How to get data change when edit on Spreadsheet and save to file?

I opened file exel from URL and edited. I want to save data change to file. Can you support me to slove this.

6 Replies

MV Madhan Venkateshan Syncfusion Team November 22, 2019 06:27 AM

Hi Nguyen, 
Thanks for contacting Syncfusion support. 
Query #1: Opening a excel file from the server 
We would like to suggest that you can open an excel file from the server using open method of spreadsheet control after http request. Please refer the code snippets below. 
<button class="e-btn" onclick="saveToServer()">Save Back to Server</button> 
<ejs-spreadsheet id="spreadsheet" openUrl="Home/Open" saveUrl="Home/Save" created="onCreated"></ejs-spreadsheet> 
    function onCreated() { 
        var spreadsheetObj = ej.base.getComponent(document.getElementById('spreadsheet'), 'spreadsheet'); 
        var request = new XMLHttpRequest(); 
        request.responseType = "blob"; 
        request.onload = () => { 
            var file = new File([request.response], "Sample1.xlsx"); 
            spreadsheetObj.open({ file: file }); 
        request.open("GET", "/Files/" + "Sample1.xlsx"); 
    function saveToServer() { 
        var spreadsheetObj = ej.base.getComponent(document.getElementById('spreadsheet'), 'spreadsheet'); 
Query #2: Save data back to the excel file 
You can able to achieve this by using save method of spreadsheet control to call the server controller method, In the controller method you can able to save back to the same excel file by using SaveAs method of XlsIO. Please refer the code snippets below. 
public string Save(SaveSettings saveSettings) 
            ExcelEngine excelEngine = new ExcelEngine(); 
            IApplication application = excelEngine.Excel; 
                // Convert Spreadsheet data as Stream 
                Stream fileStream = Workbook.Save<Stream>(saveSettings); 
                IWorkbook workbook = application.Workbooks.Open(fileStream); 
                var filePath = Startup._env.ContentRootPath.ToString() +  "/Files/Sample1.xlsx"; 
                FileStream outputStream = new FileStream(filePath, FileMode.Create); 
                return "Spreadsheet saved in server"; 
            catch (Exception ex) 
                return "Failure"; 
We have prepared the sample for your requirement, please refer the sample link below 
Madhan V 

NG Nguyen Gia Huy November 24, 2019 10:53 PM

Thank you so much for your reply.
I ran project example in your link, when i clicked on button "Save Back to Server", the button did not working. Press F12, in Console tab, i got error with message :"Uncaught Uncaught SyntaxError: Unexpected token 'function'" in file constants.js:93.
Please, support me to slove this plobrem. Thank you.

MV Madhan Venkateshan Syncfusion Team November 25, 2019 07:20 AM

Hi Nguyen, 
Sorry for the inconvenience caused. 
The reported issue is a known issue in our side. We have fixed the issue and it will be available in upcoming patch release on November 27 and appreciate your patience until then. We would suggest you to refer the below ej2 script of previous release version 17.3.16 until upcoming patch release as a workaround solution to resolve the issue at your end. 
<script src="https://cdn.syncfusion.com/ej2/17.3.16/dist/ej2.min.js"></script> 
Madhan V 

NG Nguyen Gia Huy November 25, 2019 08:46 PM

Thank you  very much. I soved this problem. 

MV Madhan Venkateshan Syncfusion Team November 26, 2019 02:24 AM

Hi Nguyen, 
Thank you for your update, We will update you once the patch release has been rolled out. 
Madhan V 

MV Madhan Venkateshan Syncfusion Team December 2, 2019 08:27 AM

Hi Nguyen, 
Thank you for your patience. 
We have corrected the reported issue and included it in the patch release ( version. So we would suggest you to use the updated JS file to resolve the issue in your end. Please find the link below. 
Script Link:  
Could you please check the above links and get back to us, if you need any further assistance on this. 
Madhan V 

Live Chat Icon For mobile
Up arrow icon