C# Range.AutoFilter-更新筛选器问题

C# Range.AutoFilter-更新筛选器问题,c#,.net,excel,C#,.net,Excel,从我通过Range.AutoFilter筛选的excel文件中提取数据时遇到问题 我在excel文件中循环查找不同的数据,因此必须“重新应用”自动筛选以返回不同的结果。第一次应用自动筛选并运行SpecialCells(XlCellType.xlCellTypeVisible)时,我能够提取所需的数据。但是,当循环返回自动筛选以筛选新数据时,SpecialCells(XlCellType.xlCellTypeVisible)似乎不会引入新数据(只是excel标题) 我使用了Application.

从我通过Range.AutoFilter筛选的excel文件中提取数据时遇到问题

我在excel文件中循环查找不同的数据,因此必须“重新应用”自动筛选以返回不同的结果。第一次应用自动筛选并运行
SpecialCells(XlCellType.xlCellTypeVisible)
时,我能够提取所需的数据。但是,当循环返回自动筛选以筛选新数据时,
SpecialCells(XlCellType.xlCellTypeVisible)
似乎不会引入新数据(只是excel标题)

我使用了
Application.Visible=true
证明自动筛选正在使用新数据进行筛选,但是
特殊单元格(XlCellType.xlCellTypeVisible)
似乎不想拾取新筛选的数据。请参见下面我如何在循环中应用自动筛选以及如何提取数据。有人能给我指点一下我做错了什么吗

for(int row = 0, row < lineCount; row++)
{
.
.
.
//Other stuff not relate to filters happening
.
.
.
xlAppL.Visible = true;
xlRangeL.AutoFilter(<col>,<row>); //I can see this applying the new filter.
Range filterLines = xlRangeL.Cells.SpecialCells(XlCellType.xlCellTypeVisible);

Range aditionalFilter = filterLines.Areas[areaId];
object[,] af = aditionalFilter.Value2;
int linesCount = af.GetLength(0);
//Do stuff with the new filter
for(int row=0,row

当使用
xlRangeL.Cells.SpecialCells(XlCellType.xlCellTypeVisible);
..

时,过滤器线似乎无法拾取新的过滤数据,但我自己通过将范围传递给新方法并使数据循环通过新方法,从而纠正了这一问题