Difference between revisions of "Documentation/DevGuide/Spreadsheets/Search and Replace"
From Apache OpenOffice Wiki
< Documentation | DevGuide
m (1 revision(s)) |
OOoWikiBot (Talk | contribs) m (Robot: Changing Category:Spreadsheet Documents) |
||
Line 30: | Line 30: | ||
{{PDL1}} | {{PDL1}} | ||
− | [[Category: Spreadsheet Documents]] | + | |
+ | [[Category:Documentation/Developers Guide/Spreadsheet Documents]] |
Revision as of 09:53, 4 June 2008
The cell range interface com.sun.star.util.XReplaceable is derived from com.sun.star.util.XSearchable providing search and replacement of text.
- The method
createReplaceDescriptor()
creates a new descriptor that contains all data for the replace action. It returns the interface com.sun.star.util.XReplaceDescriptor of this descriptor. - The method
replaceAll()
performs a replacement in all cells according to the passed replace descriptor.
The following example replaces all occurrences of "cell" with "text":
// --- Replace text in all cells. --- com.sun.star.util.XReplaceable xReplace = (com.sun.star.util.XReplaceable) UnoRuntime.queryInterface(com.sun.star.util.XReplaceable.class, xCellRange); com.sun.star.util.XReplaceDescriptor xReplaceDesc = xReplace.createReplaceDescriptor(); xReplaceDesc.setSearchString("cell"); xReplaceDesc.setReplaceString("text"); // property SearchWords searches for whole cells! xReplaceDesc.setPropertyValue("SearchWords", new Boolean(false)); int nCount = xReplace.replaceAll(xReplaceDesc); System.out.println("Search text replaced " + nCount + " times.");
Content on this page is licensed under the Public Documentation License (PDL). |