Home » Developer & Programmer » Forms » Not able to download Excel data from Oracle 10G with Window Server (Oracle 10G, Forms, Window Server 2012 R2)
Not able to download Excel data from Oracle 10G with Window Server [message #628181] Thu, 20 November 2014 20:24 Go to next message
praveenjin@gmail.com
Messages: 10
Registered: November 2014
Location: India
Junior Member
Hello Team/friends,

I'm using 'ole2' utility to download an excel file from Oracle form 10G client.

I am sharing the code Which I'm using to download excel file. Currently this code is working on my local computer (OS: Window 7) to download excel but after I migrated to MS SERVER 2012 R2 it is not working.

Can someone help me understand why it is not working?

Here is the code for reference and any help is greatly appreciate it..
PROCEDURE fpr_forms_to_excel (
   p_block_name   IN   VARCHAR2 DEFAULT NAME_IN ('system.current_block'),
   p_path         IN   VARCHAR2 DEFAULT 'C:\',
   p_file_name    IN   VARCHAR2 DEFAULT 'Temp'
)
IS
-- Declare the OLE objects
   application   ole2.obj_type;
   workbooks     ole2.obj_type;
   workbook      ole2.obj_type;
   worksheets    ole2.obj_type;
   worksheet     ole2.obj_type;
   cell          ole2.obj_type;
   RANGE         ole2.obj_type;
   range_col     ole2.obj_type;
   -- Declare handles to OLE argument lists
   args          ole2.list_type;
   arglist       ole2.list_type;
   -- Declare form and block items
   form_name     VARCHAR2 (100);
   f_block       VARCHAR2 (100);
   l_block       VARCHAR2 (100);
   f_item        VARCHAR2 (100);
   l_item        VARCHAR2 (100);
   cur_block     VARCHAR2 (100)  := NAME_IN ('system.current_block');
   cur_item      VARCHAR2 (100);
   cur_record    VARCHAR2 (100);
   item_name     VARCHAR2 (100);
   baslik        VARCHAR2 (100);
   row_n         NUMBER;
   col_n         NUMBER;
   filename      VARCHAR2 (1000) := p_path || p_file_name;
   excelfontid   ole2.list_type;
   v_file_name		varchar2(1000);
BEGIN
   -- Start Excel
   application := ole2.create_obj ('Excel.Application');
   ole2.set_property (application, 'Visible', 'False');
   -- Return object handle to the Workbooks collection
   workbooks := ole2.get_obj_property (application, 'Workbooks');
   -- Add a new Workbook object to the Workbooks collection
   workbook := ole2.get_obj_property (workbooks, 'Add');
   -- Return object handle to the Worksheets collection for the Workbook
   worksheets := ole2.get_obj_property (workbook, 'Worksheets');
   -- Get the first Worksheet in the Worksheets collection
   -- worksheet:=OLE2.GET_OBJ_PROPERTY(worksheets,'Add');
   args := ole2.create_arglist;
   ole2.add_arg (args, 1);
   worksheet := ole2.get_obj_property (worksheets, 'Item', args);
   ole2.destroy_arglist (args);
   -- Return object handle to cell A1 on the new Worksheet
   GO_BLOCK (p_block_name);
   baslik := GET_BLOCK_PROPERTY (p_block_name, first_item);
   --commented to consider the second item as the first item
   f_item :=
         p_block_name || '.' || GET_BLOCK_PROPERTY (p_block_name, first_item);
   --in order to skip the old filename in the excel file
   l_item :=
          p_block_name || '.' || GET_BLOCK_PROPERTY (p_block_name, last_item);
   FIRST_RECORD;

   LOOP
      item_name := f_item;
      row_n := NAME_IN ('SYSTEM.CURSOR_RECORD');
      col_n := 1;

      LOOP
         IF     GET_ITEM_PROPERTY (item_name, item_type) <> 'BUTTON'
            AND GET_ITEM_PROPERTY (item_name, visible) = 'TRUE'
           -- AND GET_ITEM_PROPERTY (item_name,item_name) <> 'TOTAL_AMOUNT'
                     THEN
            -- Set first row with the item names
            IF row_n = 1
            THEN
               args := ole2.create_arglist;
               ole2.add_arg (args, 1);
               ole2.add_arg (args, col_n);
               cell := ole2.get_obj_property (worksheet, 'Cells', args);
               ole2.destroy_arglist (args);
               --cell_value := OLE2.get_char_property(cell, 'Value');
               excelfontid := ole2.get_obj_property (cell, 'Font');
               ole2.set_property (excelfontid, 'Bold', 'True');
--------------------------------------------
               baslik :=
                     NVL (GET_ITEM_PROPERTY (item_name, prompt_text), baslik);
               args := ole2.create_arglist;
               ole2.add_arg (args, row_n);
               ole2.add_arg (args, col_n);
               cell := ole2.get_obj_property (worksheet, 'Cells', args);
               ole2.destroy_arglist (args);
               ole2.set_property (cell, 'Value', baslik);
               ole2.RELEASE_OBJ (cell);
            END IF;

            -- Set other rows with the item values
            args := ole2.create_arglist;
            ole2.add_arg (args, row_n + 1);
            ole2.add_arg (args, col_n);
            cell := ole2.get_obj_property (worksheet, 'Cells', args);
            ole2.destroy_arglist (args);

            IF GET_ITEM_PROPERTY (item_name, datatype) <> 'NUMBER'
            THEN
               ole2.set_property (cell, 'NumberFormat', '@');
            END IF;

            ole2.set_property (cell, 'Value', NAME_IN (item_name));
            ole2.RELEASE_OBJ (cell);
         END IF;

         IF item_name ='XXEBS_MONTH_END_DETAILS_V.REPORTED_HOURS_HANDLER' -- l_item
         THEN         
          
             EXIT;
         END IF;

         baslik := GET_ITEM_PROPERTY (item_name, nextitem);
         item_name :=
                p_block_name || '.' || GET_ITEM_PROPERTY (item_name, nextitem);
         col_n := col_n + 1;
      END LOOP;

      EXIT
      WHEN NAME_IN ('system.last_record') = 'TRUE';
      
      NEXT_RECORD;
   END LOOP;

   -- Autofit columns
   RANGE := ole2.get_obj_property (worksheet, 'UsedRange');
   range_col := ole2.get_obj_property (RANGE, 'Columns');
   ole2.invoke (range_col, 'AutoFit');
   ole2.RELEASE_OBJ (RANGE);
   ole2.RELEASE_OBJ (range_col);

   -- Save as worksheet with a Specified file path & name.
   IF NVL (filename, '0') <> '0'
   THEN
      args := ole2.create_arglist;
      ole2.add_arg (args, filename);
      ole2.invoke (worksheet, 'SaveAs', args);
      ole2.destroy_arglist (args);
   END IF;


Message ('File has been generated at C:\UL_DATA\'||:global.file_name);
Message ('File has been generated at C:\UL_DATA\'||:global.file_name);
   --     Release the OLE objects
   ole2.RELEASE_OBJ (worksheet);
   ole2.RELEASE_OBJ (worksheets);
   ole2.RELEASE_OBJ (workbook);
   ole2.RELEASE_OBJ (workbooks);
   ole2.invoke (application, 'Quit');
   ole2.RELEASE_OBJ (application);
-- Focus to the original location
EXCEPTION
   WHEN OTHERS
   THEN
      NULL;
      RAISE form_trigger_failure;
END;
 


[EDITED by LF: applied [code] tags]

[Updated on: Mon, 24 November 2014 15:15] by Moderator

Report message to a moderator

Re: Not able to download Excel data from Oracle 10G with Window Server [message #628184 is a reply to message #628181] Fri, 21 November 2014 00:41 Go to previous messageGo to next message
praveenjin@gmail.com
Messages: 10
Registered: November 2014
Location: India
Junior Member
Hi Team,
Please suggest on this problem.

Thanks:
Praveen
Re: Not able to download Excel data from Oracle 10G with Window Server [message #628203 is a reply to message #628184] Fri, 21 November 2014 02:51 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Is the excel file on the server as well?
Re: Not able to download Excel data from Oracle 10G with Window Server [message #628206 is a reply to message #628203] Fri, 21 November 2014 03:39 Go to previous messageGo to next message
praveenjin@gmail.com
Messages: 10
Registered: November 2014
Location: India
Junior Member
Hi Team,
I'm not able to generate the excel file either at Server or client machine.

Below is the exception which I'm getting

ORA-305500 non oracle exception

Exception line:
workbooks = client_ole2.get_obj_property(application 'workbooks')

Thanks:
Praveen
Re: Not able to download Excel data from Oracle 10G with Window Server [message #628236 is a reply to message #628206] Fri, 21 November 2014 09:38 Go to previous messageGo to next message
CraigB
Messages: 386
Registered: August 2014
Location: Utah, USA
Senior Member
Praveen,
The first thing you need to understand is Forms 10g actually runs on the application server and is presented to the user (client) through the Java Applet. This means that any OLE2 calls will run on the application server - not the client. In order to interact with the client computer you need to use the WebUtil library. WebUtil comes with Oracle Forms, but you have to complete the configuration and install the JACOB.jar (Java COmmunication Bridge) in order to make this work. If you haven't configured WebUtil - this could explain the ORA-305500 exception you are getting. If you haven't configured WebUtil, please take a look at the following Forms Help topics: Configuring WebUtil and Runtime Setup Checklist.

Craig...
Re: Not able to download Excel data from Oracle 10G with Window Server [message #628240 is a reply to message #628236] Fri, 21 November 2014 10:12 Go to previous messageGo to next message
praveenjin@gmail.com
Messages: 10
Registered: November 2014
Location: India
Junior Member
Thanks Craig,

When I run OLE2 at the application server (server where Form 10G installed) at window 2012R2, I'm getting this error. But at the same time when I run OLE2 at the application server at window 7 (10G installed at window 7), this is working fine for me.

i.e when my application server is Window 7 this is working fine, but when my application server moves to Window server 2012R2, I'm facing the issue.

Is this OLE2 depends to operating system as well?

Thanks:
Praveen
Re: Not able to download Excel data from Oracle 10G with Window Server [message #628249 is a reply to message #628240] Fri, 21 November 2014 15:44 Go to previous messageGo to next message
praveenjin@gmail.com
Messages: 10
Registered: November 2014
Location: India
Junior Member
Hi Craig/ Team,
Please help us in this issue.

Thanks:
Praveen
Re: Not able to download Excel data from Oracle 10G with Window Server [message #628278 is a reply to message #628249] Sat, 22 November 2014 07:42 Go to previous messageGo to next message
praveenjin@gmail.com
Messages: 10
Registered: November 2014
Location: India
Junior Member
Hi Craig,
I'm trying to configure webutil
As suggested, for this I need to download webutil_106.zip
But I'm not able to download this.

As per forms URL(http://www.orafaq.com/forum/m/493960/?srch=Configure+WebUtil#msg_493960 ) , there is no file exists at suggest "http://www.oracle.com/technology/software/products/forms/files/webutil/webutil_106.zip"

Please let me know where can i find webutil_106.zip
Re: Not able to download Excel data from Oracle 10G with Window Server [message #628290 is a reply to message #628278] Sat, 22 November 2014 10:59 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
https://www.google.com/webhp?hl=en&tab=ww#hl=en&q=webutil_106.zip
Re: Not able to download Excel data from Oracle 10G with Window Server [message #628291 is a reply to message #628290] Sat, 22 November 2014 12:09 Go to previous messageGo to next message
praveenjin@gmail.com
Messages: 10
Registered: November 2014
Location: India
Junior Member
Thanks Team,
I've found the same form metalink. I've configured all the steps. But still getting the same error.
(Non Oracle Exception)


Thanks:
Praveen
Re: Not able to download Excel data from Oracle 10G with Window Server [message #628364 is a reply to message #628291] Mon, 24 November 2014 09:09 Go to previous messageGo to next message
CraigB
Messages: 386
Registered: August 2014
Location: Utah, USA
Senior Member
Quote:
As suggested, for this I need to download webutil_106.zip

You don't need to download WebUtil! It is already included in your Forms/Reports installation. The only thing you need to download is the JACOB.JAR from SourceForge. This is spelled out clearly in the Forms Help topics on configuring WebUtil. If you download and install a version of the WebUtil library that is not compatible with your Forms version, you will have much worse problems.
Quote:
i.e when my application server is Window 7 this is working fine, but when my application server moves to Window server 2012R2, I'm facing the issue.

Do you have MS-Office (Excel) installed on your Win 2012R2 server? If not, this would explain the "Non-Oracle" error when you run on the App Server.
Quote:
I've found the same form metalink. I've configured all the steps. But still getting the same error.

Are you getting this error using OLE2 or Client_OLE? You didn't specify. If you are getting this with OLE2 - I'm not surprised because you're still running on the App Server. If you are getting this error with Client_OLE then WebUtil is NOT configured correctly.

Craig...
Re: Not able to download Excel data from Oracle 10G with Window Server [message #628442 is a reply to message #628364] Tue, 25 November 2014 05:16 Go to previous messageGo to next message
praveenjin@gmail.com
Messages: 10
Registered: November 2014
Location: India
Junior Member
Thanks Craig for your help.

Now I've degrade my application server from window 2012R2 to 2008 and installed excel at my server. Excel files are getting generated successfully. I'm using OLE2.

My concern is, when I run the application from any client machine (user machine) the excel file is getting generated at the application server (2008). My client machine is Window 7.

I've done the setup regarding the setup of "JACOB.JAR" also.

Please tell/ guide me how can I download the excel file at the machine itself.

Thanks:
Praveen
Re: Not able to download Excel data from Oracle 10G with Window Server [message #628468 is a reply to message #628442] Tue, 25 November 2014 09:05 Go to previous messageGo to next message
CraigB
Messages: 386
Registered: August 2014
Location: Utah, USA
Senior Member
Quote:
I've done the setup regarding the setup of "JACOB.JAR" also.

Ok...now you have WebUtil configured - what have you tried? Search the Internet or this forum for examples of how to use the WebUtil_File_Transfer.AS_TO_CLIENT() method. You could also skip this step by simply converting your code to use CLIENT_OLE instead of OLE2 and create the file directly on the client computer. Depending on the amount of data you are exporting it might be better to create the file on the App Server and then transfer it to the client. Exporting large amounts of data directly to the client can be extremely slow...

Craig...
Re: Not able to download Excel data from Oracle 10G with Window Server [message #628501 is a reply to message #628468] Tue, 25 November 2014 12:51 Go to previous messageGo to next message
praveenjin@gmail.com
Messages: 10
Registered: November 2014
Location: India
Junior Member
Thanks Craig for your response.
I'm following the "setup checklist for configuration webutil" by using following LINK.

https://drive.google.com/viewerng/viewer?a=v&pid=sites&srcid=ZGVmYXVsdGRvbWFpbnxjcmFpZ3NvcmFjbGVzdHVmZnxneDo3Y2M4ZmZkZmUxYzNk NzM5

But seems I'm missing some-thing while configuring this.

I've completed the following step:

1. Create a DB package as per the script, but for This I didn't create any new user. I've created this database object by using my existing development schema. (is It effective some thing? )

2. Not able to understand step# 5.

3. Completed step# 6,7,8,9.

Please let me know are any other step for configuring the webutil package.

When I use for transferring the file from application server to local machine by using following code:


--------------------------
IF NOT webutil_file_transfer.AS_to_Client('C:\temp\pp.xlsx', 'C:\temp\pp.xlsx') THEN
message('Upload was not successful');
ELSE
message('Upload was successful');
END IF;
---------------------------

When I add this code, my IE (client Machine) hang up and got the following error at application server:

------------------------------------------------------------
Problem signature:
Problem Event Name: APPCRASH
Application Name: frmweb.exe
Application Version: 10.1.2.0
Application Timestamp: 42d63fc5
Fault Module Name: kernel32.dll
Fault Module Version: 6.0.6002.19034
Fault Module Timestamp: 52f2ec86
Exception Code: ebad0258
Exception Offset: 0003fd1e
OS Version: 6.0.6002.2.2.0.272.7
Locale ID: 1033
Additional Information 1: c6f2
Additional Information 2: c64561835793ce816a447abeb3af5b73
Additional Information 3: 9dae
Additional Information 4: bb47ea4578e1eaa133fa7c39782b6904
------------------------------------------------------------

Please check the same and guide me what I'm missing while configuration of webuitl.

Thanks:
Praveen
Re: Not able to download Excel data from Oracle 10G with Window Server [message #629147 is a reply to message #628501] Wed, 03 December 2014 15:58 Go to previous message
CraigB
Messages: 386
Registered: August 2014
Location: Utah, USA
Senior Member
Quote:
1. Create a DB package as per the script, but for This I didn't create any new user. I've created this database object by using my existing development schema. (is It effective some thing? )

It could if you have not created the public synonyms to the WebUtil objects. It is always best to create the user, but it is not necessary. If you are able to successfully compile the webutil.pll then you should be OK.

Quote:
2. Not able to understand step# 5.

Are you refering to Step 5 in the Runtime Setup Checklist? If yes, then this step is typically already completed as part of the default installation, but you need to check and confirm that the Virtual Directory is valid for your configuration. Just because you don't understand the step doesn't mean you shouldn't perform the step! Virtual directories are configured within the Application Server. You'll need to figure out how to check this...and yes, this could be the cause of your error.

Quote:
IF NOT webutil_file_transfer.AS_to_Client('C:\temp\pp.xlsx', 'C:\temp\pp.xlsx') THEN

This assumes the client computer has the same directory as the application server. A better option would be to prompt the user to select the directory to download the file too. This can be done using WebUtil_File.Directory_Selection_Dialog() method.

Also, when you are working with Java or WebUtil (which uses Java) it is a good idea to check the Java Console for any Java errors. Java errors will not propogate up to Forms in most cases. To display the Java Console while your Form is running just right-click on the Java Icon in the System Tray and select "Show Console" from the context menu.

Quote:
Please check the same and guide me what I'm missing while configuration of webuitl.

Start with understanding and completing Step 5. Run the Java Console so you can the Java Exceptions (if any). Finally, did you modify the webutil.cfg file to enable File transfers? This feature is disable by default because it is a security risk. Smile

Craig...

[Updated on: Wed, 03 December 2014 16:00]

Report message to a moderator

Previous Topic: how to manually lock/unlock record in forms 6i with where clause
Next Topic: Web Forms
Goto Forum:
  


Current Time: Sat Apr 20 01:19:15 CDT 2024