@@ -2054,6 +2054,51 @@ def remove_row(self, sheet: str, row: int) -> Optional[Exception]:
20542054 )
20552055 return None if err == "" else Exception (err )
20562056
2057+ def search_sheet (
2058+ self , sheet : str , value : str , * reg : bool
2059+ ) -> Tuple [List [str ], Optional [Exception ]]:
2060+ """
2061+ Get cell reference by given worksheet name, cell value, and regular
2062+ expression. The function doesn't support searching on the calculated
2063+ result, formatted numbers and conditional lookup currently. If it is a
2064+ merged cell, it will return the cell reference of the upper left cell of
2065+ the merged range reference.
2066+
2067+ Args:
2068+ sheet (str): The worksheet name
2069+ value (str): The cell value to search
2070+ *reg (bool): Specifies if search with regular expression
2071+
2072+ Returns:
2073+ Tuple[List[str], Optional[Exception]]: A tuple containing the
2074+ cell name and an exception if an error occurred, otherwise None.
2075+
2076+ Example:
2077+ An example of search the cell reference of the value of "100" on
2078+ Sheet1:
2079+
2080+ ```python
2081+ result, err = f.search_sheet("Sheet1", "100")
2082+ ```
2083+
2084+ An example of search the cell reference where the numerical value in
2085+ the range of "0-9" of Sheet1 is described:
2086+
2087+ ```python
2088+ result, err = f.search_sheet("Sheet1", "[0-9]", True)
2089+ ```
2090+ """
2091+ lib .SearchSheet .restype = types_go ._StringArrayErrorResult
2092+ res = lib .SearchSheet (
2093+ self .file_index ,
2094+ sheet .encode (ENCODE ),
2095+ value .encode (ENCODE ),
2096+ reg [0 ] if reg else False ,
2097+ )
2098+ arr = c_value_to_py (res , StringArrayErrorResult ()).arr
2099+ err = res .Err .decode (ENCODE )
2100+ return arr if arr else [], None if err == "" else Exception (err )
2101+
20572102 def set_active_sheet (self , index : int ) -> Optional [Exception ]:
20582103 """
20592104 Set the default active sheet of the workbook by a given index. Note that
0 commit comments