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
close icon

saving and reopening the file


    i am editing the excel file in angular and passing the file to .net 6 for saving using below code

        [HttpPost("Save"), DisableRequestSizeLimit]

        public async Task<IActionResult> Save([FromForm] SaveSettings saveSettings)//,string PhysicalFolder)




                using (ExcelEngine excelEngine = new ExcelEngine())


                    IApplication application = excelEngine.Excel;

                    string PhysicalFolderId = saveSettings.FileName.Split(',')[0];

                    Guid DocumentId = Guid.Parse(saveSettings.FileName.Split(',')[1]);

                    var path = await _context.Documents.Where(x => x.Id == DocumentId).FirstOrDefaultAsync();

                    var filePath = Path.Combine(_pathHelper.ContentRootPath, _pathHelper.DocumentPath, path.Path);

                    if (!System.IO.File.Exists(filePath))

                        return NotFound(filePath);

                    // Convert Spreadsheet data as Stream

                    Stream fileStream = Workbook.Save<Stream>(saveSettings);

                    IWorkbook workbook = application.Workbooks.Open(fileStream);

                    FileStream outputStream = new FileStream(filePath, FileMode.Create);






            catch (Exception ex)


                return Ok(ex); //NotFound(new ObjectResult("Failure"));


            return Ok("File Saved");


but after saving the file. File cannot be accessed after saving saying ' IOException: The process cannot access the file 'D:\filemanager\Main\SourceCode\DotnetCoreRESTApiSQLServerProvider\ShareDrive.API\Documents\4b352b37-332a-40c6-ab05-e38fcf109719\4fb7f532-4ff0-4843-a302-651907a5af8f.xlsx' because it is being used by another process.'

1 Reply 1 reply marked as answer

VR Vasanth Ravi Syncfusion Team October 27, 2022 10:12 AM

Hi Tirathpal ,

We have checked your reported issue and we suspect that the cause of the issue is due to the file stream is not properly disposed iyour server side save method. Hence, we suggest you to properly dispose the output stream in save method.  For more clarification regarding open/save the excel file in the server. Please find the link below.


We also attach a sample along with local Web API sample for your kind reference. Please do refer to it.

Stackblitz Sample: https://stackblitz.com/edit/angular-8ysbbu?file=app.component.ts 

Web API Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/WebAPI_-209939568.zip

Note: Run the API sample before performing the Save or Load action on the spreadsheet.

Kindly get back to us if you need further assistance regarding.

NOTE: If this post is helpful, please mark it as an answer so that other members can locate it more quickly.


Vasanth R

Marked as answer
Live Chat Icon For mobile
Up arrow icon