How to read open excel file at C#

前端 未结 6 2096
北海茫月
北海茫月 2020-12-17 16:47

I want to read already open excel file with C#. I am using this method but it can\'t read the excel file while the file is open in Microsoft excel.

FileStre         


        
6条回答
  •  隐瞒了意图╮
    2020-12-17 17:39

    You can try the File.Open with a fourth parameter - fileShare.

    FileStream stream = File.Open("myfile.xlsx", FileMode.Open, FileAccess.Read, FileShare.Read);
    

    You may need to specify write access also.

提交回复
热议问题