Find Value in Cells in xlsx4j

Aspose.Cells - Find Value in Cells

In Microsoft Excel, users can search for cells that contain specific data. For example, clicking Edit and then Find opens the Search dialog. The user enters a value and clicks OK to search for it. Excel highlights matching fields.

Java

 // Instantiating a Workbook object
Workbook workbook = new Workbook("workbook.xls");

// Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.getWorksheets().get(0);

// Accessing the cells collection
Cells cells = worksheet.getCells();

// Instantiating FindOptions
FindOptions findOptions = new FindOptions();

// Finding the cell containing a string value that starts with "Or"
findOptions.setLookAtType(LookAtType.START_WITH);

Cell cell = cells.find("SH", null, findOptions);

// Printing the name of the cell found after searching the worksheet
System.out.println("Name of the cell containing String: " + cell.getName());

Download Running Code

Download Sample Code