use of com.jacob.com.Variant 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.Variant in project yyl_example by Relucent.
the class JacobWordEngine method closeDocument.
/**
* 关闭当前word文档
*/
public void closeDocument() {
if (doc != null) {
Dispatch.call(doc, "Save");
Dispatch.call(doc, "Close", new Variant(saveOnExit));
doc = null;
}
}
use of com.jacob.com.Variant 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.Variant 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.Variant 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