📄 findreplace.html
字号:
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../application/workbooks/workbook/documents/document/FindReplace.html#setStyle(java.lang.String)">setStyle</A></B>(java.lang.String styleName)</CODE>
<BR>
设置查找或替换文本的样式。</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../application/workbooks/workbook/documents/document/FindReplace.html#setText(java.lang.String)">setText</A></B>(java.lang.String findString)</CODE>
<BR>
设置要查找的内容。</TD>
</TR>
</TABLE>
<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TH ALIGN="left"><B>从类 java.lang.Object 继承的方法</B></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE>equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</CODE></TD>
</TR>
</TABLE>
<P>
<!-- ============ METHOD DETAIL ========== -->
<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>方法详细信息</B></FONT></TH>
</TR>
</TABLE>
<A NAME="clearFormat()"><!-- --></A><H3>
clearFormat</H3>
<PRE>
public void <B>clearFormat</B>()</PRE>
<DL>
<DD>清除查找替换的格式,即初始化查找替换格式。 <p> <b>例子:</b> <pre> //请输入一些文字 Document doc = Application.getWorkbooks().getActiveDocument(); FindReplace finding = new FindReplace(); finding.setText("永中OFFICE"); finding.setFindWrap(2); System.out.println("清除格式前,text = " + finding.getText()); System.out.println("清除格式前,findWrap = " + finding.getFindWrap()); finding.clearFormat(); System.out.println("清除格式后,text = " + finding.getText()); System.out.println("清除格式后,findWrap = " + finding.getFindWrap()); </pre>
<P>
<DD><DL>
<DT><B>另请参见:</B><DD><A HREF="../../../../../application/workbooks/workbook/documents/document/FindReplace.html#setText(java.lang.String)"><CODE>setText(String)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="execute()"><!-- --></A><H3>
execute</H3>
<PRE>
public <A HREF="../../../../../application/workbooks/workbook/documents/document/FindResult.html" title="application.workbooks.workbook.documents.document 中的类">FindResult</A> <B>execute</B>()</PRE>
<DL>
<DD>在当前区域内进行指定条件的查找。 说明:当前区域指的是本查找管理器的来源对象的文本范围。即如果从TextRange对象中获得FindReplace,则当前 的查找范围就是TextRange指定的文本范围。如果从BaseText对象中获得FindReplace,则当前的查找范围就是正文的范围。 查找的条件由FindReplace对象的set方法指定,可以设置查找的文字、字体格式、段落格式、查找的方向等。详细的解释 可参看FindReplace对象的方法说明。
<P>
<DD><DL>
<DT><B>返回:</B><DD>返回查找的结果 <p> <b>例子:</b> <pre> Document doc = Application.getWorkbooks().getActiveDocument(); Section section = doc.getSection(0); BaseText baseText = section.getBaseText(); baseText.insertText(0,"this is a test!\nthis is a test!\nthis is a test!"); FindReplace finding = baseText.getFindReplace(); finding.clearFormat(); finding.setText("this"); finding.setFindDirect(FindConstants.FORWARD); FindResult result = finding.execute(); while (result.hasNext()) { TextRange rs = result.next(); rs.highlight(Color.red); } </pre></DL>
</DD>
</DL>
<HR>
<A NAME="execute(int)"><!-- --></A><H3>
execute</H3>
<PRE>
public boolean <B>execute</B>(int replaceType)</PRE>
<DL>
<DD>在当前区域内进行指定条件的查找操作。
<P>
<DD><DL>
<DT><B>参数:</B><DD><CODE>replaceType</CODE> - 表示查找操作过程中是否需要替换内容,可以取以下几种常量: <pre> FindConstants.REPLACE_NONE = 0; 表示替换的方式为不替换找到的内容 FindConstants.REPLACE_ONE = 1; 表示替换的方式为替换第一个找到的内容 FindConstants.REPLACE_ALL = 2; 表示替换的方式为替换所有的找到的内容 </pre>
<DT><B>返回:</B><DD>返回操作是否成功 <p> <b>例子:</b> <pre> Document doc = Application.getWorkbooks().getActiveDocument(); Section section = doc.getSection(0); BaseText baseText = section.getBaseText(); baseText.insertText(0,"this is a test!\nthis is a test!\nthis is a test!"); FindReplace finding = baseText.getFindReplace(); finding.clearFormat(); finding.setText("this"); finding.setFindDirect(FindConstants.FORWARD); boolean b = finding.execute(FindConstants.REPLACE_ALL); System.out.println("是否完成全部替换操作:" + b); </pre></DL>
</DD>
</DL>
<HR>
<A NAME="getFindDirect()"><!-- --></A><H3>
getFindDirect</H3>
<PRE>
public int <B>getFindDirect</B>()</PRE>
<DL>
<DD>判断文本查找的方式。 (注:要查找就必须创建FindReplace对象。)
<P>
<DD><DL>
<DT><B>返回:</B><DD>文本查找的方式,只能取以下值之一: <pre> FindConstants.FORWARD 表示查找的方式为向下查找 FindConstants.BACKWARD 表示查找方式为向上查找 FindConstants.ALL 表示查找方式为全部查找 </pre> <p> <b>例子:</b> <pre> Document doc = Application.getWorkbooks().getActiveDocument(); Section section = doc.getSection(0); BaseText baseText = section.getBaseText(); FindReplace finding = new FindReplace(); finding.clearFormat(); finding.setText("永中OFFICE"); finding.setFindDirect(FindConstants.FORWARD); baseText.find(finding); int findDirect = finding.getFindDirect(); System.out.println("文本查找的方式为:" + findDirect); </pre><DT><B>另请参见:</B><DD><A HREF="../../../../../application/workbooks/workbook/documents/document/FindReplace.html#setFindDirect(int)"><CODE>setFindDirect(int)</CODE></A>,
<A HREF="../../../../../application/workbooks/workbook/documents/document/FindReplace.html#clearFormat()"><CODE>clearFormat()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="getFontAttribute()"><!-- --></A><H3>
getFontAttribute</H3>
<PRE>
public <A HREF="../../../../../application/workbooks/workbook/style/font/FontAttribute.html" title="application.workbooks.workbook.style.font 中的类">FontAttribute</A> <B>getFontAttribute</B>()</PRE>
<DL>
<DD>获取查找或替换文本的字体格式。
<P>
<DD><DL>
<DT><B>返回:</B><DD>查找或替换文本的字体格式 <p> <b>例子:</b> <pre> Document doc = Application.getWorkbooks().getActiveDocument(); Section section = doc.getSection(0); BaseText baseText = section.getBaseText(); FindReplace finding = new FindReplace(); finding.clearFormat(); finding.setText("永中OFFICE"); FontAttribute font = new FontAttribute(); font.setBold(true); font.setFontSize(14); finding.setFont(font); finding.setForward(true); finding.setFormat(true); baseText.find(finding); FontAttribute findingFont = finding.getFont(); System.out.println("查找或替换文本是否为粗体:" + findingFont.isBold()); System.out.println("查找或替换文本的字体大小为:" + findingFont.getFontSize()); </pre><DT><B>另请参见:</B><DD><A HREF="../../../../../application/workbooks/workbook/documents/document/FindReplace.html#setFont(application.workbooks.workbook.style.font.FontAttribute)"><CODE>setFont(FontAttribute)</CODE></A>,
<A HREF="../../../../../application/workbooks/workbook/documents/document/FindReplace.html#setFormat(boolean)"><CODE>setFormat(boolean)</CODE></A>,
<A HREF="../../../../../application/workbooks/workbook/documents/document/FindReplace.html#clearFormat()"><CODE>clearFormat()</CODE></A>,
<A HREF="../../../../../application/workbooks/workbook/style/font/FontAttribute.html" title="application.workbooks.workbook.style.font 中的类"><CODE>FontAttribute</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="getFormat()"><!-- --></A><H3>
getFormat</H3>
<PRE>
public boolean <B>getFormat</B>()</PRE>
<DL>
<DD>判断查找或替换的文本是否设置了格式(包括字体格式,段落格式或样式等)。 (注:查找或替换时,只有查找文本与被查文本之间格式与文本内容都相同时才匹配。)
<P>
<DD><DL>
<DT><B>返回:</B><DD>布尔型值,如果为查找或替换的文本设置了格式,返回true;否则,返回false <p> <b>例子:</b> <pre> Document doc = Application.getWorkbooks().getActiveDocument(); Section section = doc.getSection(0); BaseText baseText = section.getBaseText(); FindReplace finding = new FindReplace(); finding.clearFormat(); finding.setText("永中OFFICE"); FontAttribute font = new FontAttribute(); font.setBold(true); font.setFontSize(14); finding.setFont(font); finding.setForward(true); finding.setFormat(true); baseText.find(finding); boolean isFormat = finding.getFormat(); System.out.println("查找或替换的文本是否设置了格式:" + isFormat); </pre><DT><B>另请参见:</B><DD><A HREF="../../../../../application/workbooks/workbook/documents/document/FindReplace.html#setFormat(boolean)"><CODE>setFormat(boolean)</CODE></A>,
<A HREF="../../../../../application/workbooks/workbook/documents/document/FindReplace.html#clearFormat()"><CODE>clearFormat()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="getHighlight()"><!-- --></A><H3>
getHighlight</H3>
<PRE>
public int <B>getHighlight</B>()</PRE>
<DL>
<DD>获取查找或替换文本匹配时是否高亮显示匹配区域。
<P>
<DD><DL>
<DT><B>返回:</B><DD>查找或替换文本匹配时匹配区域的显示方式,只能取以下三种值: <pre> FindConstants.NO_HIGHTLIGHT 0 匹配区域采用非高亮显示 FindConstants.HIGHTLIGHT 1 匹配区域采用高亮显示 FindConstants.NULL_HIGHLIGHT 2 匹配区域不考虑是否高亮显示 </pre> <p> <b>例子:</b> <pre> Document doc = Application.getWorkbooks().getActiveDocument(); Section section = doc.getSection(0); BaseText baseText = section.getBaseText(); FindReplace finding = new FindReplace(); finding.clearFormat(); finding.setText("永中OFFICE"); finding.setForward(true); finding.setFormat(true); finding.setHighlight(1); baseText.find(finding); int highlight = finding.getHighlight(); System.out.println("查找或替换文本匹配时匹配区域的显示方式为:" + highlight); </pre><DT><B>另请参见:</B><DD><A HREF="../../../../../application/workbooks/workbook/documents/document/FindReplace.html#setHighlight(int)"><CODE>setHighlight(int)</CODE></A>,
<A HREF="../../../../../application/workbooks/workbook/documents/document/FindReplace.html#setFormat(boolean)"><CODE>setFormat(boolean)</CODE></A>,
<A HREF="../../../../../application/workbooks/workbook/documents/document/FindReplace.html#clearFormat()"><CODE>clearFormat()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="getMatchCase()"><!-- --></A><H3>
getMatchCase</H3>
<PRE>
public boolean <B>getMatchCase</B>()</PRE>
<DL>
<DD>判断查找过程中是否区分大小写。
<P>
<DD><DL>
<DT><B>返回:</B><DD>布尔型值,如果查找过程中区分大小写,返回true;否则,返回false <p> <b>例子:</b> <pre> Document doc = Application.getWorkbooks().getActiveDocument(); Section section = doc.getSection(0); BaseText baseText = section.getBaseText(); FindReplace finding = new FindReplace(); finding.clearFormat(); finding.setText("office EIO"); finding.setForward(true); finding.setMatchCase(true); baseText.find(finding); boolean isMatchCase = finding.getMatchCase(); System.out.println("查找过程中是否区分大小写:" + isMatchCase); </pre><DT><B>另请参见:</B><DD><A HREF="../../../../../application/workbooks/workbook/documents/document/FindReplace.html#setMatchCase(boolean)"><CODE>setMatchCase(boolean)</CODE></A>,
<A HREF="../../../../../application/workbooks/workbook/documents/document/FindReplace.html#clearFormat()"><CODE>clearFormat()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="getMatchWholeWord()"><!-- --></A><H3>
getMatchWholeWord</H3>
<PRE>
public boolean <B>getMatchWholeWord</B>()</PRE>
<DL>
<DD>判断查找过程中查找的单词是否需要完全匹配。
<P>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -