2 Replies Latest reply on May 14, 2019 1:55 PM by Frank Hoffmann-colognedata

    Help on using client_ole2 on MAC OS

    myluism

      Hi all.

       

      I'm using Forms latest version.

       

      We have a client that uses MAC OS and they have a MS Office version installed on their MAC Laptops.

       

      I have create a sorf of generic procedure that looks like this:

       

      procedure proc_excel is

      --

      -- Escribe a Hoja Excel los datos de un formulario.

      --

      -- 1. Siempre imprime el registro actual de bloque principal.

      --

      -- 2. Para los bloques subsiguientes escribe TODOS los registros del bloque.

      --

      -- 3. Al finalizar cierra el archivo y llama a la hoja de cálculo definida.

      --

      --

        block_id           block;

        item_id            item;

        item_type          varchar2(40);

      v_nb_item varchar2(80);

      v_item_prompt      varchar2(500);

      v_nb_bloque varchar2(40);

      v_nb_bloque_item varchar2(80);

      v_de_item_proceso varchar2(100);

      v_contador         integer := 0;

      v_existe varchar2(1);

        v_mensaje          varchar2(1000);

        start_rec          number;

        stop_rec           number;

        skip_this_item     exception;

      j                  integer;

      k                  integer;

      v_directorio       varchar2(250);

      v_archivo_excel    varchar2(500);

      v_separador_excel  varchar2(2);

        --

      application        CLIENT_OLE2.Obj_Type;

      workbooks          CLIENT_OLE2.Obj_Type;

      workbook           CLIENT_OLE2.Obj_Type;

      worksheets         CLIENT_OLE2.Obj_Type;

      worksheet          CLIENT_OLE2.Obj_Type;

      args               CLIENT_OLE2.List_Type;

      cell               CLIENT_OLE2.Obj_Type;

      --

      begin

      --

      v_separador_excel   := client_win_api_environment.get_environment_string('CARACTER_EXCEL_DECIMAL');

      --

      set_application_property(PLSQL_DATE_FORMAT,'DD/MM/YYYY');

        set_application_property(BUILTIN_DATE_FORMAT,'DD/MM/YYYY');

      --

      if upper(webutil_clientinfo.get_operating_system) like '%WIND%'

      then

      v_archivo_excel   := client_win_api_environment.get_environment_string('USERPROFILE')||'\webFIGO.xls';

      else

      client_tool_env.getvar('$HOME',v_archivo_excel);

      v_archivo_excel   := v_archivo_excel||'/webFIGO.xls';

      end if;

      --

      application :=  CLIENT_OLE2.CREATE_OBJ('Excel.Application');

      workbooks := CLIENT_OLE2.GET_OBJ_PROPERTY(application, 'Workbooks');

      args := CLIENT_OLE2.CREATE_ARGLIST;

      CLIENT_OLE2.ADD_ARG(args,v_archivo_excel);

      workbook := CLIENT_OLE2.GET_OBJ_PROPERTY(workbooks, 'Open', args);

      CLIENT_OLE2.DESTROY_ARGLIST(args);

      worksheets:=CLIENT_OLE2.GET_OBJ_PROPERTY(workbook, 'Worksheets');

      args := CLIENT_OLE2.CREATE_ARGLIST;

      CLIENT_OLE2.ADD_ARG(args, 'Sheet1');

      CLIENT_OLE2.DESTROY_ARGLIST(args);

      worksheet:=CLIENT_OLE2.GET_OBJ_PROPERTY(workbook,'ActiveSheet');

      CLIENT_OLE2.SET_PROPERTY(application, 'Visible', 'True');

        --

        v_nb_bloque := get_form_property(:system.current_form,first_block);

      --

        j   :=1;

        k   :=1;

      --

        loop

          --

          if get_block_property(v_nb_bloque,query_data_source_name) is not null

          then

            --

            go_block(v_nb_bloque);

            block_id    := find_block(v_nb_bloque);

            v_contador  := v_contador + 1;

            --

            if v_contador = 1 then

            --

              start_rec := 1;

              stop_rec  := 1;

            --

            else

            --

              start_rec := 1;

              stop_rec  := get_block_property(block_id, query_hits);

              --

            end if;

            --

            -- Carga los datos del bloque actual a la hoja

            --

          --

            first_record;

            for i in start_rec..stop_rec loop

              --

              --  Construye Etiquetas

              --

              if i = 1

              then

              --

                v_nb_item    := v_nb_bloque || '.' || get_block_property(block_id,first_item);

                item_id      := find_item(v_nb_item);

                k            := 1;

                while v_nb_item is not null loop

                item_type  := get_item_property(item_id, datatype);

                --

                if item_type in ('LONG','GRAPHICS','IMAGE','SOUND')

                  then

                     null;

                  elsif get_item_property(v_nb_item,visible) = 'FALSE'

                  then

                  null;

                  else

              v_item_prompt := get_item_property(item_id, prompt_text);

              args:=CLIENT_OLE2.create_arglist;

            CLIENT_OLE2.add_arg(args, j);

            CLIENT_OLE2.add_arg(args, k);

            cell:=CLIENT_OLE2.get_obj_property(worksheet, 'Cells', args);

            CLIENT_OLE2.destroy_arglist(args);

            CLIENT_OLE2.set_property(cell, 'Value',nvl(v_item_prompt,' '));

            CLIENT_OLE2.release_obj(cell);

            --

            k   := k + 1;

              --

                end if;

                v_nb_item := get_item_property(item_id, nextitem);

                if v_nb_item is not null then

                  v_nb_item := v_nb_bloque || '.' || v_nb_item;

                    item_id   := find_item(v_nb_item);

                end if;

                --

                end loop;

                --

      end if;

      --       

              -- Carga Data del Bloque Actual

              --

                v_nb_item    := v_nb_bloque || '.' || get_block_property(block_id,first_item);

                item_id      := find_item(v_nb_item);

                k            := 1;

                j            := j + 1;

                while v_nb_item is not null loop

                  item_type  := get_item_property(item_id, datatype);

                  --

                  if item_type in ('LONG','GRAPHICS','IMAGE','SOUND')

                  then

                     null;

                  elsif get_item_property(v_nb_item,visible) = 'FALSE'

                  then

                  null;

                  else

            args:=CLIENT_OLE2.create_arglist;

            CLIENT_OLE2.add_arg(args, j);

            CLIENT_OLE2.add_arg(args, k);

        cell:=CLIENT_OLE2.get_obj_property(worksheet, 'Cells', args);

              CLIENT_OLE2.destroy_arglist(args);

              --

              if get_item_property(item_id, datatype) in ('MONEY'

                                                       ,'RMONEY'

                                                       ,'NUMBER'

                                                       ,'RNUMBER')

              then

              CLIENT_OLE2.set_property(cell, 'Value', nvl(replace(name_in(v_nb_item),'.',','),' ' ));

              else

              CLIENT_OLE2.set_property(cell, 'Value', nvl(name_in(v_nb_item),' ' ));

              end if;

              --

              CLIENT_OLE2.release_obj(cell);

              --

              k   := k + 1;

              --

                  end if;

                  v_nb_item := get_item_property(item_id, nextitem);

                  if v_nb_item is not null then

                     v_nb_item := v_nb_bloque || '.' || v_nb_item;

                     item_id   := find_item(v_nb_item);

                  end if;

                end loop;

                j         :=  j + 1;

                exit when :system.last_record = 'TRUE';

                next_record;

            end loop;

            --

            -- Fin carga de datos

            --

          end if;

          --

          v_nb_bloque := get_block_property(v_nb_bloque,nextblock);

          --

          exit when v_nb_bloque is null;

        end loop;

      --

      CLIENT_OLE2.Release_Obj(worksheet);

      CLIENT_OLE2.Release_Obj(worksheets);

      --

      args := CLIENT_OLE2.Create_Arglist;

      CLIENT_OLE2.Add_Arg(args,v_archivo_excel);

      CLIENT_OLE2.Invoke(workbook, 'SaveAs', args);

      CLIENT_OLE2.Destroy_Arglist(args);

      --

      CLIENT_OLE2.Release_Obj(workbook);

      CLIENT_OLE2.Release_Obj(workbooks);

      --

      --CLIENT_OLE2.Invoke(application, 'Quit');

      --CLIENT_OLE2.Release_Obj(application);

      --

        set_application_property(PLSQL_DATE_FORMAT,'DD/MM/YYYY HH24:MI:SS');

        set_application_property(BUILTIN_DATE_FORMAT,'DD/MM/YYYY HH24:MI:SS');

        --

      end;

        

      The thing is this works fine on Windows.

       

      When i try it on MAC it fails.

       

      I even put a message on the first line of procedure, but it does not get there. I fails on the declaration section. probably when it encounters the first CLIENT_OLE2 declaration.

       

      Help will be greatly appreciated.

       

      Kind regards, Luis.