Find text in spread sheets

From NOA Documentation Wiki

Jump to: navigation, search

Source: http://ubion.ion.ag/mainForumFolder/noa_forum/0100/


"Since [..][a SearchDescriptor in Spread Sheets] is not supported by NOA by now, you have to use the UNO API like this:"

ISpreadsheetDocument spreadsheetDocument = (ISpreadsheetDocument)document;
XSpreadsheets spreadsheets =
spreadsheetDocument.getSpreadsheetDocument().getSheets();
XSpreadsheet sheet = (XSpreadsheet) UnoRuntime.queryInterface(
XSpreadsheet.class, spreadsheets.getByName(
spreadsheets.getElementNames()[0]));
XCellRange cellRangeToSearch = sheet.getCellRangeByName("A1:R38";);
XSearchable xSearchable = (XSearchable) UnoRuntime.queryInterface(XSearchable.class, cellRangeToSearch);
XSearchDescriptor xSearchDesc = xSearchable.createSearchDescriptor();
xSearchDesc.setSearchString("NOA";);
/*xSearchDesc.setPropertyValue("SearchCaseSensitive", Boolean.TRUE);*/
xSearchDesc.setPropertyValue("SearchWords", Boolean.FALSE);
System.out.println("Search text found " + xSearchable.findFirst(xSearchDesc)); 
Personal tools