⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wpsortproperties.html

📁 永中OFFICE二次开发帮助文档
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<DD><DL>

<DT><B>返回:</B><DD>当排序对象是表格时,返回排序的方向。否则返回-1 <pre> SortOrderConstants.SORT_BY_COLUMN = 1; 按列排序 SortOrderConstants.SORT_BY_ROW = 0;    按行排序 </pre> <p> <b>例子:</b> <pre> Document doc = Application.getWorkbooks().getActiveWorkbook().getDocuments().getActiveDocument(); TextRange range = doc.getRange(0); Tables tables = doc.getTables(); Table table = tables.addTable(range, 5, 5); Rows rows = table.getRows(); for (int i = 0; i < rows.getCount(); i++) {      Row row = rows.getRow(i);      Cells cells = row.getCells();      for (int j = 0; j < cells.getCount(); j++)      {          cells.getCell(j).getRange().insertText("" + (i * j));      } } WpSortProperties isort = new WpSortProperties(); isort.setSortKey1(2); isort.setSortKeyType1(SortOrderConstants.NUMERIC); isort.setAscending1(false); isort.setSortOrientation(SortOrderConstants.SORT_BY_COLUMN); table.sort(isort); System.out.println("返回排序的方向为:"+ isort.getSortOrientation()); </pre></DL>
</DD>
</DL>
<HR>

<A NAME="isCaseSensitive()"><!-- --></A><H3>
isCaseSensitive</H3>
<PRE>
public boolean <B>isCaseSensitive</B>()</PRE>
<DL>
<DD>返回排序时是否区分大小写。
<P>
<DD><DL>

<DT><B>返回:</B><DD>true代表区分大小写 <b>例子:</b> <pre> Document document = Application.getWorkbooks().getActiveWorkbook().getDocuments().getActiveDocument(); TextRange range = document.getRange(0,0); range.insertTextAfter("name sex age salary"); range.insertTextAfter("\n张三 man 21 2500"); range.insertTextAfter("\n李芸 woman 19 1300"); range.insertTextAfter("\n小燕 woman 25 5300"); range.insertTextAfter("\n刘强 man 45 13000"); range = document.getRange(0,document.getLength()-1); WpSortProperties isort = new WpSortProperties(); isort.setExcludeTitle(true); isort.setSortKey1(1); isort.setAscending1(false); isort.setCaseSensitive(true); range.sort(isort); System.out.println("返回排序时是否区分大小写:" + isort.isCaseSensitive()); </pre></DL>
</DD>
</DL>
<HR>

<A NAME="isExcludeTitle()"><!-- --></A><H3>
isExcludeTitle</H3>
<PRE>
public boolean <B>isExcludeTitle</B>()</PRE>
<DL>
<DD>返回排序时是否包含标题行或标题列。
<P>
<DD><DL>

<DT><B>返回:</B><DD>是否包含标题行或标题列 <b>例子:</b> <pre> Document document = Application.getWorkbooks().getActiveWorkbook().getDocuments().getActiveDocument(); TextRange range = document.getRange(0,0); range.insertTextAfter("name sex age salary"); range.insertTextAfter("\n张三 man 21 2500"); range.insertTextAfter("\n李芸 woman 19 1300"); range.insertTextAfter("\n小燕 woman 25 5300"); range.insertTextAfter("\n刘强 man 45 13000"); range = document.getRange(0,document.getLength()-1); WpSortProperties isort = new WpSortProperties(); isort.setExcludeTitle(true); isort.setSortKey1(4); isort.setAscending1(false); range.sort(isort); System.out.println("返回排序时是否包含标题行或标题列:" + isort.isExcludeTitle()); </pre></DL>
</DD>
</DL>
<HR>

<A NAME="setAscending1(boolean)"><!-- --></A><H3>
setAscending1</H3>
<PRE>
public void <B>setAscending1</B>(boolean&nbsp;ascending)</PRE>
<DL>
<DD>设置是否以主关键字升序排列。
<P>
<DD><DL>
<DT><B>参数:</B><DD><CODE>ascending</CODE> - true代表升序排列 <b>例子:</b> <pre> Document document = Application.getWorkbooks().getActiveWorkbook().getDocuments().getActiveDocument(); TextRange range = document.getRange(0,0); range.insertTextAfter("name sex age salary"); range.insertTextAfter("\n张三 man 21 2500"); range.insertTextAfter("\n李芸 woman 19 1300"); range.insertTextAfter("\n小燕 woman 25 5300"); range.insertTextAfter("\n刘强 man 45 13000"); range = document.getRange(0,document.getLength()-1); WpSortProperties isort = new WpSortProperties(); isort.setExcludeTitle(true); isort.setSortKey1(4); isort.setAscending1(false); range.sort(isort); </pre></DL>
</DD>
</DL>
<HR>

