Package com.independentsoft.office.spreadsheet

# Class FindResult

java.lang.Object
com.independentsoft.office.spreadsheet.FindResult

public class FindResult extends Object
A single match of a find operation. A result knows the objects holding the matched text, so the text can be replaced in place.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `delete()`
  Deletes the matched text.
  `Cell`
  `getCell()`
  Gets the cell the match belongs to or null if the match does not belong to a cell.
  `Comment`
  `getComment()`
  Gets the comment the match belongs to or null if the match does not belong to a comment.
  `Object`
  `getElement()`
  Gets the object holding the matched text, for example a `Cell` or a `Run`.
  `String`
  `getHostText()`
  Gets the whole text of the cell, comment, header, footer or shape paragraph the match belongs to.
  `int`
  `getLength()`
  Gets the number of matched characters.
  `Run`
  `getRun()`
  Gets the first run of the match or null if the matched text is not stored in runs.
  `List<Run>`
  `getRuns()`
  Gets all runs the match spans.
  `Sheet`
  `getSheet()`
  Gets the sheet the match belongs to.
  `int`
  `getStart()`
  Gets the index of the match in the text of the cell, comment, header, footer or shape paragraph.
  `ContentStory`
  `getStory()`
  Gets the part of the workbook the match was found in.
  `String`
  `getText()`
  Gets the matched text.
  `Worksheet`
  `getWorksheet()`
  Gets the worksheet the match belongs to or null if the match does not belong to a worksheet.
  `boolean`
  `replace​(Run run)`
  Replaces the matched text with the specified run.
  `boolean`
  `replace​(String newText)`
  Replaces the matched text with the specified text.
  `boolean`
  `replace​(List<Run> runs)`
  Replaces the matched text with the specified runs.
  `String`
  `toString()`
  Returns a string that represents the current `FindResult`.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Method Details

  - ### replace

    public boolean replace​(String newText)
    Replaces the matched text with the specified text. The format of the cell and the properties of all runs remain unchanged.
    Parameters:
      `newText` - the replacement text
    Returns:
      true if the text was replaced

  - ### replace

    public boolean replace​(Run run)
    Replaces the matched text with the specified run. A cell which holds plain text is converted into a rich text cell, the text before and after the match keeps its format.
    Parameters:
      `run` - the `Run` that replaces the matched text
    Returns:
      true if the text was replaced

  - ### replace

    public boolean replace​(List<Run> runs)
    Replaces the matched text with the specified runs.
    Parameters:
      `runs` - the `Run` objects that replace the matched text
    Returns:
      true if the text was replaced

  - ### delete

    public boolean delete()
    Deletes the matched text.
    Returns:
      true if the text was deleted

  - ### toString

    public String toString()
    Returns a string that represents the current `FindResult`.
    Overrides:
      `toString` in class `Object`
    Returns:
      a string that represents the current `FindResult`

  - ### getElement

    public Object getElement()
    Gets the object holding the matched text, for example a `Cell` or a `Run`.
    Returns:
      the object holding the matched text

  - ### getText

    public String getText()
    Gets the matched text.
    Returns:
      the matched text

  - ### getHostText

    public String getHostText()
    Gets the whole text of the cell, comment, header, footer or shape paragraph the match belongs to.
    Returns:
      the whole text of the cell, comment, header, footer or shape paragraph

  - ### getSheet

    public Sheet getSheet()
    Gets the sheet the match belongs to.
    Returns:
      the sheet the match belongs to

  - ### getWorksheet

    public Worksheet getWorksheet()
    Gets the worksheet the match belongs to or null if the match does not belong to a worksheet.
    Returns:
      the worksheet the match belongs to or null

  - ### getCell

    public Cell getCell()
    Gets the cell the match belongs to or null if the match does not belong to a cell.
    Returns:
      the cell the match belongs to or null

  - ### getComment

    public Comment getComment()
    Gets the comment the match belongs to or null if the match does not belong to a comment.
    Returns:
      the comment the match belongs to or null

  - ### getRun

    public Run getRun()
    Gets the first run of the match or null if the matched text is not stored in runs.
    Returns:
      the first run of the match or null

  - ### getRuns

    public List<Run> getRuns()
    Gets all runs the match spans.
    Returns:
      all runs the match spans

  - ### getStart

    public int getStart()
    Gets the index of the match in the text of the cell, comment, header, footer or shape paragraph.
    Returns:
      the index of the match

  - ### getLength

    public int getLength()
    Gets the number of matched characters.
    Returns:
      the number of matched characters

  - ### getStory

    public ContentStory getStory()
    Gets the part of the workbook the match was found in.
    Returns:
      the part of the workbook the match was found in