获取怪异的表格/工作表名称 [英] Getting wierd table/sheet names
本文介绍了获取怪异的表格/工作表名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一些运行良好的代码.一些excel书籍给我带来奇怪的工作表,例如打印区域页面和其他元数据表
I have some code that has been working relatively well. Some excel books give me odd sheets, like the print area pages, and other meta data tables
System.Data.DataTable dt = Connection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
foreach (System.Data.DataRow dr in dt.Rows)
{
WorkSheets.Add(dr["TABLE_NAME"].ToString());
}
Connection.Close();
如何解决此问题以仅获取数据表?
How can I fix this to get just the data sheets?
推荐答案
使用Excel对象而不是OleDB进行连接. http://msdn.microsoft.com/en-us/library/wss56bz7 (v = VS.80).aspx [
Connect using the Excel Object instead of using OleDB. http://msdn.microsoft.com/en-us/library/wss56bz7(v=VS.80).aspx[^]
您也可以尝试OleDbSchemaGuid.Views,然后在OleDbSchemaGuid.Tables给您的内容和视图给您的内容之间进行区别.
You may try OleDbSchemaGuid.Views as well and then do a difference between what OleDbSchemaGuid.Tables gives you and the views give you.
这篇关于获取怪异的表格/工作表名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文