<A NAME="setAscending2(boolean)"><!-- --></A><H3>
setAscending2</H3>
<PRE>
public void <B>setAscending2</B>(boolean&nbsp;ascending)</PRE>
<DL>
<DD>设置是否以次关键字升序排列。
<P>
<DD><DL>
<DT><B>参数:</B><DD><CODE>ascending</CODE> - true代表升序排列 <b>例子:</b> <pre> Document document = Application.getWorkbooks().getActiveWorkbook().getDocuments().getActiveDocument(); TextRange range = document.getRange(0,0); range.insertTextAfter("name sex age salary"); range.insertTextAfter("\n张三 man 21 2500"); range.insertTextAfter("\n李芸 woman 19 1300"); range.insertTextAfter("\n小燕 woman 25 5300"); range.insertTextAfter("\n刘强 man 45 13000"); range = document.getRange(0,document.getLength()-1); WpSortProperties isort = new WpSortProperties(); isort.setExcludeTitle(true); isort.setSortKey1(4); isort.setAscending1(false); isort.setSortKey2(1); isort.setSortKey2(SortOrderConstants.PHONETIC); isort.setAscending2(true); range.sort(isort); </pre></DL>
</DD>
</DL>
<HR>

<A NAME="setAscending3(boolean)"><!-- --></A><H3>
setAscending3</H3>
<PRE>
public void <B>setAscending3</B>(boolean&nbsp;ascending)</PRE>
<DL>
<DD>设置是否以第三关键字升序排列。
<P>
<DD><DL>
<DT><B>参数:</B><DD><CODE>ascending</CODE> - true代表升序排列 <b>例子:</b> <pre> Document document = Application.getWorkbooks().getActiveWorkbook().getDocuments().getActiveDocument(); TextRange range = document.getRange(0,0); range.insertTextAfter("name sex age salary"); range.insertTextAfter("\n张三 man 21 2500"); range.insertTextAfter("\n李芸 woman 19 1300"); range.insertTextAfter("\n小燕 woman 25 5300"); range.insertTextAfter("\n刘强 man 45 13000"); range = document.getRange(0,document.getLength()-1); WpSortProperties isort = new WpSortProperties(); isort.setExcludeTitle(true); isort.setSortKey1(4); isort.setSortKey2(2); isort.setSortKey3(1); isort.setSortKey3(SortOrderConstants.PHONETIC); isort.setAscending3(true); range.sort(isort); </pre></DL>
</DD>
</DL>
<HR>

<A NAME="setCaseSensitive(boolean)"><!-- --></A><H3>
setCaseSensitive</H3>
<PRE>
public void <B>setCaseSensitive</B>(boolean&nbsp;matchCase)</PRE>
<DL>
<DD>设置排序时是否区分大小写。
<P>
<DD><DL>
<DT><B>参数:</B><DD><CODE>matchCase</CODE> - true代表区分大小写 <b>例子:</b> <pre> Document document = Application.getWorkbooks().getActiveWorkbook().getDocuments().getActiveDocument(); TextRange range = document.getRange(0,0); range.insertTextAfter("name sex age salary"); range.insertTextAfter("\n张三 man 21 2500"); range.insertTextAfter("\n李芸 woman 19 1300"); range.insertTextAfter("\n小燕 woman 25 5300"); range.insertTextAfter("\n刘强 man 45 13000"); range = document.getRange(0,document.getLength()-1); WpSortProperties isort = new WpSortProperties(); isort.setExcludeTitle(true); isort.setSortKey1(1); isort.setAscending1(false); isort.setCaseSensitive(true); range.sort(isort); </pre></DL>
</DD>
</DL>
<HR>

<A NAME="setExcludeTitle(boolean)"><!-- --></A><H3>
setExcludeTitle</H3>
<PRE>
public void <B>setExcludeTitle</B>(boolean&nbsp;hasTitle)</PRE>
<DL>
<DD>设置排序时是否包含标题行或标题列。
<P>
<DD><DL>
<DT><B>参数:</B><DD><CODE>hasTitle</CODE> - 是否包含标题行或标题列 <b>例子:</b> <pre> Document document = Application.getWorkbooks().getActiveWorkbook().getDocuments().getActiveDocument(); TextRange range = document.getRange(0,0); range.insertTextAfter("name sex age salary"); range.insertTextAfter("\n张三 man 21 2500"); range.insertTextAfter("\n李芸 woman 19 1300"); range.insertTextAfter("\n小燕 woman 25 5300"); range.insertTextAfter("\n刘强 man 45 13000"); range = document.getRange(0,document.getLength()-1); WpSortProperties isort = new WpSortProperties(); isort.setExcludeTitle(true); isort.setSortKey1(4); isort.setAscending1(false); range.sort(isort); </pre></DL>
</DD>
</DL>
<HR>

