如何查看excel表是否可用 [英] How to check out the excel sheet is available or not
本文介绍了如何查看excel表是否可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用以下代码阅读excel工作簿excel表
Hi,
I am using the following code to read excel sheets of excel workbook
OleDbDataAdapter command1 = new OleDbDataAdapter("Select * From [" + listSheetNames[0] + "]", connection);<br />
OleDbDataAdapter command2 = new OleDbDataAdapter("Select * From [" + listSheetNames[1] + "]", connection);<br />
OleDbDataAdapter command3 = new OleDbDataAdapter("Select * From [" + listSheetNames[2] + "]", connection);
现在只有3张excel表。
我需要编写代码的方式如果listSheetNames [3]可用然后做一些事情
我正在尝试下面的事情
Right now there are only 3 excel sheets.
I need to write the code in a way that if listSheetNames[3] is available then do something
I am trying some thing like below
if (listSheetNames[3] == "orange")<br />
{<br />
command4 = new OleDbDataAdapter("Select * From [" + listSheetNames[3] + "]", connection);<br />
command4.Fill(dataSet4);<br />
lstDS.Add(dataSet4);<br />
}
但是它不工作
任何人都可以帮我解决这个问题吗?
谢谢
John
But it is not working
Can any one help me in solving this???
Thanks
John
推荐答案
最初你应该问谷歌这个。
它回答了我的问题。
你可以找到你的解决方案此处 [ ^ ]。
希望这对你有所帮助。
问候,
RK
Hi,
Initially you should have asked Google for this.
It answered my your question for me.
You could find your solution here[^].
Hope this helps you a bit.
Regards,
RK
看看文章:如何使用GetOleDbSchemaTable和Visual C#.NET检索架构信息在标题为创建在数据库中列出表的样本的部分下。
请注意,表名(工作表名称)有一个后写
Have as look at the article: How To Retrieve Schema Information by Using GetOleDbSchemaTable and Visual C# .NET under the section titled: "Create Sample That List Tables in a Database".
Be advised that the table names (worksheet names) have a post-pended "
on(Sheet1成为Sheet1
" on them (Sheet1 becomes Sheet1
这篇关于如何查看excel表是否可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文