Search in sources :

Example 26 with Dispatch

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));
}
Also used : Variant(com.jacob.com.Variant) Dispatch(com.jacob.com.Dispatch)

Example 27 with Dispatch

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");
    }
}
Also used : Variant(com.jacob.com.Variant) Dispatch(com.jacob.com.Dispatch)

Example 28 with Dispatch

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));
}
Also used : Variant(com.jacob.com.Variant) Dispatch(com.jacob.com.Dispatch)

Example 29 with Dispatch

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");
    }
}
Also used : Variant(com.jacob.com.Variant) Dispatch(com.jacob.com.Dispatch)

Example 30 with Dispatch

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));
}
Also used : Variant(com.jacob.com.Variant) Dispatch(com.jacob.com.Dispatch)

Aggregations

Dispatch (com.jacob.com.Dispatch)50 Variant (com.jacob.com.Variant)45 ComFailException (com.jacob.com.ComFailException)19 ActiveXComponent (com.jacob.activeX.ActiveXComponent)18 Message (de.janrufmonitor.exception.Message)13 ICallerList (de.janrufmonitor.framework.ICallerList)13 ZipArchiveException (de.janrufmonitor.repository.zip.ZipArchiveException)13 SQLException (java.sql.SQLException)13 ArrayList (java.util.ArrayList)13 List (java.util.List)13 IAttribute (de.janrufmonitor.framework.IAttribute)8 File (java.io.File)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 ICaller (de.janrufmonitor.framework.ICaller)1 IMultiPhoneCaller (de.janrufmonitor.framework.IMultiPhoneCaller)1 IPhonenumber (de.janrufmonitor.framework.IPhonenumber)1 UUID (de.janrufmonitor.util.uuid.UUID)1 Properties (java.util.Properties)1