使用 Aspose.Cells 在 Cells 中查找值

Aspose.Cells - 在 Cells 中寻找价值

在 Microsoft Excel 中,用户可以搜索包含特定数据的单元格。例如,点击编辑接着寻找打开搜索对话框。用户输入一个值并点击好的搜索它。 Excel 突出显示匹配字段。

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);

//Finding the cell containing the specified formula

Cells cells = worksheet.getCells();

//Instantiate 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 worksheet

System.out.println("Name of the cell containing String: " + cell.getName());

下载运行代码

下载示例代码