如何从定义的名称(命名范围)读取值?

发布于 2025-02-11 07:06:35 字数 550 浏览 1 评论 0原文

我正在使用exceldataReader读取XLS文件,而且工作正常,但我不知道如何读取定义的名称。

我能够将文件内容读取到数据集中:

var excelDataSet = reader.AsDataSet(new ExcelDataSetConfiguration 
{
    ConfigureDataTable = (_) => new ExcelDataTableConfiguration { UseHeaderRow = true }
});

然后,我可以从内容中获取第一个表:

DataTable? table = excelDataSet.Tables["MyTable"];

然后我可以通过行和列循环,

string cellValue = table.Rows[rowNumber][colNumber].ToString();

但这并不能从所谓的定义的名称< /strong>(命名范围)。如何阅读这些?

I'm using ExcelDataReader to read XLS files and it's working fine but I don't know how to read Defined Names.

I am able to read file contents into a DataSet:

var excelDataSet = reader.AsDataSet(new ExcelDataSetConfiguration 
{
    ConfigureDataTable = (_) => new ExcelDataTableConfiguration { UseHeaderRow = true }
});

I then take the first table from the contents:

DataTable? table = excelDataSet.Tables["MyTable"];

And I can then loop through rows and columns with

string cellValue = table.Rows[rowNumber][colNumber].ToString();

But this doesn't give me values from the so-called Defined Names (Named Ranges). How to read those?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白日梦 2025-02-18 07:06:35

目前,它在Exceldatareader中不支持 -
请参阅上一个堆栈溢出问题:使用exceldatareader.dataset的指定范围从excel表

It's currently not supported in ExcelDataReader -
See previous stack overflow question: How get a named range from an excel sheet using ExcelDataReader.Dataset

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文