使用Excel的OleDb要获得单订购表名称 [英] Using Excel OleDb to get sheet names IN SHEET ORDER

查看:110
本文介绍了使用Excel的OleDb要获得单订购表名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用OleDb的Excel工作簿中有很多表来读取。

I'm using OleDb to read from an excel workbook with many sheets.

我需要读取表名称,但我需要他们,他们是S preadsheet定义的顺序;所以如果我有一个看起来像这样的文件;

I need to read the sheet names, but I need them in the order they are defined in the spreadsheet; so If I have a file that looks like this;

|_____|_____|____|____|____|____|____|____|____|
|_____|_____|____|____|____|____|____|____|____|
|_____|_____|____|____|____|____|____|____|____|
\__GERMANY__/\__UK__/\__IRELAND__/

然后,我需要得到字典

Then I need to get the dictionary

1="GERMANY", 
2="UK", 
3="IRELAND"

我已经使用 OleDbConnection.GetOleDbSchemaTable()试过了,也练就了我的名字的名单,但按字母顺序排序。阿尔法排序意味着我不知道哪片数量特定名称相对应。所以我得到;

I've tried using OleDbConnection.GetOleDbSchemaTable(), and that gives me the list of names, but it alphabetically sorts them. The alpha-sort means I don't know which sheet number a particular name corresponds to. So I get;

GERMANY, IRELAND, UK

这已经改变英国爱尔兰的顺序。

我需要它来进行排序的原因是,我必须让用户选择一个范围内名称或索引的数据;他们可以要求所有的数据从德国爱尔兰或数据表1至表3。

The reason I need it to be sorted is that I have to let the user choose a range of data by name or index; they can ask for 'all the data from GERMANY to IRELAND' or 'data from sheet 1 to sheet 3'.

任何意见将大大AP preciated。

Any ideas would be greatly appreciated.

如果我可以使用办公室互操作类,这将是直接的。不幸的是,我不能因为互操作类不可靠的非交互式环境中,如Windows服务和ASP.NET网站的工作,所以我需要使用OLEDB。

if I could use the office interop classes, this would be straightforward. Unfortunately, I can't because the interop classes don't work reliably in non-interactive environments such as windows services and ASP.NET sites, so I needed to use OLEDB.

推荐答案

无法实际MSDN文档中找到这个,但是在论坛主持人说:

Can't find this in actual MSDN documentation, but a moderator in the forums said

恐怕OLEDB并不preserve板材订单,因为他们是在Excel

I am afraid that OLEDB does not preserve the sheet order as they were in Excel

<一个href=\"http://social.msdn.microsoft.com/Forums/en/adodotnetdataproviders/thread/2f459200-deef-4131-be8a-1b67a41efb97\">Excel在单订购表单名称

看起来这将是一个共同的足够需求,将有一个体面的解决办法。

Seems like this would be a common enough requirement that there would be a decent workaround.

这篇关于使用Excel的OleDb要获得单订购表名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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