pagenumbers.html

来自「永中OFFICE二次开发帮助文档」· HTML 代码 · 共 1,004 行 · 第 1/4 页

HTML
1,004
字号
<PRE>
public int <B>getPageNumberFormat</B>()</PRE>
<DL>
<DD>返回插入页码的数字样式。
<P>
<DD><DL>
<DT><B>覆盖:</B><DD>类 <CODE>application.workbooks.workbook.documents.document.PageNumberAttribute</CODE> 中的 <CODE>getPageNumberFormat</CODE></DL>
</DD>
<DD><DL>

<DT><B>返回:</B><DD>int    插入页码的数字样式. 常量值如下: <pre>                FieldConstants.Arabic       数字样式为“1,2,3,...”      FieldConstants.ALPHABETIC   数字样式为“A,B,C,...”      FieldConstants.alphabetic   数字样式为“a,b,c,...”      FieldConstants.roman        数字样式为“i,ii,iii,...”      FieldConstants.ROMAN        数字样式为“I,II,III,...”      FieldConstants.ARABIC_DASH  数字样式为“- 1 -,- 2 -,- 3 -,...”      FieldConstants.DBCHAR       数字样式为“全角”      FieldConstants.CHINESENUM2  数字样式为“壹,贰,叁,...”      FieldConstants.CHINESENUM3  数字样式为“一,二,三(简),...”      FieldConstants.ZODIAC1      数字样式为“甲,乙,丙,...”      FieldConstants.ZODIAC2      数字样式为“子,丑,寅,...”      FieldConstants.GB1          数字样式为“⒈,⒉,⒊,...”      FieldConstants.GB2          数字样式为“⑴,⑵,⑶,...”      FieldConstants.GB3          数字样式为“①,②,③,...”      FieldConstants.GB4          数字样式为“㈠,㈡,㈢,...”  </pre> <p> <b>例子:</b> <pre> Document doc = Application.getWorkbooks().getActiveWorkbook().getDocuments().getActiveDocument(); Section section = doc.getSection(0); BaseText baseText = section.getBaseText(); baseText.insertText(0,"this is a test! this is a test!"); PageNumbers pageNumbers = section.getPageNumbers(); pageNumbers.setPageNumberFormat(FieldConstants.GB3); pageNumbers.addPageNumber(PageNumbersConstants.POSITION_HEADER, PageNumbersConstants.ALIGNMENT_CENTER, true); int numberFormat = pageNumbers.getPageNumberFormat(); System.out.println("插入页码的数字样式为:" + numberFormat); </pre><DT><B>另请参见:</B><DD><A HREF="../../../../../../application/workbooks/workbook/documents/document/section/PageNumbers.html#setPageNumberFormat(int)"><CODE>setPageNumberFormat(int)</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="getStartingNumber()"><!-- --></A><H3>
getStartingNumber</H3>
<PRE>
public int <B>getStartingNumber</B>()</PRE>
<DL>
<DD>得到所设置的起始页码。 注:只有当页码编排选项为设置起始页码时,此方法才有效。
<P>
<DD><DL>
<DT><B>覆盖:</B><DD>类 <CODE>application.workbooks.workbook.documents.document.PageNumberAttribute</CODE> 中的 <CODE>getStartingNumber</CODE></DL>
</DD>
<DD><DL>

<DT><B>返回:</B><DD>int  得到所设置的起始页码 <p> <b>例子:</b> <pre> Document doc = Application.getWorkbooks().getActiveWorkbook().getDocuments().getActiveDocument(); Section section = doc.getSection(0); BaseText baseText = section.getBaseText(); baseText.insertText(0,"this is a test! this is a test!"); PageNumbers pageNumbers = section.getPageNumbers(); pageNumbers.setContinueSection(false); pageNumbers.setStartingNumber(2); pageNumbers.addPageNumber(PageNumbersConstants.POSITION_HEADER, PageNumbersConstants.ALIGNMENT_CENTER, true); int startNumber = pageNumbers.getStartingNumber(); System.out.println("起始页码为:" + startNumber); </pre><DT><B>另请参见:</B><DD><A HREF="../../../../../../application/workbooks/workbook/documents/document/section/PageNumbers.html#setContinueSection(boolean)"><CODE>setContinueSection(boolean)</CODE></A>, 
<A HREF="../../../../../../application/workbooks/workbook/documents/document/section/PageNumbers.html#setStartingNumber(int)"><CODE>setStartingNumber(int)</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="isContinueSection()"><!-- --></A><H3>
isContinueSection</H3>
<PRE>
public boolean <B>isContinueSection</B>()</PRE>
<DL>
<DD>判断页码编排选项,即得到页码起始位置从哪开始(页码编排选项默认为续前节)。
<P>
<DD><DL>
<DT><B>覆盖:</B><DD>类 <CODE>application.workbooks.workbook.documents.document.PageNumberAttribute</CODE> 中的 <CODE>isContinueSection</CODE></DL>
</DD>
<DD><DL>

