如何将打开的Excel文件数据读入数据表? [英] How Do I Read The Opened Excel File Data Into Datatable?
本文介绍了如何将打开的Excel文件数据读入数据表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在将excel数据读入数据表并存储到数据库表中。
但是当打开excel文件时我无法加载excel数据。
任何人都可以给我解决方案从打开的Excel中读取数据。
提前谢谢。
I am reading the excel data into datatable and storing into database table.
But i was unable to load the excel data when excel file is opened.
Can anybody give me the solution to read the data from opened excel.
Thanks in advance.
推荐答案
你不能。该文件被另一个进程独占锁定,其他任何应用程序都无法打开该文件并将其读取,直到任何进程锁定文件关闭它为止。
You can't. The file is locked exclusive by another process no other application can open the file and read it until whatever process has locked the file closes it.
放弃并打开副本。由于某种原因,微软几乎不可能对打开的工作簿做任何事情,除了另一本工作簿。我长期寻找一种与开放式工作簿进行交流的方法,但除了死胡同之外什么都没找到。祝你好运。
Give up and open a copy. Microsoft for some reason made it nearly impossible to do anything with an open workbook except from another workbook. I searched long for a way to communicate with an open workbook, but found nothing but dead ends. Good luck.
以readonly模式打开文件,例如< codelang> File.OpenRead(path)。
这样,即使文件处于其他程序的写入打开模式,该文件仍然可以被读取。
当然,无法写入文件。
Open the file in readonly mode for e.g. <codelang>File.OpenRead(path).
This way, even if the file is in write-open mode by some other program, the file can still be read.
There will, be, of course, no way to write to the file.
这篇关于如何将打开的Excel文件数据读入数据表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文