I'm currently trying to develop an application which uses ClosedXML to read an .xlsx file and use some of these values to generate a .csv file. So far it seems to work fairly well but I still have some problems which might simply be due to my lack of knowledge
of how C# treats files, streams etc.
Currently I ask the user (using an OpenFileDialog) to choose the Excel file he/she wants to convert and open the Excel-file using:
originalWorkbook = new XLWorkbook(ofd.OpenFile())
Here I encounter the first problem: If the user has the file open in Excel, an IOException is thrown. Since I only need to read values from the workbook I would like to just open it as a readonly file which should be possible, even if the user has the file
opened in Excel.
My second problem is that the application seems to keep the workbook open until I close the application. This means that the user will only be able to open the file in Excel as a readonly file until the application is closed. Since I only want to read data
from the workbook I'm not interested in saving it at any point. Is there a way to close the workbook without using "SaveAs"?