<DT><B>返回:</B><DD>布尔型值,页码编排是否为续前节。如果页码编排选项为续前节,即页码起始位置从1开始,且setStartingNumber(int)无效,则返回true;否则,返回false <p> <b>例子:</b> <pre> Document doc = Application.getWorkbooks().getActiveWorkbook().getDocuments().getActiveDocument(); Section section = doc.getSection(0); BaseText baseText = section.getBaseText(); baseText.insertText(0,"this is a test! this is a test!"); PageNumbers pageNumbers = section.getPageNumbers(); pageNumbers.setContinueSection(false); pageNumbers.setStartingNumber(2); pageNumbers.addPageNumber(PageNumbersConstants.POSITION_HEADER, PageNumbersConstants.ALIGNMENT_CENTER, true); boolean isContinue = pageNumbers.isContinueSection(); System.out.println("页码编排选项是否为续前节:" + isContinue); </pre><DT><B>另请参见:</B><DD><A HREF="../../../../../../application/workbooks/workbook/documents/document/section/PageNumbers.html#setContinueSection(boolean)"><CODE>setContinueSection(boolean)</CODE></A>, 
<A HREF="../../../../../../application/workbooks/workbook/documents/document/section/PageNumbers.html#setStartingNumber(int)"><CODE>setStartingNumber(int)</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="isFirstPageNumberVisible()"><!-- --></A><H3>
isFirstPageNumberVisible</H3>
<PRE>
public boolean <B>isFirstPageNumberVisible</B>()</PRE>
<DL>
<DD>判断插入页码时首页是否显示页号(默认显示首页页号)。 注:当首页不显示页号时,第二页的页号仍为2,即页码值仍是从首页开始计算的。
<P>
<DD><DL>
<DT><B>覆盖:</B><DD>类 <CODE>application.workbooks.workbook.documents.document.PageNumberAttribute</CODE> 中的 <CODE>isFirstPageNumberVisible</CODE></DL>
</DD>
<DD><DL>

<DT><B>返回:</B><DD>布尔型值,首页是否显示页号。如果首页显示页号,则返回true;否则,返回false   <p> <b>例子:</b> <pre> Document doc = Application.getWorkbooks().getActiveWorkbook().getDocuments().getActiveDocument(); Section section = doc.getSection(0); PageNumbers pageNumbers = section.getPageNumbers(); pageNumbers.setFirstPageNumberVisible(false); pageNumbers.addPageNumber(PageNumbersConstants.POSITION_HEADER, PageNumbersConstants.ALIGNMENT_CENTER); boolean isShowFirstPageNumber = pageNumbers.isFirstPageNumberVisible(); System.out.println("插入页码时首页是否显示页号:" + isShowFirstPageNumber); </pre><DT><B>另请参见:</B><DD><A HREF="../../../../../../application/workbooks/workbook/documents/document/section/PageNumbers.html#setFirstPageNumberVisible(boolean)"><CODE>setFirstPageNumberVisible(boolean)</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="isIncludeChapterNumber()"><!-- --></A><H3>
isIncludeChapterNumber</H3>
<PRE>
public boolean <B>isIncludeChapterNumber</B>()</PRE>
<DL>
<DD>判断插入的页码是否包含章节号(默认页码不包含章节号)。
<P>
<DD><DL>
<DT><B>覆盖:</B><DD>类 <CODE>application.workbooks.workbook.documents.document.PageNumberAttribute</CODE> 中的 <CODE>isIncludeChapterNumber</CODE></DL>
</DD>
<DD><DL>

