[]
IRange.replace(Object,Object,ReplaceOptions). Use this class to configure how content is matched and replaced in a range, including whether the search matches the whole cell content or part of it, the search order, case sensitivity, double-byte matching, and optional search and replacement formats. This wrapper keeps the replace API consistent when optional settings are provided.
worksheet.getRange("A1:A2").setValue(new Object[][] {
{"Draft"},
{"Draft plan"}
});
ReplaceOptions options = new ReplaceOptions();
options.setLookAt(LookAt.Whole);
worksheet.getRange("A1:A2").replace("Draft", "Final", options);
final LookAtfinal booleanfinal booleanfinal IDisplayFormatfinal IDisplayFormatfinal SearchOrderfinal voidfinal voidsetMatchByte(boolean value) final voidsetMatchCase(boolean value) final voidsetReplaceFormat(IDisplayFormat value) final voidsetSearchFormat(IDisplayFormat value) final voidsetSearchOrder(SearchOrder value) IRange.replace(Object,Object,ReplaceOptions).Returns one of the LookAt enum values that determines whether IRange.replace(Object,Object,ReplaceOptions) matches the whole search text or any part of it. The default value is LookAt.Part.
worksheet.getRange("A1:A3").setValue(new Object[][] {
{"NewYork"},
{"York"},
{"NewYork City"}
});
ReplaceOptions options = new ReplaceOptions();
options.setLookAt(LookAt.Whole);
LookAt lookAt = options.getLookAt();
worksheet.getRange("A1:A3").replace("NewYork", "Seattle", options);
LookAt enum value that specifies whether the replace operation matches the whole search text or any part of it.Use this method to specify whether the replace operation matches the whole search text or any part of it. The default value is LookAt.Part.
worksheet.getRange("A1:A3").setValue(new Object[][] {
{"NewYork"},
{"York"},
{"NewYork City"}
});
ReplaceOptions options = new ReplaceOptions();
options.setLookAt(LookAt.Whole);
worksheet.getRange("A1:A3").replace("NewYork", "Seattle", options);
value - The LookAt value that specifies whether the replace operation matches the whole search text or any part of it. Can be null.The search order determines how a range is traversed during a replace operation. For example, SearchOrder.ByRows searches across a row before moving to the next row, and SearchOrder.ByColumns searches down a column before moving to the next column.
worksheet.getRange("A1:B2").setValue(new Object[][] {
{"NewYork", "Draft"},
{"Review", "NewYork"}
});
ReplaceOptions options = new ReplaceOptions();
options.setSearchOrder(SearchOrder.ByColumns);
SearchOrder searchOrder = options.getSearchOrder();
worksheet.getRange("A1:B2").replace("NewYork", "Seattle", options);
SearchOrder enum value representing the search order.IRange.replace(Object,Object,ReplaceOptions). Use this method to control how the range is traversed during a replace operation. Specify SearchOrder.ByRows to search across each row before moving to the next row, or SearchOrder.ByColumns to search down each column before moving to the next column.
worksheet.getRange("A1:B2").setValue(new Object[][] {
{"NewYork", "Draft"},
{"Review", "NewYork"}
});
ReplaceOptions options = new ReplaceOptions();
options.setSearchOrder(SearchOrder.ByColumns);
worksheet.getRange("A1:B2").replace("NewYork", "Seattle", options);
value - The SearchOrder value that controls the search traversal order; null clears the current setting.This option controls whether IRange.replace(Object,Object,ReplaceOptions) matches letter case when searching text. The default value is false.
worksheet.getRange("A1:A3").setValue(new Object[][] {
{"newyork"},
{"NewYork"},
{"NEWYORK"}
});
ReplaceOptions options = new ReplaceOptions();
options.setMatchCase(true);
boolean matchCase = options.getMatchCase();
worksheet.getRange("A1:A3").replace("newyork", "Seattle", options);
true if the search is case-sensitive; otherwise, false. The default value is false.This option controls whether IRange.replace(Object,Object,ReplaceOptions) matches letter case when searching text. The default value is false.
worksheet.getRange("A1:A3").setValue(new Object[][] {
{"newyork"},
{"NewYork"},
{"NEWYORK"}
});
ReplaceOptions options = new ReplaceOptions();
options.setMatchCase(true);
worksheet.getRange("A1:A3").replace("newyork", "Seattle", options);
value - true if the search is case-sensitive; otherwise, false. The default value is false.If this property is true, double-byte characters match only double-byte characters. If this property is false, double-byte characters can match their single-byte equivalents.
Use setMatchByte(boolean) to change this setting for IRange.replace(Object,Object,ReplaceOptions) operations.
worksheet.getRange("A1:A2").setValue(new Object[][] {
{"A"},
{"A"}
});
ReplaceOptions options = new ReplaceOptions();
options.setMatchByte(true);
boolean matchByte = options.getMatchByte();
worksheet.getRange("A1:A2").replace("A", "B", options);
true if double-byte characters match only double-byte characters; false if they can match their single-byte equivalents.If this property is true, double-byte characters match only double-byte characters. If this property is false, double-byte characters can match their single-byte equivalents.
worksheet.getRange("A1:A2").setValue(new Object[][] {
{"A"},
{"A"}
});
ReplaceOptions options = new ReplaceOptions();
options.setMatchByte(true);
worksheet.getRange("A1:A2").replace("A", "B", options);
value - true if double-byte characters match only double-byte characters; false if they can match their single-byte equivalents.Returns the IDisplayFormat used by IRange.replace(Object,Object,ReplaceOptions) to limit matching to cells whose displayed formatting matches the specified format. The default value is null.
worksheet.getRange("A1").setValue("Draft");
worksheet.getRange("A1").setNumberFormat("$0.00");
ReplaceOptions options = new ReplaceOptions();
options.setSearchFormat(worksheet.getRange("A1").getDisplayFormat());
IDisplayFormat searchFormat = options.getSearchFormat();
null if no format criterion has been set.Use this method to limit IRange.replace(Object,Object,ReplaceOptions) to cells whose displayed format matches the specified IDisplayFormat.
worksheet.getRange("A1").setValue("NewYork");
worksheet.getRange("B1").setValue("NewYork");
worksheet.getRange("A1").getFont().setBold(true);
ReplaceOptions options = new ReplaceOptions();
options.setSearchFormat(worksheet.getRange("A1").getDisplayFormat());
worksheet.getRange("A1:B1").replace("NewYork", "Seattle", options);
value - The display format to use as the search criteria. Specify null to clear the search format.Returns the IDisplayFormat configured for IRange.replace(Object,Object,ReplaceOptions). When this property is not null, the replace operation uses the specified display format for matched cells after their values are replaced. The default value is null.
worksheet.getRange("A1").setValue("Draft");
worksheet.getRange("C1").getFont().setColor(Color.GetBlue());
ReplaceOptions options = new ReplaceOptions();
options.setReplaceFormat(worksheet.getRange("C1").getDisplayFormat());
IDisplayFormat replaceFormat = options.getReplaceFormat();
null if no replacement format has been set.This method configures the IDisplayFormat used by IRange.replace(Object,Object,ReplaceOptions). When this property is not null, the replace operation applies the specified display format to matched cells after their values are replaced. Specify null to remove the replacement format setting.
worksheet.getRange("A1").setValue("Draft");
worksheet.getRange("C1").getFont().setColor(Color.GetBlue());
ReplaceOptions options = new ReplaceOptions();
options.setReplaceFormat(worksheet.getRange("C1").getDisplayFormat());
worksheet.getRange("A1").replace("Draft", "Final", options);
value - The display format to apply to replaced cells. Specify null to clear the replacement format setting.