这可能是一个重复的问题,但实际上不知道如何标题.
有没有人能够在Excel Interop Library中找到一个方法,从"查找和替换"对话框中公开"查找全部"功能?
有Find,FindNext和FindPrevious,但没有FindAll,这很奇怪.
到目前为止,这是我这样做的方式,我第一次尝试它,可以这么说......
//FindRange() is an extension method which wraps Worksheet.Cells.Find()
Range start = sheet.FindRange(searchText,
XlLookAt.xlPart,
XlSearchOrder.xlByColumns,
XlSearchDirection.xlNext);
HashSet<int> matches = new HashSet<int>();
Range next = start;
while (true)
{
next = sheet.Cells.FindNext(next.get_Offset(1, 0));
if (!matches.Add(next.Row))
break;
}
Run Code Online (Sandbox Code Playgroud)
有什么想法吗?
| 归档时间: |
|
| 查看次数: |
1946 次 |
| 最近记录: |