我怎样才能使用命名的区域在Excel与OLEDB? [英] How can I use named range in Excel with OleDB?

查看:122
本文介绍了我怎样才能使用命名的区域在Excel与OLEDB?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从Excel与ASP .NET / C#特定的命名范围内提取数据。这里是什么我试图提取的为例。

I'm trying to extract data from a specific named range in Excel with ASP .NET/C#. Here is an exemple of what I'm trying to extract.

我要的是B,C,D通过使用名为RANGE_NAMED。是否有可能与OLEDB做到这一点?

What I want is "B", "C", "D" by using the name "RANGE_NAMED". Is it possible to do this with OleDB ?

最好的问候,

亚历克斯。

推荐答案

您可以试试这个code

You could try this code

using(OleDbConnection c = new OleDbConnection(con))
{
    c.Open();
    string selectString = "SELECT * FROM [RANGE_NAMED]";
    using(OleDbCommand cmd1 = new OleDbCommand(selectString))
    {
          cmd1.Connection = c;
        var result = cmd1.ExecuteReader();
        while(result.Read())
        {
              Console.WriteLine(result[0].ToString());
        }
    }
}

这篇关于我怎样才能使用命名的区域在Excel与OLEDB?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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