Examples of Dispatch


Examples of com.jacob.com.Dispatch

      ActiveXComponent excel = new ActiveXComponent("Excel.Application");

      try {

        excel.setProperty("Visible", false);
        Dispatch workbooks = excel.getProperty("Workbooks")
            .toDispatch();

        Dispatch workbook = Dispatch.call(workbooks, "Open", path, // FileName
            3, // UpdateLinks
            false, // Readonly
            5, // Format
            password // Password
            ).toDispatch();

        Dispatch sheets = Dispatch.call(workbook, "Worksheets")
            .toDispatch();
        System.out.println("Before executa");
        executa(excel, sheets);
        System.out.println("After executa");
View Full Code Here

Examples of com.jacob.com.Dispatch

     *            valor a ser escrito na celula
     */
    public void informarValorCelula(String celula, Dispatch sheet,
        String valor) {
      System.out.println("Entered informarValorCelula");
      Dispatch cel = obterCelula(celula, sheet);
      Dispatch.put(cel, "Value", valor);
      System.out.println("Exiting informarValorCelula");
    }
View Full Code Here

Examples of com.jacob.com.Dispatch

     *            pasta da planilha que cont�m a c�lula
     * @return - conte�do da propriedade Value
     */
    public Variant obterValorCelula(String celula, Dispatch sheet) {
      System.out.println("Entered obterValorCelula");
      Dispatch d = obterCelula(celula, sheet);
      Variant returnedValue = Dispatch.get(d, "Value");
      System.out.println("Exiting obterValorCelula");
      return returnedValue;
    }
View Full Code Here

Examples of com.jacob.com.Dispatch

     * @return - referencia para um c�lula ou conjunto de c�lulas,
     *         dependendo do par�metro passado
     */
    public Dispatch obterCelula(String celula, Dispatch sheet) {
      System.out.println("Entered obterCelula");
      Dispatch d = Dispatch.invoke(sheet, "Range", Dispatch.Get,
          new Object[] { celula }, new int[1]).toDispatch();
      System.out.println("Exiting obterCelula");
      return d;
    }
View Full Code Here

Examples of com.jacob.com.Dispatch

     *            Referencia para conjunto de pastas da planilha
     */
    public void executa(ActiveXComponent xl, Dispatch sheets) {

      System.out.println("Entered private ExcellCallBack executa()");
      Dispatch sheet = Dispatch.call(sheets, "Item", "Plan1")
          .toDispatch();
      columnA = obterValoresRange("A1:A50", sheet);
      columnB = obterValoresRange("B1:B40", sheet);
      System.out.println("Exiting private ExcellCallBack executa()");
    }
View Full Code Here

Examples of com.jacob.com.Dispatch

        .invoke("ExecQuery", new Variant(query));

    EnumVariant enumVariant = new EnumVariant(vCollection.toDispatch());

    String resultString = "";
    Dispatch item = null;

    while (enumVariant.hasMoreElements()) {
      resultString = "";
      item = enumVariant.nextElement().toDispatch();
      String categoryString = Dispatch.call(item, "CategoryString")
View Full Code Here

Examples of com.jacob.com.Dispatch

   * ----------------------------------------------------------------------------------------------------------------------------
   */
  public void testLeakWithSetString() {

    ActiveXComponent xl = null;
    Dispatch workbooks = null;
    Dispatch workbook = null;
    Dispatch workSheets = null;
    Dispatch sheet = null;
    Dispatch tabCells = null;
    SafeArray sa = null;

    // -Dcom.jacob.autogc=true
    System.out.println("Jacob version: " + JacobReleaseInfo.getBuildVersion());

    for (int t = 0; t < 10; t++) {
      // look at a large range of cells
      String position = "A7:DM8934";

      try {
        xl = new ActiveXComponent("Excel.Application");
        System.out
            .println("Excel version=" + xl.getProperty("Version"));

        xl.setProperty("Visible", new Variant(false));
        workbooks = xl.getProperty("Workbooks").toDispatch();

        workbook = Dispatch.get(workbooks, "Add").toDispatch();

        workSheets = Dispatch.get(workbook, "Worksheets").toDispatch();

        sheet = Dispatch.get(workbook, "ActiveSheet").toDispatch();
        // grab the whole range specified above.
        tabCells = Dispatch.invoke(sheet, "Range", Dispatch.Get,
            new Object[] { position }, new int[1]).toDispatch();

        sa = Dispatch.get(tabCells, "Value").toSafeArray(true);

        System.out.println("Ub0=" + sa.getUBound(1)); // nbCol
        System.out.println("Ub1=" + sa.getUBound(2)); // nbLgn

        // number of rows
        int nbLgn = sa.getUBound(2);
        // number of columns
        int nbCol = sa.getUBound(1);

        int[] colLgn = new int[] { 0, 0 };

        // now set a value on every cell in the range we retrieved
        for (int i = 1; i <= nbLgn; i++) {
          colLgn[1] = i;

          for (int j = 1; j <= nbCol; j++) {
            colLgn[0] = j;
            // this one works with out a leak 1.13-M3
            // sa.setString(j, i, "test");
            // This one leaks with 1.13-M3 and earlier
            sa.setString(colLgn, "test");
          }
        }

        Dispatch.put(tabCells, "Value", sa);

        Variant f = new Variant(false);
        Dispatch.call(workbook, "Close", f);
        System.out.println("Close");
      } catch (Exception e) {
        e.printStackTrace();
      } finally {

        if (sa != null) {
          try {
            sa.safeRelease();
          } catch (Exception e) {
            e.printStackTrace();
          } finally {
            sa = null;
          }
        }

        if (tabCells != null) {
          try {
            tabCells.safeRelease();
          } catch (Exception e) {
            e.printStackTrace();
          } finally {
            tabCells = null;
          }
View Full Code Here

Examples of com.jacob.com.Dispatch

      // put the variant in the array
      sa.setVariant(0, v);

      // take it back out
      Variant v2 = sa.getVariant(0);
      Dispatch d = v2.toDispatch();

      // make sure you can call eval on it
      result = Dispatch.call(d, "Eval", scriptCommand);
      assertTrue(result.toString().equals("6"));
    } catch (ComException e) {
View Full Code Here

Examples of com.jacob.com.Dispatch

   * behavior if someone hits the cancel button
   *
   */
  public void testPrintDialog() {
    ActiveXComponent oActiveX = new ActiveXComponent("Visio.Application");
    Dispatch oDocuments = oActiveX.getProperty("Documents").toDispatch();
    // create a blank document
    Dispatch.call(oDocuments, "Add", "");
    try {
      Dispatch.call(oActiveX, "DoCmd", new Integer(1010)).getInt();
      System.out.println("User hit the ok button.");
View Full Code Here

Examples of com.jacob.com.Dispatch

    // Create a Dispatch Parameter to hide the document that is opened
    Dispatch.put(wordObject, "Visible", new Variant(false));

    // Instantiate the Documents Property
    Dispatch documents = objWord.getProperty("Documents").toDispatch();

    // Open a word document, Current Active Document
    document = Dispatch.call(documents, "Open", filename).toDispatch();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.