use of com.jacob.com.Dispatch in project yyl_example by Relucent.
the class JacobWordEngine method setParagraphsProperties.
/**
* 设置段落格式
*
* @param alignment
* 0-左对齐, 1-右对齐, 2-右对齐, 3-两端对齐, 4-分散对齐
* @param lineSpaceingRule
* @param lineUnitBefore
* @param lineUnitAfter
* @param characterUnitFirstLineIndent
*/
public void setParagraphsProperties(int alignment, int lineSpaceingRule, int lineUnitBefore, int lineUnitAfter, int characterUnitFirstLineIndent) {
Dispatch paragraphs = Dispatch.get(selection, "Paragraphs").toDispatch();
// 对齐方式
Dispatch.put(paragraphs, "Alignment", new Variant(alignment));
// 行距
Dispatch.put(paragraphs, "LineSpacingRule", new Variant(lineSpaceingRule));
// 段前
Dispatch.put(paragraphs, "LineUnitBefore", new Variant(lineUnitBefore));
// 段后
Dispatch.put(paragraphs, "LineUnitAfter", new Variant(lineUnitAfter));
// 首行缩进字符数
Dispatch.put(paragraphs, "CharacterUnitFirstLineIndent", new Variant(characterUnitFirstLineIndent));
}
use of com.jacob.com.Dispatch in project yyl_example by Relucent.
the class JacobWordEngine method createTable.
/**
* 创建表格
*
* @param pos
* 位置
* @param cols
* 列数
* @param rows
* 行数
*/
public void createTable(String pos, int numCols, int numRows) {
if (find(pos)) {
Dispatch tables = Dispatch.get(doc, "Tables").toDispatch();
Dispatch range = Dispatch.get(selection, "Range").toDispatch();
@SuppressWarnings("unused") Dispatch newTable = Dispatch.call(tables, "Add", range, new Variant(numRows), new Variant(numCols), new Variant(1)).toDispatch();
Dispatch.call(selection, "MoveRight");
} else {
Dispatch tables = Dispatch.get(doc, "Tables").toDispatch();
Dispatch range = Dispatch.get(selection, "Range").toDispatch();
@SuppressWarnings("unused") Dispatch newTable = Dispatch.call(tables, "Add", range, new Variant(numRows), new Variant(numCols), new Variant(1)).toDispatch();
Dispatch.call(selection, "MoveRight");
}
}
use of com.jacob.com.Dispatch in project yyl_example by Relucent.
the class JacobWordEngine method setCellVerticalAlign.
/**
* 设置选定单元格的垂直对起方式, 请使用setTableCellSelected选中一个单元格
*
* @param align
* 0-顶端, 1-居中, 3-底端
*/
public void setCellVerticalAlign(int verticalAlign) {
Dispatch cells = Dispatch.get(selection, "Cells").toDispatch();
Dispatch.put(cells, "VerticalAlignment", new Variant(verticalAlign));
}
use of com.jacob.com.Dispatch in project yyl_example by Relucent.
the class JacobWordEngine method autoFitTable.
/**
* 自动调整表格
*
*/
public void autoFitTable() {
Dispatch tables = Dispatch.get(doc, "Tables").toDispatch();
int count = Dispatch.get(tables, "Count").getInt();
for (int i = 0; i < count; i++) {
Dispatch table = Dispatch.call(tables, "Item", new Variant(i + 1)).toDispatch();
Dispatch cols = Dispatch.get(table, "Columns").toDispatch();
Dispatch.call(cols, "AutoFit");
}
}
use of com.jacob.com.Dispatch in project yyl_example by Relucent.
the class JacobWordEngine method addLastTableRow.
/**
* 在最后1行前增加一行
*
* @param tableIndex
* word文档中的第N张表(从1开始)
*/
public void addLastTableRow(int tableIndex) {
// 所有表格
Dispatch tables = Dispatch.get(doc, "Tables").toDispatch();
// 要填充的表格
Dispatch table = Dispatch.call(tables, "Item", new Variant(tableIndex)).toDispatch();
// 表格的所有行
Dispatch rows = Dispatch.get(table, "Rows").toDispatch();
Dispatch row = Dispatch.get(rows, "Last").toDispatch();
Dispatch.call(rows, "Add", new Variant(row));
}
Aggregations