What is the recommended worflow to keep a workbook locked for editing while loaded with NPOI?
I am using:
Dim ReadStream As New FileStream(WorkbookPath, FileMode.Open, FileAccess.ReadWrite, FileShare.Read)
_Workbook = WorkbookFactory.Create(ReadStream)
but the stream is automatically closed once the workbook is created. The excel file can then be opened by other applications and tempered with before I save it back and it can result in corrupted file, or loss of data.
I read several posts on using OPCPackage directly or streams etc. but with everything I tried the file is released right after the workbook is created.
I aslo tried to open a second stream right after the workbook is created and maintaining it open until it is used to save the workbook. This works. However after several time saving the file it gets corrupted (while it is not corrupted if I save it into a Using
statement with a different stream).
Thank you for your suggestions