Search in sources :

Example 66 with Variant

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

the class JacobWordEngine method putTxtToCell.

/**
   * 在指定的单元格里填写数据
   * 
   * @param tableIndex
   * @param cellRowIdx
   * @param cellColIdx
   * @param txt
   */
public void putTxtToCell(int tableIndex, int cellRowIdx, int cellColIdx, String txt) {
    // 所有表格
    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");
    Dispatch.put(selection, "Text", txt);
}
Also used : Variant(com.jacob.com.Variant) Dispatch(com.jacob.com.Dispatch)

Example 67 with Variant

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

the class JacobWordEngine method getParagraphs.

/**
   * 读取文档中第paragraphsIndex段文字的内容;
   * 
   * @param paragraphsIndex
   * @return
   */
public String getParagraphs(int paragraphsIndex) {
    String ret = "";
    // 所有段落
    Dispatch paragraphs = Dispatch.get(doc, "Paragraphs").toDispatch();
    // 一共的段落数
    int paragraphCount = Dispatch.get(paragraphs, "Count").getInt();
    Dispatch paragraph = null;
    Dispatch range = null;
    if (paragraphCount > paragraphsIndex && 0 < paragraphsIndex) {
        paragraph = Dispatch.call(paragraphs, "Item", new Variant(paragraphsIndex)).toDispatch();
        range = Dispatch.get(paragraph, "Range").toDispatch();
        ret = Dispatch.get(range, "Text").toString();
    }
    return ret;
}
Also used : Variant(com.jacob.com.Variant) Dispatch(com.jacob.com.Dispatch)

Example 68 with Variant

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

the class JacobWordEngine method addCol.

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

Example 69 with Variant

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

the class ActiveXComponentDemo method main.

public static void main(String[] s) {
    ActiveXComponent sC = new ActiveXComponent("ScriptControl");
    Dispatch sControl = sC.getObject();
    Dispatch.put(sControl, "Language", "VBScript");
    // use COM component in same thread
    Variant v = Dispatch.call(sControl, "Eval", "1+2*3");
    System.out.println(v.toString());
}
Also used : Variant(com.jacob.com.Variant) ActiveXComponent(com.jacob.activeX.ActiveXComponent) Dispatch(com.jacob.com.Dispatch)

Example 70 with Variant

use of com.jacob.com.Variant in project janrufmonitor by tbrandt77.

the class OutlookContactProxy method createContact.

public synchronized void createContact(ICaller c) throws OutlookContactProxyException {
    ActiveXComponent outlook = new ActiveXComponent("Outlook.Application");
    Dispatch mapiNS = null;
    Dispatch contactsFolder = null;
    Dispatch contactsSubFolder = null;
    Dispatch items = null;
    try {
        if (this.m_logger.isLoggable(Level.INFO))
            this.m_logger.info("created Outlook.Application dispatch");
        if (this.m_logger.isLoggable(Level.INFO))
            this.m_logger.info("Microsoft Outlook version: " + Dispatch.get(outlook.getObject(), "Version"));
        mapiNS = outlook.getProperty("Session").toDispatch();
        if (this.m_logger.isLoggable(Level.INFO))
            this.m_logger.info("Microsoft Outlook namespace: " + mapiNS);
        Variant contactsVariant = new Variant(10);
        contactsFolder = Dispatch.call(mapiNS, "GetDefaultFolder", contactsVariant).toDispatch();
        if (this.m_logger.isLoggable(Level.INFO))
            this.m_logger.info("Microsoft Outlook folder: " + contactsFolder);
        contactsVariant.safeRelease();
        String folder = this.getAttribute(c.getAttribute(IJAMConst.ATTRIBUTE_NAME_CATEGORY));
        items = this.getItemsOfFolder(contactsFolder, folder, true);
        if (items == null)
            throw new OutlookContactProxyException("Error in Application Outlook. Folder <" + folder + "> could not be created");
        Dispatch newContact = Dispatch.call(items, "Add").toDispatch();
        boolean business = (c.getAttribute("outlook.business") != null && c.getAttribute("outlook.business").getValue().equalsIgnoreCase("true") ? true : false);
        this.setContactData(newContact, c, business);
        if (newContact != null)
            newContact.safeRelease();
        if (this.m_logger.isLoggable(Level.INFO)) {
            this.m_logger.info("Added new outlook contact in folder " + (folder.length() > 0 ? folder : "<root>") + ": " + c);
        }
    } catch (ComFailException ex) {
        throw new OutlookContactProxyException("Error in Application Outlook.", ex);
    } catch (Exception ex) {
        throw new OutlookContactProxyException("Error in Application Outlook.", ex);
    } finally {
        // added 2006/02/05: clean outlook references
        if (items != null)
            items.safeRelease();
        if (contactsFolder != null)
            contactsFolder.safeRelease();
        if (contactsSubFolder != null)
            contactsSubFolder.safeRelease();
        if (mapiNS != null)
            mapiNS.safeRelease();
        if (outlook != null)
            outlook.safeRelease();
    }
}
Also used : Variant(com.jacob.com.Variant) ActiveXComponent(com.jacob.activeX.ActiveXComponent) Dispatch(com.jacob.com.Dispatch) ComFailException(com.jacob.com.ComFailException) ZipArchiveException(de.janrufmonitor.repository.zip.ZipArchiveException) SQLException(java.sql.SQLException) ComFailException(com.jacob.com.ComFailException)

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