Skip to Main Content

Oracle Forms

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Read Excel file from Oracle Foms

ricardogcOct 1 2008 — edited Oct 18 2008
Hi Guys

Im trying to read a excel file from oracle forms 10g using webuti and client_ole2 in order to store the file information in a table.

This is my code.

--------------------------------------------------------------------------------------------------------------

DECLARE
lv_application client_ole2.obj_type;
lv_workbooks client_ole2.obj_type;
lv_workbook client_ole2.obj_type;
lv_worksheet client_ole2.obj_type;
lv_args client_ole2.list_type;
lv_cell client_ole2.obj_type;
lv_cell_list1 client_ole2.list_type;
lv_cell_value VARCHAR2 (100);
lv_row_cntr NUMBER := 1;
lv_col_cntr NUMBER := 1;
lv_bttn NUMBER := 0;
BEGIN
lv_application := client_ole2.create_obj ('EXCEL.APPLICATION');
lv_workbooks := client_ole2.get_obj_property (lv_application, 'WORKBOOKS');
lv_args := client_ole2.create_arglist;
client_ole2.add_arg (lv_args, :bl_control.filename);
lv_workbook := client_ole2.get_obj_property (lv_workbooks, 'OPEN', lv_args);
client_ole2.destroy_arglist (lv_args);
lv_args := client_ole2.create_arglist;
client_ole2.add_arg (lv_args, 'SHEET1');
lv_worksheet :=
client_ole2.get_obj_property (lv_workbook, 'WORKSHEETS', lv_args);
client_ole2.destroy_arglist (lv_args);

FOR i IN 1 .. 10
LOOP
lv_cell_list1 := client_ole2.create_arglist;
client_ole2.add_arg (lv_cell_list1, lv_row_cntr);
client_ole2.add_arg (lv_cell_list1, lv_col_cntr);
lv_cell :=
client_ole2.get_obj_property (lv_worksheet, 'CELLS', lv_cell_list1);
client_ole2.destroy_arglist (lv_cell_list1);
lv_cell_value := client_ole2.get_char_property (lv_cell, 'value');
client_ole2.RELEASE_OBJ (lv_cell);
END LOOP;

lv_args := client_ole2.create_arglist;
client_ole2.add_arg (lv_args, 0);
client_ole2.invoke (lv_workbook, 'CLOSE', lv_args);
client_ole2.destroy_arglist (lv_args);
client_ole2.invoke (lv_application, 'QUIT');
client_ole2.RELEASE_OBJ (lv_worksheet);
client_ole2.RELEASE_OBJ (lv_workbook);
client_ole2.RELEASE_OBJ (lv_workbooks);
client_ole2.RELEASE_OBJ (lv_application);
proc_show_alert ('ALERT_DIALOG',
'Import',
'The import is completed successfully.',
lv_bttn
);
EXCEPTION
WHEN OTHERS
THEN
client_ole2.invoke (lv_application, 'QUIT');
client_ole2.RELEASE_OBJ (lv_worksheet);
client_ole2.RELEASE_OBJ (lv_workbook);
client_ole2.RELEASE_OBJ (lv_workbooks);
client_ole2.RELEASE_OBJ (lv_application);
END;

--------------------------------------------------------------------------------------------------------------

This code is inside a WHEN-BUTTON-PRESSED trigger.

My problem is that my program gets stuck when this line is reached:

lv_workbook := client_ole2.get_obj_property (lv_workbooks, 'OPEN', lv_args);

There's no exception thrown, no errors. It simply does nothing.

I'm running the form from a Windows XP machine, my Office is 2003; both in Spanish.

Hope somebody can help me.

Regards.

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Nov 15 2008
Added on Oct 1 2008
9 comments
1,554 views