<DT><B>返回:</B><DD>布尔型值,插入页码是否包含章节号。如果包含章节号,则返回true;否则,返回false <p> <b>例子:</b> <pre> //请在正文中输入几段文字,并对这几段文字格式化项目编号,选择多级编号中的带有标题的编号,使这些段落获得标题编号。 Document doc = Application.getWorkbooks().getActiveWorkbook().getDocuments().getActiveDocument(); Section section = doc.getSection(0); BaseText baseText = section.getBaseText(); baseText.insertText(0,"this is a test! this is a test!"); PageNumbers pageNumbers = section.getPageNumbers(); pageNumber.setIncludeChapterNumber(true); pageNumber.setHeadingLeverForCharpter(1); pageNumbers.addPageNumber(PageNumbersConstants.POSITION_HEADER, PageNumbersConstants.ALIGNMENT_CENTER, true); boolean isIncludeChapterNumber = pageNumbers.isIncludeChapterNumber(); System.out.println("插入页码是否包含章节号:" + isIncludeChapterNumber); </pre><DT><B>另请参见:</B><DD><A HREF="../../../../../../application/workbooks/workbook/documents/document/section/PageNumbers.html#setIncludeChapterNumber(boolean)"><CODE>setIncludeChapterNumber(boolean)</CODE></A>, 
<A HREF="../../../../../../application/workbooks/workbook/documents/document/section/PageNumbers.html#setHeadingLeverForCharpter(int)"><CODE>setHeadingLeverForCharpter(int)</CODE></A>, 
<A HREF="../../../../../../application/workbooks/workbook/documents/document/section/PageNumbers.html#setFirstPageNumberVisible(boolean)"><CODE>setFirstPageNumberVisible(boolean)</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="removePageNumber(int)"><!-- --></A><H3>
removePageNumber</H3>
<PRE>
public void <B>removePageNumber</B>(int&nbsp;index)</PRE>
<DL>
<DD>删除索引指定的页码。
<P>
<DD><DL>
<DT><B>参数:</B><DD><CODE>index</CODE> - 指定的索引,根据页码添加的顺序排列 <p> <b>例子:</b> <pre> Document doc = Application.getWorkbooks().getActiveWorkbook().getDocuments().getActiveDocument(); Section section = doc.getSection(0); PageNumbers pageNumbers = section.getPageNumbers(); pageNumbers.addPageNumber(PageNumbersConstants.POSITION_HEADER, PageNumbersConstants.ALIGNMENT_CENTER, true); pageNumbers.addPageNumber(PageNumbersConstants.POSITION_FOOTER, PageNumbersConstants.ALIGNMENT_LEFT, true); System.out.println("当前章节页码的个数:"+ pageNumbers.getCount()); pageNumbers.removePageNumber(0); System.out.println("删除后当前章节页码的个数:"+ pageNumbers.getCount()); </pre></DL>
</DD>
</DL>
<HR>

<A NAME="setChapterPageSeparator(int)"><!-- --></A><H3>
setChapterPageSeparator</H3>
<PRE>
public void <B>setChapterPageSeparator</B>(int&nbsp;type)</PRE>
<DL>
<DD>设置章节号与页码之间的分隔符类型(分隔符默认为连字号)。 注:章节号的起始样式应与带有标题编号段落的样式相同才能正确显示页码章节号。
<P>
<DD><DL>
<DT><B>覆盖:</B><DD>类 <CODE>application.workbooks.workbook.documents.document.PageNumberAttribute</CODE> 中的 <CODE>setChapterPageSeparator</CODE></DL>
</DD>
<DD><DL>
<DT><B>参数:</B><DD><CODE>type</CODE> - 分隔符类型,只能取以下值之一: <pre>      PageNumbersConstants.SEPARATOE_HYPHEN    页码与章节号之间的分隔符为连字号      PageNumbersConstants.SEPARATOE_PERIOD    页码与章节号之间的分隔符为句号      PageNumbersConstants.SEPARATOE_COLON     页码与章节号之间的分隔符为冒号      PageNumbersConstants.SEPARATOE_EM_DASH   页码与章节号之间的分隔符为长破折号      PageNumbersConstants.SEPARATOE_EN_DASH   页码与章节号之间的分隔符为短破折号 </pre> <p> <b>例子:</b> <pre> //请在正文中输入几段文字,并对这几段文字格式化项目编号,选择多级编号中的带有标题的编号,使这些段落获得标题编号。 Document doc = Application.getWorkbooks().getActiveWorkbook().getDocuments().getActiveDocument(); Section section = doc.getSection(0); BaseText baseText = section.getBaseText(); baseText.insertText(0,"this is a test! this is a test!"); PageNumbers pageNumbers = section.getPageNumbers(); pageNumbers.setIncludeChapterNumber(true); pageNumbers.setHeadingLeverForCharpter(1); pageNumbers.setChapterPageSeparator(PageNumbersConstants.SEPARATOE_COLON); pageNumbers.addPageNumber(PageNumbersConstants.POSITION_HEADER, PageNumbersConstants.ALIGNMENT_CENTER, true); </pre>
<DT><B>抛出:</B>
<DD><CODE><A HREF="../../../../../../application/exceptions/MacroRunException.html" title="application.exceptions 中的类">MacroRunException</A></CODE> - 指定的常量不存在<DT><B>另请参见:</B><DD><A HREF="../../../../../../application/workbooks/workbook/documents/document/section/PageNumbers.html#getChapterPageSeparator()"><CODE>getChapterPageSeparator()</CODE></A>, 
<CODE>#setHeadingLeverForChapter(int)</CODE>, 
<A HREF="../../../../../../application/workbooks/workbook/documents/document/section/PageNumbers.html#setIncludeChapterNumber(boolean)"><CODE>setIncludeChapterNumber(boolean)</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="setContinueSection(boolean)"><!-- --></A><H3>
setContinueSection</H3>
<PRE>
public void <B>setContinueSection</B>(boolean&nbsp;continueSection)</PRE>
<DL>
<DD>设置页码编排选项,即设置的页码起始位置从哪开始(页码编排选项默认为续前节)。
<P>
<DD><DL>
<DT><B>覆盖:</B><DD>类 <CODE>application.workbooks.workbook.documents.document.PageNumberAttribute</CODE> 中的 <CODE>setContinueSection</CODE></DL>
</DD>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?