可以读取过滤后的行数据吗?

发布于 2025-01-09 17:27:02 字数 719 浏览 2 评论 0原文

场景

  1. 拥有一个包含表和数据的现有 Excel XLSX 文件。
  2. 该表已被过滤。例如,如果没有过滤器,它会有 5 行,并且当前被过滤为只有 3 行可见。
  3. 我想使用 EPPlus 从 XLSX 文件中读取经过严格筛选的 10 行。

这是未过滤时表格的样子:

在此处输入图像描述

这是过滤后表格的样子:

在此处输入图像描述

问题

是否可以通过以下方式仅获取那些过滤后的行C# 中的 EPPlus?

我已经在 EPPlus 存储库以及 Google 中搜索了各种问题,但没有找到任何一个类似的问题/答案。

似乎这可以通过 PIA 和 Excel Interop 实现,但我想在不依赖任何 Office 的情况下完成此操作。

Scenario

  1. Having an existing Excel XLSX file with a table and data.
  2. This table is filtered. E.g. it would have 5 rows without a filter and is currently filtered to only have 3 rows visible.
  3. I want to use EPPlus to read that very filtered 10 rows from the XLSX file.

This is how the table could look like when being unfiltered:

enter image description here

And this is how the table could look like when being filtered:

enter image description here

Question

Is it possible to get only those filtered rows via EPPlus in C#?

I've searched through various issues in the EPPlus repository as well as through Google in general and did not find one single similar question/answer.

It seems that this is possible via PIA and Excel Interop, but I want to do it without any Office dependency.

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

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

发布评论

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

评论(1

少年亿悲伤 2025-01-16 17:27:02

我还在 EPPlus 的 GitHub 页面上提出了这个问题,并得到了一个可行的答案< /a>:

必须检查 ExcelRow.Hidden 属性是否为 false,才能仅获取未过滤的可见行。

例子:

if (!worksheet.Rows[rowNumber].Hidden)
{
    // Process visible, unfiltered row.
}

I've also asked the question on EPPlus' GitHub page and got a working answer:

One has to check if the ExcelRow.Hidden property is false to get only the unfiltered, visible rows.

Example:

if (!worksheet.Rows[rowNumber].Hidden)
{
    // Process visible, unfiltered row.
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文