[]
        
首页
开发者学堂
文档
论坛
市场
生态机会
活动
立即试用
(Showing Draft Content)

FindOptions

Class FindOptions

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

public class FindOptions extends Object
包装区域搜索操作使用的可选参数。

使用此类可以配置 IRange.find(Object,IRange,FindOptions)和 IRange.find(Object,FindOptions) 搜索区域的方式,包括搜索位置、内容匹配方式、搜索顺序和方向、大小写敏感性、字节匹配,以及可选的显示格式筛选器。


 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()
      获取搜索所查找的数据类型。

      此属性返回当前 FindLookIn 设置,IRange.find(Object,IRange,FindOptions) 使用该设置确定搜索目标是值、公式、注释还是其他受支持的内容类型。

      
       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:
      当前 FindLookIn 设置。如果未指定搜索目标,则返回 null。
    • setLookIn

      public final void setLookIn(FindLookIn value)
      设置搜索所查找的数据类型。

      使用此属性可以控制 IRange.find(Object,IRange,FindOptions)或 IRange.find(Object,FindOptions) 的搜索位置,例如公式、显示文本、值或注释。指定的 FindLookIn 值会存储在此FindOptions 实例上,并由后续的区域搜索操作使用。

      
       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 - 指定要搜索的数据类型的 FindLookIn 值。
    • getLookAt

      public final LookAt getLookAt()
      获取将此对象与 IRange.find(Object,IRange,FindOptions)或 IRange.find(Object,FindOptions) 一起使用时搜索文本的匹配方式。

      返回的 LookAt 值控制查找操作是匹配整个单元格内容,还是只匹配其中一部分。此方法返回通过 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:
      当前 LookAt 设置。如果未指定任何值,则返回 null。
    • setLookAt

      public final void setLookAt(LookAt value)
      设置将此对象与 IRange.find(Object,IRange,FindOptions)或 IRange.find(Object,FindOptions) 一起使用时搜索文本的匹配方式。

      使用此属性可以控制查找操作是匹配整个单元格内容,还是只匹配其中一部分。指定的 LookAt 值会存储在此 FindOptions 实例上,并由后续的区域搜索操作使用。

      
       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 - 控制完整内容匹配或部分内容匹配的 LookAt 设置。指定LookAt.Whole 可匹配整个单元格内容,或指定 LookAt.Part 可匹配其中一部分;null会清除当前设置。
    • getSearchOrder

      public final SearchOrder getSearchOrder()
      获取将此对象与 IRange.find(Object,IRange,FindOptions)或 IRange.find(Object,FindOptions) 一起使用时搜索区域的顺序。

      返回的 SearchOrder 值确定搜索是先按行横向扫描( SearchOrder.ByRows),还是先按列向下扫描 ( SearchOrder.ByColumns)。此方法返回通过 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:
      当前 SearchOrder 设置。如果未指定任何值,则返回 null。
    • setSearchOrder

      public final void setSearchOrder(SearchOrder value)
      设置将此对象与 IRange.find(Object,IRange,FindOptions)或 IRange.find(Object,FindOptions) 一起使用时搜索区域的顺序。

      使用此属性可以控制查找操作是先按行横向扫描,还是先按列向下扫描。指定 SearchOrder.ByRows 可在移到下一行前搜索每一行,或指定SearchOrder.ByColumns 可在移到下一列前向下搜索每一列。指定的SearchOrder 值会存储在此 FindOptions 实例上,并由后续的区域搜索操作使用。

      
       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 - 控制搜索遍历顺序的 SearchOrder 设置。指定SearchOrder.ByRows 可按行搜索,或指定 SearchOrder.ByColumns 可按列搜索;null 会清除当前设置。
    • getSearchDirection

      public final SearchDirection getSearchDirection()
      获取 IRange.find(Object,IRange,FindOptions) 使用的搜索方向。

      返回值确定搜索是在区域中向前 ( SearchDirection.Next) 还是向后 ( SearchDirection.Previous) 进行。

      
       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:
      当前搜索方向。如果未设置搜索方向,则返回 null。
    • setSearchDirection

      public final void setSearchDirection(SearchDirection value)
      设置搜索区域时的搜索方向。

      此选项确定 IRange.find(Object,IRange,FindOptions) 是在目标区域中向前搜索还是向后搜索。如果调用 find 时未指定 after参数,则对于 SearchDirection.Next,搜索从左上角单元格开始;对于 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 - 要使用的搜索方向。必须是有效的 SearchDirection 值。
    • getMatchCase

      public final boolean getMatchCase()
      获取搜索是否区分大小写。

      此属性返回 IRange.find(Object,IRange,FindOptions)和 IRange.find(Object,FindOptions) 用于确定大小写字母是否被视为不同字符的当前设置。默认值为 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;否则为 false。
    • setMatchCase

      public final void setMatchCase(boolean value)
      设置搜索是否区分大小写。

      此属性设置 IRange.find(Object,IRange,FindOptions)和 IRange.find(Object,FindOptions) 用于确定大小写字母是否被视为不同字符的当前设置。默认值为 false。

      
       worksheet.getRange("A1").setValue("Hello World");
       FindOptions options = new FindOptions();
       options.setMatchCase(true);
       worksheet.getRange("A1:A1").find("Hello", options);
       
      Parameters:
      value - 如果搜索区分大小写,则为 true;否则为 false。
    • getMatchByte

      public final boolean getMatchByte()
      获取将此对象与 IRange.find(Object,IRange,FindOptions)或 IRange.find(Object,FindOptions) 一起使用时双字节字符的匹配方式。

      如果此属性为 true,则双字节字符只匹配双字节字符。如果此属性为 false,则双字节字符可以匹配其单字节等价字符。此方法返回通过 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;如果它们可以匹配其单字节等价字符,则为 false。
    • setMatchByte

      public final void setMatchByte(boolean value)
      设置将此对象与 IRange.find(Object,IRange,FindOptions)或 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;如果它们可以匹配其单字节等价字符,则为 false。
    • getSearchFormat

      public final IDisplayFormat getSearchFormat()
      获取搜索格式。

      返回在查找操作期间用于匹配单元格格式的 IDisplayFormat。默认值为 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:
      搜索格式;如果未设置格式条件,则返回 null。
    • setSearchFormat

      public final void setSearchFormat(IDisplayFormat value)
      设置用作搜索条件的显示格式。

      使用此方法可以将查找操作限制为显示格式与指定 IDisplayFormat 匹配的单元格。默认搜索格式为 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 - 搜索期间要匹配的显示格式,通常从IRange.getDisplayFormat() 获取; null 会清除搜索格式条件。