[]
        
(Showing Draft Content)

FindOptions

Class FindOptions

java.lang.Object
com.grapecity.documents.excel.FindOptions

public class FindOptions extends Object
Wraps the optional parameters used by range search operations.

Use this class to configure how IRange.find(Object,IRange,FindOptions) and IRange.find(Object,FindOptions) search a range, including where to search, how to match content, the search order and direction, case sensitivity, byte matching, and an optional display format filter.


 worksheet.getRange("A1").setValue("Total");
 worksheet.getRange("A2").setFormula("=A1");

 FindOptions options = new FindOptions();
 options.setLookIn(FindLookIn.Formulas);
 options.setLookAt(LookAt.Part);
 IRange found = worksheet.getRange("A1:A2").find("A1", options);
 
  • Constructor Details

    • FindOptions

      public FindOptions()
  • Method Details

    • getLookIn

      public final FindLookIn getLookIn()
      Gets the data type that the search looks in.

      This property returns the current FindLookIn setting used by IRange.find(Object,IRange,FindOptions) to determine whether the search targets values, formulas, comments, or other supported content types.

      
       worksheet.getRange("A1").setValue("Hello World");
       worksheet.getRange("A2").setFormula("=\"Hello\"&\" World\"");
       FindOptions options = new FindOptions();
       options.setLookIn(FindLookIn.Formulas);
       FindLookIn lookIn = options.getLookIn();
       worksheet.getRange("A1:A2").find("Hello", null, options);
       
      Returns:
      The current FindLookIn setting. Returns null if no search target has been specified.
    • setLookIn

      public final void setLookIn(FindLookIn value)
      Sets the data type that the search looks in.

      Use this property to control where IRange.find(Object,IRange,FindOptions) or IRange.find(Object,FindOptions) searches, such as formulas, displayed text, values, or comments. The specified FindLookIn value is stored on this FindOptions instance and is later used by the range search operation.

      
       worksheet.getRange("A1").setValue("Hello World");
       worksheet.getRange("A2").setFormula("=\"Hello\"&\" World\"");
       FindOptions options = new FindOptions();
       options.setLookIn(FindLookIn.Formulas);
       worksheet.getRange("A1:A2").find("Hello", null, options);
       
      Parameters:
      value - The FindLookIn value that specifies the type of data to search in.
    • getLookAt

      public final LookAt getLookAt()
      Gets how search text is matched when this object is used with IRange.find(Object,IRange,FindOptions) or IRange.find(Object,FindOptions).

      The returned LookAt value controls whether a find operation matches the whole cell content or only part of it. This method returns the current value configured by setLookAt(LookAt).

      
       worksheet.getRange("A1").setValue("Hello World");
       FindOptions options = new FindOptions();
       options.setLookAt(LookAt.Whole);
       LookAt lookAt = options.getLookAt();
       worksheet.getRange("A1:A1").find("Hello World", options);
       
      Returns:
      The current LookAt setting. Returns null if no value has been specified.
    • setLookAt

      public final void setLookAt(LookAt value)
      Sets how search text is matched when this object is used with IRange.find(Object,IRange,FindOptions) or IRange.find(Object,FindOptions).

      Use this property to control whether a find operation matches the whole cell content or only part of it. The specified LookAt value is stored on this FindOptions instance and is later used by the range search operation.

      
       worksheet.getRange("A1").setValue("Hello World");
       worksheet.getRange("A2").setValue("Hello");
       FindOptions options = new FindOptions();
       options.setLookAt(LookAt.Whole);
       worksheet.getRange("A1:A2").find("Hello", null, options);
       
      Parameters:
      value - The LookAt setting that controls whole-content or partial-content matching. Specify LookAt.Whole to match the entire cell content or LookAt.Part to match part of it; null clears the current setting.
    • getSearchOrder

      public final SearchOrder getSearchOrder()
      Gets the order in which a range is searched when this object is used with IRange.find(Object,IRange,FindOptions) or IRange.find(Object,FindOptions).

      The returned SearchOrder value determines whether the search scans across rows first( SearchOrder.ByRows) or down columns first ( SearchOrder.ByColumns). This method returns the current value configured by setSearchOrder(SearchOrder).

      
       worksheet.getRange("A1:B2").setValue(new Object[][] {
           {"Name", "Value"},
           {"Test", "Value"}
       });
       FindOptions options = new FindOptions();
       options.setSearchOrder(SearchOrder.ByColumns);
       SearchOrder searchOrder = options.getSearchOrder();
       worksheet.getRange("A1:B2").find("Value", options);
       
      Returns:
      The current SearchOrder setting. Returns null if no value has been specified.
    • setSearchOrder

      public final void setSearchOrder(SearchOrder value)
      Sets the order in which a range is searched when this object is used with IRange.find(Object,IRange,FindOptions) or IRange.find(Object,FindOptions).

      Use this property to control whether a find operation scans across rows first or down columns first. Specify SearchOrder.ByRows to search across each row before moving to the next row, or SearchOrder.ByColumns to search down each column before moving to the next column. The specified SearchOrder value is stored on this FindOptions instance and is later used by the range search operation.

      
       worksheet.getRange("A1").setValue("Hello");
       worksheet.getRange("B1").setValue("Hello");
       FindOptions options = new FindOptions();
       options.setSearchOrder(SearchOrder.ByColumns);
       worksheet.getRange("A1:B1").find("Hello", null, options);
       
      Parameters:
      value - The SearchOrder setting that controls the search traversal order. Specify SearchOrder.ByRows to search by rows or SearchOrder.ByColumns to search by columns; null clears the current setting.
    • getSearchDirection

      public final SearchDirection getSearchDirection()
      Gets the search direction used by IRange.find(Object,IRange,FindOptions).

      The returned value determines whether the search proceeds forward ( SearchDirection.Next) or backward ( SearchDirection.Previous) through the range.

      
       worksheet.getRange("A1").setValue("Hello World");
       FindOptions options = new FindOptions();
       options.setSearchDirection(SearchDirection.Previous);
       SearchDirection searchDirection = options.getSearchDirection();
       worksheet.getRange("A1:A1").find("Hello", null, options);
       
      Returns:
      The current search direction. Returns null if no search direction has been set.
    • setSearchDirection

      public final void setSearchDirection(SearchDirection value)
      Sets the search direction when searching a range.

      This option determines whether IRange.find(Object,IRange,FindOptions) searches forward or backward through the target range. If the after argument is not specified when calling find, the search starts at the upper-left cell for SearchDirection.Next and at the bottom-right cell for SearchDirection.Previous.

      
       worksheet.getRange("A1").setValue("Hello");
       worksheet.getRange("A2").setValue("Hello");
       FindOptions options = new FindOptions();
       options.setSearchDirection(SearchDirection.Previous);
       worksheet.getRange("A1:A2").find("Hello", null, options);
       
      Parameters:
      value - The search direction to use. Must be a valid SearchDirection value.
    • getMatchCase

      public final boolean getMatchCase()
      Gets whether searches are case-sensitive.

      This property returns the current setting used by IRange.find(Object,IRange,FindOptions) and IRange.find(Object,FindOptions) to determine whether uppercase and lowercase letters are treated as different characters. The default value is false.

      
       worksheet.getRange("A1").setValue("Hello World");
       FindOptions options = new FindOptions();
       options.setMatchCase(true);
       boolean matchCase = options.getMatchCase();
       worksheet.getRange("A1:A1").find("Hello", options);
       
      Returns:
      true if searches are case-sensitive; otherwise, false.
    • setMatchCase

      public final void setMatchCase(boolean value)
      Sets whether searches are case-sensitive.

      This property sets the current setting used by IRange.find(Object,IRange,FindOptions) and IRange.find(Object,FindOptions) to determine whether uppercase and lowercase letters are treated as different characters. The default value is false.

      
       worksheet.getRange("A1").setValue("Hello World");
       FindOptions options = new FindOptions();
       options.setMatchCase(true);
       worksheet.getRange("A1:A1").find("Hello", options);
       
      Parameters:
      value - true if searches are case-sensitive; otherwise, false.
    • getMatchByte

      public final boolean getMatchByte()
      Gets how double-byte characters are matched when this object is used with IRange.find(Object,IRange,FindOptions) or IRange.find(Object,FindOptions).

      If this property is true, double-byte characters match only double-byte characters. If this property is false, double-byte characters can match their single-byte equivalents. This method returns the current value configured by setMatchByte(boolean).

      
       worksheet.getRange("A1").setValue("A");
       worksheet.getRange("A2").setValue("A");
       FindOptions options = new FindOptions();
       options.setMatchByte(true);
       boolean matchByte = options.getMatchByte();
       worksheet.getRange("A1:A2").find("A", options);
       
      Returns:
      true if double-byte characters match only double-byte characters; false if they can match their single-byte equivalents.
    • setMatchByte

      public final void setMatchByte(boolean value)
      Sets how double-byte characters are matched when this object is used with IRange.find(Object,IRange,FindOptions) or IRange.find(Object,FindOptions).
      
       worksheet.getRange("A1").setValue("A");
       worksheet.getRange("A2").setValue("A");
       FindOptions options = new FindOptions();
       options.setMatchByte(true);
       worksheet.getRange("A1:A2").find("A", options);
       
      Parameters:
      value - true if double-byte characters match only double-byte characters; false if they can match their single-byte equivalents.
    • getSearchFormat

      public final IDisplayFormat getSearchFormat()
      Gets the search format.

      Returns the IDisplayFormat used to match cell formatting during a find operation. The default value is null.

      
       worksheet.getRange("A1").setValue(100);
       worksheet.getRange("A1").setNumberFormat("$0.00");
       FindOptions options = new FindOptions();
       options.setSearchFormat(worksheet.getRange("A1").getDisplayFormat());
       IDisplayFormat searchFormat = options.getSearchFormat();
       
      Returns:
      The search format, or null if no format criteria has been set.
    • setSearchFormat

      public final void setSearchFormat(IDisplayFormat value)
      Sets the display format used as the search criterion.

      Use this method to limit a find operation to cells whose displayed formatting matches the specified IDisplayFormat. The default search format is null.

      
       worksheet.getRange("A1").setValue("Text");
       worksheet.getRange("A2").setValue("Text");
       worksheet.getRange("A2").getInterior().setColor(Color.GetRed());
       FindOptions options = new FindOptions();
       options.setSearchFormat(worksheet.getRange("A2").getDisplayFormat());
       worksheet.getRange("A1:A2").find("*", null, options);
       
      Parameters:
      value - The display format to match during the search, typically obtained from IRange.getDisplayFormat(); null clears the search format criterion.