Search in sources :

Example 1 with Dispatch

use of com.jacob.com.Dispatch in project yyl_example by Relucent.

the class JacobWordEngine method addLastTableCol.

/**
   * 在最后一列前增加一列
   * 
   * @param tableIndex
   *        word文档中的第N张表(从1开始)
   */
public void addLastTableCol(int tableIndex) {
    Dispatch tables = Dispatch.get(doc, "Tables").toDispatch();
    // 要填充的表格
    Dispatch table = Dispatch.call(tables, "Item", new Variant(tableIndex)).toDispatch();
    // 表格的所有行
    Dispatch cols = Dispatch.get(table, "Columns").toDispatch();
    Dispatch col = Dispatch.get(cols, "Last").toDispatch();
    Dispatch.call(cols, "Add", col).toDispatch();
    Dispatch.call(cols, "AutoFit");
}
Also used : Variant(com.jacob.com.Variant) Dispatch(com.jacob.com.Dispatch)

Example 2 with Dispatch

use of com.jacob.com.Dispatch in project yyl_example by Relucent.

the class JacobWordEngine method copyTableFromAnotherDoc.

/**
   * 在当前文档指定的位置拷贝来自另一个文档中的表格
   * 
   * @param anotherDocPath
   *        另一个文档的磁盘路径
   * @param tableIndex
   *        被拷贝的表格在另一格文档中的位置
   * @param pos
   *        当前文档指定的位置
   */
public void copyTableFromAnotherDoc(String anotherDocPath, int tableIndex, String pos) {
    Dispatch doc2 = null;
    try {
        doc2 = Dispatch.call(documents, "Open", anotherDocPath).toDispatch();
        // 所有表格
        Dispatch tables = Dispatch.get(doc2, "Tables").toDispatch();
        // 要填充的表格
        Dispatch table = Dispatch.call(tables, "Item", new Variant(tableIndex)).toDispatch();
        Dispatch range = Dispatch.get(table, "Range").toDispatch();
        Dispatch.call(range, "Copy");
        if (this.find(pos)) {
            Dispatch textRange = Dispatch.get(selection, "Range").toDispatch();
            Dispatch.call(textRange, "Paste");
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if (doc2 != null) {
            Dispatch.call(doc2, "Close", new Variant(saveOnExit));
            doc2 = null;
        }
    }
}
Also used : Variant(com.jacob.com.Variant) Dispatch(com.jacob.com.Dispatch)

Example 3 with Dispatch

use of com.jacob.com.Dispatch in project yyl_example by Relucent.

the class JacobWordEngine method callWordMacro.

/**
   * 调用word里的宏以调整表格的宽度,其中宏保存在document下
   * 
   */
public void callWordMacro() {
    Dispatch tables = Dispatch.get(doc, "Tables").toDispatch();
    int count = Dispatch.get(tables, "Count").getInt();
    Variant vMacroName = new Variant("Normal.NewMacros.tableFit");
    @SuppressWarnings("unused") Variant vParam = new Variant("param1");
    @SuppressWarnings("unused") Variant[] para = new Variant[] { vMacroName };
    for (int i = 0; i < count; i++) {
        Dispatch table = Dispatch.call(tables, "Item", new Variant(i + 1)).toDispatch();
        Dispatch.call(table, "Select");
        Dispatch.call(word, "Run", "tableFitContent");
    }
}
Also used : Variant(com.jacob.com.Variant) Dispatch(com.jacob.com.Dispatch)

Example 4 with Dispatch

use of com.jacob.com.Dispatch in project yyl_example by Relucent.

the class JacobWordEngine method addFirstTableRow.

/**
   * 在第1行前增加一行
   * 
   * @param tableIndex
   *        word文档中的第N张表(从1开始)
   */
public void addFirstTableRow(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, "First").toDispatch();
    Dispatch.call(rows, "Add", new Variant(row));
}
Also used : Variant(com.jacob.com.Variant) Dispatch(com.jacob.com.Dispatch)

Example 5 with Dispatch

use of com.jacob.com.Dispatch in project yyl_example by Relucent.

the class JacobWordEngine method addTableRow.

/**
   * 在指定行前面增加行
   * 
   * @param tableIndex
   *        word文件中的第N张表(从1开始)
   * @param rowIndex
   *        指定行的序号(从1开始)
   */
public void addTableRow(int tableIndex, int rowIndex) {
    // 所有表格
    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.call(rows, "Item", new Variant(rowIndex)).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