Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel:查找隐藏单元格中的数据(不取消隐藏)_Excel_C# 4.0_Office Interop - Fatal编程技术网

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中的“查找”对话框。选择公式而不是值后,“查找”对话框将查找隐藏的单元格


当然,如果您不想在公式中搜索,这可能会导致其他问题,但使用此方法,它似乎是唯一的方法。

工作得很好。谢谢,布鲁先生!