问题
This is pretty much exact question of : OleDbConnection() opens an Excel file in any open Excel window. But does not if there isnt a window open, but it had no answers.
If I have multiple Excel windows open, my program will open a read-only sheet in any Excel window. I.e. if I have Test.xlsx open, and a blank sheet in another window (let's say my program wants to write to Test.xlsx); when I do:
OleDbConnection myConn = new OleDbConnection(conn);
myConn.Open();
a read-only copy of Test.xlsx will open in the blank window, and the program will operate on that. Is there a way to ensure that myConn
uses the already open Test.xlsx?
If it helps, my conn
variable is:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\temp\Test.xlsx;Extended Properties="Excel 8.0;HDR=No""
来源:https://stackoverflow.com/questions/12300827/oledbconnection-opens-sheet-as-read-only-in-any-open-excel-window