Save Excel file on Server

Hi there , I need to know how to Save Excel file on server by using Javascript . Please also provide me some sample code for this. 

Thanks & Regards ,

3 Replies

SP Sangeetha Priya Murugan Syncfusion Team December 8, 2020 11:02 AM UTC

Hi Vikash Kumar, 
 
Thank you for contacting Syncfusion support. 
 
We have checked your reported requirement and it can be achievable in our spreadsheet by using the openFromJson and saveAsJson client side methods. For open and saving the excel file we have used ASP.NET workbook server side action (Open, Save). For more details regarding your requirement. Please refer the below link. 
 
 
In the above link, we have done the open/save functionality in a button click event. Please check the above link and get back to us, if you need any further assistance on this. 
 
Regards, 
Sangeetha M 



VK Vikash Kumar December 8, 2020 04:30 PM UTC

Can you please send me sample with Php .. I am using Php + Javascript and I need to save Excel file on server . 


SP Sangeetha Priya Murugan Syncfusion Team December 9, 2020 07:59 AM UTC

Hi Vikash Kumar 
 
Thank you for your update. 
 
We have checked your reported requirement and we would suggest you to use JavaScript (ES5) spreadsheet in your end. For your convenience, we have prepared the sample that loads the excel file from the server and save the modified file in the server using open and save methods as like as below.  
 
 
public IActionResult Open(IFormCollection openRequest) 
        { 
            OpenRequest open = new OpenRequest(); 
            open.File = openRequest.Files[0]; 
            return Content(Workbook.Open(open)); 
        } 
 
        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); 
            FileStream filePath = new FileStream(Startup._env.WebRootPath.ToString() + "/Sample1.xlsx", FileMode.Create); 
            workbook.SaveAs(filePath);  // you can use this stream as your need.  
            fileStream.Dispose(); 
            filePath.Dispose(); 
            return "Spreadsheet saved in server"; 
        } 
 created() { 
    fetch("http://localhost:55367/" + "Sample1.xlsx").then(response => { 
      response.blob().then(fileBlob => { 
        var file = new File([fileBlob], "Sample.xlsx"); // to open the blob file 
        this.spreadsheetObj.open({ file: file }); 
      }); 
    }); 
  } 
   
 
 
 
Note: launch the service first and then open the stackblitz sample for import and export. 
 
 
 
Could you please check the above link and get back to us, if you need any further assistance on this. 
 
Regards, 
Sangeetha M 


Loader.
Up arrow icon