如何阅读在C#打开excel文件 [英] How to read open excel file at C#

查看:159
本文介绍了如何阅读在C#打开excel文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想读已打开的Excel用C#文件。我使用这种方法,但同时,该文件是在Microsoft Excel中打开它无法读取Excel文件。

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.

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



它给 IOException异常:该进程无法访问文件'myfile.xlsx因为它正被另一个进程使用。

我希望你明白我的意思。我想保持excel文件打开,而文件是打开微软的Excel,我想从C#阅读。我使用C#.NET框架4.0

I hope you understands what I mean. I want to keep excel file open and while file is open at Microsoft excel i want to read it from C#. I am using C# net framework 4.0

推荐答案

我觉得你还是可以复制该文件,而Excel有它打开,所以你可以做该文件的副本,然后打开。只要确保你收拾好自己,当你与复制完成。

I think you can still copy the file while excel has it open, so you could make a copy of the file and then open that. Just make sure you clean up after yourself when you are done with the copy.

这篇关于如何阅读在C#打开excel文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