How to remove read-only mode from excel file using interop.excel in C#

840 Views Asked by At

I have a doubt about the excel sheet. When I apply the formula column. If my code throws any exceptions/errors then my excel file is set as a read-only mode. So, here I want my file remains in read-write mode. Please, help me to solve this problem.

1

There are 1 best solutions below

0
Marat_Muginov On

There are multiple reasons why the file may only be available in read-only mode:

  1. Someone other process is using the file. Perhaps one of your earlier Excel instances you left opened after a crash / exception? Utilize Task Manager to kill ghost instances of Excel or other apps that may be using the file.

  2. The file is opened in read only mode. Here's some info on how to open it in editable mode. https://www.stellarinfo.com/article/excel-cannot-open-read-only-document.php