Search in sources :

Example 6 with Variant

use of com.jacob.com.Variant 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)

Example 7 with Variant

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

the class JacobWordEngine method copyImageFromAnotherDoc.

/**
   * 在当前文档指定的位置拷贝来自另一个文档中的图片
   * 
   * @param anotherDocPath
   *        另一个文档的磁盘路径
   * @param shapeIndex
   *        被拷贝的图片在另一格文档中的位置
   * @param pos
   *        当前文档指定的位置
   */
public void copyImageFromAnotherDoc(String anotherDocPath, int shapeIndex, String pos) {
    Dispatch doc2 = null;
    try {
        doc2 = Dispatch.call(documents, "Open", anotherDocPath).toDispatch();
        Dispatch shapes = Dispatch.get(doc2, "InLineShapes").toDispatch();
        Dispatch shape = Dispatch.call(shapes, "Item", new Variant(shapeIndex)).toDispatch();
        Dispatch imageRange = Dispatch.get(shape, "Range").toDispatch();
        Dispatch.call(imageRange, "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 8 with Variant

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

the class JacobWordEngine method setFont.

/**
   * 设置当前选定内容的字体
   * 
   * @param boldSize
   * @param italicSize
   * @param underLineSize
   *        下划线
   * @param colorSize
   *        字体颜色
   * @param size
   *        字体大小
   * @param name
   *        字体名称
   */
public void setFont(boolean bold, boolean italic, boolean underLine, String size, String name) {
    Dispatch font = Dispatch.get(selection, "Font").toDispatch();
    Dispatch.put(font, "Name", new Variant(name));
    Dispatch.put(font, "Bold", new Variant(bold));
    Dispatch.put(font, "Italic", new Variant(italic));
    Dispatch.put(font, "Underline", new Variant(underLine));
    Dispatch.put(font, "Size", size);
}
Also used : Variant(com.jacob.com.Variant) Dispatch(com.jacob.com.Dispatch)

Example 9 with Variant

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

the class JacobWordEngine method setApplyTableFormat.

/**
   * 设置当前文档中所有表格水平居中方式及其它一些格式,用在将word文件转化为html中,针对申报表
   */
public void setApplyTableFormat() {
    Dispatch tables = Dispatch.get(doc, "Tables").toDispatch();
    // System.out.println(tabCount);
    int tabCount = Integer.valueOf(Dispatch.get(tables, "Count").toString());
    System.out.println("*******************************************************");
    for (int i = 1; i <= tabCount; i++) {
        Dispatch table = Dispatch.call(tables, "Item", new Variant(i)).toDispatch();
        Dispatch rows = Dispatch.get(table, "Rows").toDispatch();
        if (i == 1) {
            // 1-居中,2-Right
            Dispatch.put(rows, "Alignment", new Variant(2));
            continue;
        }
        // 1-居中
        Dispatch.put(rows, "Alignment", new Variant(1));
        // 设置自动调整表格方式,1-根据窗口自动调整
        Dispatch.call(table, "AutoFitBehavior", new Variant(1));
        Dispatch.put(table, "PreferredWidthType", new Variant(1));
        Dispatch.put(table, "PreferredWidth", new Variant(700));
        System.out.println(Dispatch.get(rows, "HeightRule").toString());
        // 0-自动wdRowHeightAuto,1-最小值wdRowHeightAtLeast,
        Dispatch.put(rows, "HeightRule", new Variant(1));
        // 2-固定wdRowHeightExactly
        Dispatch.put(rows, "Height", new Variant(0.04 * 28.35));
    // int oldAlign = Integer.valueOf(Dispatch.get(rows,
    // "Alignment").toString());
    // System.out.println("Algin:" + oldAlign);
    }
}
Also used : Variant(com.jacob.com.Variant) Dispatch(com.jacob.com.Dispatch)

Example 10 with Variant

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

the class JacobWordEngine method addRow.

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

Aggregations

Variant (com.jacob.com.Variant)100 Dispatch (com.jacob.com.Dispatch)45 ActiveXComponent (com.jacob.activeX.ActiveXComponent)18 ComFailException (com.jacob.com.ComFailException)17 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)6 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 SafeArray (com.jacob.com.SafeArray)1 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