<A NAME="setSeparator(char)"><!-- --></A><H3>
setSeparator</H3>
<PRE>
public void <B>setSeparator</B>(char&nbsp;c)</PRE>
<DL>
<DD>设置排序时用于区分域的分隔符。
<P>
<DD><DL>
<DT><B>参数:</B><DD><CODE>separator</CODE> - 分隔符,作为排序域的分隔符,是一个字符值,默认有两种 <pre>   制表位  '\t'  (默认) 逗号    ',' </pre>     也可以为其他字符,如 '*'.... <b>例子:</b> <pre> Document document = Application.getWorkbooks().getActiveWorkbook().getDocuments().getActiveDocument(); TextRange range = document.getRange(0,0); range.insertTextAfter("name sex age salary"); range.insertTextAfter("\n张三 man 21 2500"); range.insertTextAfter("\n李芸 woman 19 1300"); range.insertTextAfter("\n小燕 woman 25 5300"); range.insertTextAfter("\n刘强 man 45 13000"); range = document.getRange(0,document.getLength()-1); WpSortProperties isort = new WpSortProperties(); isort.setExcludeTitle(true); isort.setSeparator(','); isort.setSortKey1(4); isort.setAscending1(false); range.sort(isort); </pre></DL>
</DD>
</DL>
<HR>

<A NAME="setSortColumnOnly(boolean)"><!-- --></A><H3>
setSortColumnOnly</H3>
<PRE>
public void <B>setSortColumnOnly</B>(boolean&nbsp;bool)</PRE>
<DL>
<DD>当按列进行排序时,设置是否仅对列排序。 说明:此方法仅在表格排序并且按列排序时可用。
<P>
<DD><DL>
<DT><B>参数:</B><DD><CODE>bool</CODE> - 是否仅对列排序 <p> <b>例子:</b> <pre> Document doc = Application.getWorkbooks().getActiveWorkbook().getDocuments().getActiveDocument(); TextRange range = doc.getRange(0); Tables tables = doc.getTables(); Table table = tables.addTable(range, 5, 5); Rows rows = table.getRows(); for (int i = 0; i < rows.getCount(); i++) {      Row row = rows.getRow(i);      Cells cells = row.getCells();      for (int j = 0; j < cells.getCount(); j++)      {          cells.getCell(j).getRange().insertText("" + (i * j));      } } WpSortProperties isort = new WpSortProperties(); isort.setSortKey1(2); isort.setSortKeyType1(SortOrderConstants.NUMERIC); isort.setAscending1(false); isort.setSortOrientation(SortOrderConstants.SORT_BY_COLUMN); isort.setSortColumnOnly(true); table.sort(isort); </pre></DL>
</DD>
</DL>
<HR>

<A NAME="setSortKey1(int)"><!-- --></A><H3>
setSortKey1</H3>
<PRE>
public void <B>setSortKey1</B>(int&nbsp;key1)</PRE>
<DL>
<DD>设置排序主关键字索引。
<P>
<DD><DL>
<DT><B>参数:</B><DD><CODE>key1</CODE> - 排序主关键字索引 <b>例子:</b> <pre> Document document = Application.getWorkbooks().getActiveWorkbook().getDocuments().getActiveDocument(); TextRange range = document.getRange(0,0); range.insertTextAfter("name sex age salary"); range.insertTextAfter("\n张三 man 21 2500"); range.insertTextAfter("\n李芸 woman 19 1300"); range.insertTextAfter("\n小燕 woman 25 5300"); range.insertTextAfter("\n刘强 man 45 13000"); range = document.getRange(0,document.getLength()-1); WpSortProperties isort = new WpSortProperties(); isort.setSortKey1(4); range.sort(isort); </pre></DL>
</DD>
</DL>
<HR>

<A NAME="setSortKey2(int)"><!-- --></A><H3>
setSortKey2</H3>
<PRE>
public void <B>setSortKey2</B>(int&nbsp;key2)</PRE>
<DL>
<DD>设置排序次关键字索引。
<P>
<DD><DL>
<DT><B>参数:</B><DD><CODE>key2</CODE> - 排序次关键字索引 <b>例子:</b> <pre> Document document = Application.getWorkbooks().getActiveWorkbook().getDocuments().getActiveDocument(); TextRange range = document.getRange(0,0); range.insertTextAfter("name sex age salary"); range.insertTextAfter("\n张三 man 21 2500"); range.insertTextAfter("\n李芸 woman 19 1300"); range.insertTextAfter("\n小燕 woman 25 5300"); range.insertTextAfter("\n刘强 man 45 13000"); range = document.getRange(0,document.getLength()-1); WpSortProperties isort = new WpSortProperties(); isort.setExcludeTitle(true); isort.setSortKey1(4); isort.setSortKey2(1); isort.setSortKey2(SortOrderConstants.PHONETIC); range.sort(isort); </pre></DL>
</DD>
</DL>
<HR>

<A NAME="setSortKey3(int)"><!-- --></A><H3>
setSortKey3</H3>
<PRE>
public void <B>setSortKey3</B>(int&nbsp;key3)</PRE>
<DL>
<DD>设置排序第三关键字索引。
<P>
<DD><DL>
<DT><B>参数:</B><DD><CODE>key3</CODE> - 排序第三关键字索引 <b>例子:</b> <pre>

⌨️ 快捷键说明

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