Search in sources :

Example 61 with Variant

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

the class JacobWordEngine method copyTable.

/**
   * 在当前文档指定的位置拷贝表格
   * 
   * @param pos
   *        当前文档指定的位置
   * @param tableIndex
   *        被拷贝的表格在word文档中所处的位置
   */
public void copyTable(String pos, int tableIndex) {
    // 所有表格
    Dispatch tables = Dispatch.get(doc, "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");
    }
}
Also used : Variant(com.jacob.com.Variant) Dispatch(com.jacob.com.Dispatch)

Example 62 with Variant

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

the class JacobWordEngine method addFirstTableCol.

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

Example 63 with Variant

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

the class JacobWordEngine method setHeaderContent.

/**
   * 设置页眉文字
   * 
   * @param cont
   * @return
   * 
   *         Sub AddHeaderText() '设置页眉或页脚中的文字 '由 Headers、Footers 和
   *         HeaderFooter 属性返回 HeaderFooter 对象。下列示例更改当前页眉中的文字。 With
   *         ActiveDocument.ActiveWindow.View .SeekView =
   *         wdSeekCurrentPageHeader Selection.HeaderFooter.Range.Text =
   *         "Header text" .SeekView = wdSeekMainDocument End With End Sub
   */
public void setHeaderContent(String cont) {
    Dispatch activeWindow = Dispatch.get(doc, "ActiveWindow").toDispatch();
    Dispatch view = Dispatch.get(activeWindow, "View").toDispatch();
    // Dispatch seekView = Dispatch.get(view, "SeekView").toDispatch();
    // wdSeekCurrentPageHeader-9
    Dispatch.put(view, "SeekView", new Variant(9));
    Dispatch headerFooter = Dispatch.get(selection, "HeaderFooter").toDispatch();
    Dispatch range = Dispatch.get(headerFooter, "Range").toDispatch();
    Dispatch.put(range, "Text", new Variant(cont));
    // String content = Dispatch.get(range, "Text").toString();
    Dispatch font = Dispatch.get(range, "Font").toDispatch();
    Dispatch.put(font, "Name", new Variant("宋体 (中文正文)"));
    Dispatch.put(font, "Bold", new Variant(false));
    // Dispatch.put(font, "Italic", new Variant(true));
    // Dispatch.put(font, "Underline", new Variant(true));
    Dispatch.put(font, "Size", 9);
    // wdSeekMainDocument-0恢复视图;
    Dispatch.put(view, "SeekView", new Variant(0));
}
Also used : Variant(com.jacob.com.Variant) Dispatch(com.jacob.com.Dispatch)

Example 64 with Variant

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

the class JacobWordEngine method getTxtFromCell.

/**
   * 获得指定的单元格里数据
   * 
   * @param tableIndex
   * @param cellRowIdx
   * @param cellColIdx
   * @return
   */
public String getTxtFromCell(int tableIndex, int cellRowIdx, int cellColIdx) {
    // 所有表格
    Dispatch tables = Dispatch.get(doc, "Tables").toDispatch();
    // 要填充的表格
    Dispatch table = Dispatch.call(tables, "Item", new Variant(tableIndex)).toDispatch();
    Dispatch cell = Dispatch.call(table, "Cell", new Variant(cellRowIdx), new Variant(cellColIdx)).toDispatch();
    Dispatch.call(cell, "Select");
    String ret = "";
    ret = Dispatch.get(selection, "Text").toString();
    // 去掉最后的回车符;
    ret = ret.substring(0, ret.length() - 1);
    return ret;
}
Also used : Variant(com.jacob.com.Variant) Dispatch(com.jacob.com.Dispatch)

Example 65 with Variant

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

the class JacobWordEngine method mergeCell.

/**
   * 合并当前表格指定的单元格 如果需要一次合并几个单元格只需要指出第一个单元格和最后一个单元格
   * 
   * @param fstCellRowIndex
   *        第一个单元格的行索引
   * @param fstCellColIndex
   *        第一个单元格的列索引
   * @param secCellRowIndex
   *        第二个单元格的行索引
   * @param secCellColIndex
   *        第二个单元格的列索引
   */
public void mergeCell(int tableIndex, int fstCellRowIdx, int fstCellColIdx, int secCellRowIdx, int secCellColIdx) {
    // 所有表格
    Dispatch tables = Dispatch.get(doc, "Tables").toDispatch();
    // 要填充的表格
    Dispatch table = Dispatch.call(tables, "Item", new Variant(tableIndex)).toDispatch();
    Dispatch fstCell = Dispatch.call(table, "Cell", new Variant(fstCellRowIdx), new Variant(fstCellColIdx)).toDispatch();
    Dispatch secCell = Dispatch.call(table, "Cell", new Variant(secCellRowIdx), new Variant(secCellColIdx)).toDispatch();
    Dispatch.call(fstCell, "Merge", secCell);
}
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