樂威壯 jpg">C# NPOI 打开Excel报The process cannot access the file because it is being used by another process的解决办法-程序旅途

最近一个项目中需要操作 Excel,我选择使用 NPOI 使用如下方式读取

using var stream = new FileStream(@"test.xlsx", FileMode.Open);

但是 test.xlsx 被其他程序打开的情况下,执行这段代码会报如下错误:

The process cannot access the file 'test.xlsx' because it is being used by another process.

(更多…)