📄 cells.html
字号:
<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="addCell(application.workbooks.workbook.tables.Cell, int)"><!-- --></A><H3>
addCell</H3>
<PRE>
public <A HREF="../../../../application/workbooks/workbook/tables/Cell.html" title="application.workbooks.workbook.tables 中的类">Cell</A> <B>addCell</B>(<A HREF="../../../../application/workbooks/workbook/tables/Cell.html" title="application.workbooks.workbook.tables 中的类">Cell</A> beforeCell,
int shiftCells)</PRE>
<DL>
<DD>在指定的单元格插入新的单元格。插入新单元格后可选择控制如何移动活动的单元格。
<P>
<DD><DL>
<DT><B>参数:</B><DD><CODE>beforeCell</CODE> - 指定单元格<DD><CODE>shiftCells</CODE> - 新单元格插入后,其他活动单元格的补齐方式,只能取以下整型值之一: <pre> TableConstants.CELL_RIGHTMOVE 活动单元格右移 TableConstants.CELL_ADOWN 活动单元格下移 TableConstants.CELL_INSERTROW 整行插入 TableConstants.CELL_INSERTCOL 整列插入 </pre>
<DT><B>返回:</B><DD>新插入的单元格 <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); application.workbooks.workbook.tables.Rows rows = table.getRows(); Row row = rows.getRow(2); Cells cells = row.getCells(); application.workbooks.workbook.tables.Cell beforeCell = table.getCell(2,3); application.workbooks.workbook.tables.Cell cell = cells.addCell(beforeCell, TableConstants.CELL_INSERTROW); cell.getRange().insertText("永中OFFICE"); </pre>
<DT><B>抛出:</B>
<DD><CODE><A HREF="../../../../application/exceptions/MacroRunException.html" title="application.exceptions 中的类">MacroRunException</A></CODE> - 指定单元格补齐方式常量不存在
<DD><CODE><A HREF="../../../../application/exceptions/MacroRunException.html" title="application.exceptions 中的类">MacroRunException</A></CODE> - 指定单元格对象为空<DT><B>另请参见:</B><DD><A HREF="../../../../application/workbooks/workbook/tables/Cells.html#addCells(int)"><CODE>addCells(int)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="addCells(int)"><!-- --></A><H3>
addCells</H3>
<PRE>
public <A HREF="../../../../application/workbooks/workbook/tables/Cells.html" title="application.workbooks.workbook.tables 中的类">Cells</A> <B>addCells</B>(int shiftCells)</PRE>
<DL>
<DD>根据当前指定的单元格区域插入新的单元格。插入新单元格后可选择控制如何移动活动的单元格。
<P>
<DD><DL>
<DT><B>参数:</B><DD><CODE>shiftCells</CODE> - 新单元格插入后,其他活动单元格的补齐方式,只能取以下整型值之一: <pre> TableConstants.CELL_RIGHTMOVE 活动单元格右移 TableConstants.CELL_ADOWN 活动单元格下移 TableConstants.CELL_INSERTROW 整行插入 TableConstants.CELL_INSERTCOL 整列插入 </pre>
<DT><B>返回:</B><DD>新插入的单元格集合 <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); application.workbooks.workbook.tables.Rows rows = table.getRows(); Row row = rows.getRow(2); Cells cells = row.getCells(); cells.addCells(TableConstants.CELL_INSERTROW); </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/tables/Cells.html#addCell(application.workbooks.workbook.tables.Cell, int)"><CODE>addCell(Cell, int)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="averageColumnWidth()"><!-- --></A><H3>
averageColumnWidth</H3>
<PRE>
public void <B>averageColumnWidth</B>()</PRE>
<DL>
<DD>平均分配当前指定单元格区域内所有列的列宽。 说明:平均分配后,区域内每个表格列的列宽相等并等于其平均值。 <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); application.workbooks.workbook.tables.Rows rows = table.getRows(); Row row = rows.getRow(2); Cells cells = row.getCells(); cells.averageColumnWidth(); </pre>
<P>
<DD><DL>
<DT><B>另请参见:</B><DD><A HREF="../../../../application/workbooks/workbook/tables/Cells.html#averageRowHeight()"><CODE>averageRowHeight()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="averageRowHeight()"><!-- --></A><H3>
averageRowHeight</H3>
<PRE>
public void <B>averageRowHeight</B>()</PRE>
<DL>
<DD>平均分配当前指定单元格区域内所有行的行高。 说明:平均分配后,区域内每个表格行的行高相等并等于其平均值。 <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); application.workbooks.workbook.tables.Rows rows = table.getRows(); Row row = rows.getRow(2); Cells cells = row.getCells(); cells.averageRowHeight(); </pre>
<P>
<DD><DL>
<DT><B>另请参见:</B><DD><A HREF="../../../../application/workbooks/workbook/tables/Cells.html#averageColumnWidth()"><CODE>averageColumnWidth()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="delete(int)"><!-- --></A><H3>
delete</H3>
<PRE>
public void <B>delete</B>(int shiftCells)</PRE>
<DL>
<DD>删除当前指定的单元格区域。单元格被删除后可选择控制如何移动剩余的单元格。
<P>
<DD><DL>
<DT><B>参数:</B><DD><CODE>shiftCells</CODE> - 单元格被删除后,其他活动单元格的补齐方式,只能取以下整型值之一: <pre> TableConstants.CELL_LEFTMOVE 右侧单元格左移 TableConstants.CELL_UPMOVE 下方单元格上移 TableConstants.CELL_DELROW 整行删除 TableConstants.CELL_DELCOL 整列删除 </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); application.workbooks.workbook.tables.Rows rows = table.getRows(); Row row = rows.getRow(2); Cells cells = row.getCells(); cells.delete(TableConstants.CELL_DELROW); </pre>
<DT><B>抛出:</B>
<DD><CODE><A HREF="../../../../application/exceptions/MacroRunException.html" title="application.exceptions 中的类">MacroRunException</A></CODE> - 指定参数常量不存在</DL>
</DD>
</DL>
<HR>
<A NAME="getBorderAttribute()"><!-- --></A><H3>
getBorderAttribute</H3>
<PRE>
public <A HREF="../../../../application/workbooks/workbook/style/border/BorderAttribute.html" title="application.workbooks.workbook.style.border 中的类">BorderAttribute</A> <B>getBorderAttribute</B>()</PRE>
<DL>
<DD>得到指定单元格区域的边框属性。
<P>
<DD><DL>
<DT><B>返回:</B><DD>边框属性 <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); Cells cells = table.getSelectionCells(); BorderAttribute borderAttribute = cells.getBorderAttribute(); System.out.println("返回单元格区域的边框类型为:"+ borderAttribute.getBorderType()); </pre><DT><B>另请参见:</B><DD><A HREF="../../../../application/workbooks/workbook/tables/Cells.html#setBorderAttribute(application.workbooks.workbook.style.border.BorderAttribute)"><CODE>setBorderAttribute(BorderAttribute)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="getCell(int)"><!-- --></A><H3>
getCell</H3>
<PRE>
public <A HREF="../../../../application/workbooks/workbook/tables/Cell.html" title="application.workbooks.workbook.tables 中的类">Cell</A> <B>getCell</B>(int index)</PRE>
<DL>
<DD>得到当前单元格集合中某个指定的单元格对象。
<P>
<DD><DL>
<DT><B>参数:</B><DD><CODE>index</CODE> - 单元格集合中指定单元格的索引。说明:这个索引值在单元格范围中是按行进行查找的。
<DT><B>返回:</B><DD>单个单元格对象 <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); application.workbooks.workbook.tables.Rows rows = table.getRows(); Row row = rows.getRow(2); Cells cells = row.getCells(); application.workbooks.workbook.tables.Cell cell = cells.getCell(2); cell.getRange().insertText("永中科技"); </pre></DL>
</DD>
</DL>
<HR>
<A NAME="getCellAttribute()"><!-- --></A><H3>
getCellAttribute</H3>
<PRE>
public <A HREF="../../../../application/workbooks/workbook/tables/CellAttribute.html" title="application.workbooks.workbook.tables 中的类">CellAttribute</A> <B>getCellAttribute</B>()</PRE>
<DL>
<DD>得到指定单元格区域的单元格属性。
<P>
<DD><DL>
<DT><B>返回:</B><DD>单元格属性 <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); application.workbooks.workbook.tables.Rows rows = table.getRows(); Row row = rows.getRow(2); Cells cells = row.getCells(); CellAttribute cellAttribute = cells.getCellAttribute(); System.out.println("指定单元格宽度的度量方式为:" + cellAttribute.getPreferredWidthMeasure()); System.out.println("指定单元格的宽度为:" + cellAttribute.getPreferredWidth()); </pre><DT><B>另请参见:</B><DD><A HREF="../../../../application/workbooks/workbook/tables/Cells.html#setCellAttribute(application.workbooks.workbook.tables.CellAttribute)"><CODE>setCellAttribute(CellAttribute)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="getCount()"><!-- --></A><H3>
getCount</H3>
<PRE>
public int <B>getCount</B>()</PRE>
<DL>
<DD>得到当前单元格集合中单元格的数目。
<P>
<DD><DL>
<DT><B>返回:</B><DD>单元格集合的格子总数 <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); application.workbooks.workbook.tables.Columns columns = table.getColumns(); Column column = columns.getColumn(2); Cells cells = column.getCells(); System.out.println("当前集合中单元格的总数:" + cells.getCount()); </pre></DL>
</DD>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -