Excel:查找隐藏单元格中的数据(不取消隐藏)
我有一个查找函数,如下所示:Excel:查找隐藏单元格中的数据(不取消隐藏),excel,c#-4.0,office-interop,Excel,C# 4.0,Office Interop,我有一个查找函数,如下所示: public static int FindRowThatContains(Excel.Worksheet ws, string what) { int result = 0; Excel.Range rng = ws.Cells.Find(what, Type.Missing, Excel.XlFindLookIn.xlValues,
public static int FindRowThatContains(Excel.Worksheet ws, string what)
{
int result = 0;
Excel.Range rng = ws.Cells.Find(what,
Type.Missing,
Excel.XlFindLookIn.xlValues,
Excel.XlLookAt.xlWhole,
Type.Missing,
Excel.XlSearchDirection.xlNext,
false,
Type.Missing,
Type.Missing);
if (rng != null)
result = rng.Row;
return result;
}
当包含我要查找的数据的单元格未隐藏时,此操作有效,但当搜索的单元格丢失时,此操作失败
有没有办法在搜索中包含隐藏的单元格
Thx尝试
XlFindLookIn.xlFormulas
而不是XlFindLookIn.xlValues
出现Range.Find
方法来复制Excel中的“查找”对话框。选择公式而不是值后,“查找”对话框将查找隐藏的单元格
当然,如果您不想在公式中搜索,这可能会导致其他问题,但使用此方法,它似乎是唯一的方法。工作得很好。谢谢,布鲁先生!