我正在尝试从oracle表单10g和Oracle APPS ERP导出Excel文件中显示的数据。
我正在使用CLIENT_OLE2软件包创建和保存Excel文件
这是我的CLIENT_OLE2软件包:
这是我的代码:
DECLARE
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 OLE2.OBJ_TYPE;
J INTEGER;
K INTEGER;
file_name_cl VARCHAR2(32767);
user_cancel EXCEPTION;
BEGIN
MESSAGE('AFTER DECLARATION');
file_name_cl := CLIENT_GET_FILE_NAME('C:\', 'file_name.xls', 'XLS Files
(*.xls)|*.xls|', NULL, SAVE_FILE, TRUE);
file_name_cl := SUBSTR(file_name_cl,1,LENGTH(file_name_cl));
IF file_name_cl IS NULL THEN
MESSAGE('INSIDE EXCEPTION STATEMENT');
RAISE user_cancel;
END IF;
MESSAGE('STARTING TRIGGER');
APPLICATION := CLIENT_OLE2.CREATE_OBJ('Excel.Application');
CLIENT_OLE2.SET_PROPERTY(APPLICATION,'Visible',True);
MESSAGE('AFTER CREATING APPLICATION');
WORKBOOKS := CLIENT_OLE2.GET_OBJ_PROPERTY(APPLICATION, 'WORKBOOKS');
WORKBOOK := CLIENT_OLE2.INVOKE_OBJ(WORKBOOKS, 'ADD');
WORKSHEETS := CLIENT_OLE2.GET_OBJ_PROPERTY(WORKBOOK, 'WORKSHEETS');
WORKSHEET := CLIENT_OLE2.INVOKE_OBJ(WORKSHEETS, 'ADD');
MESSAGE('RIGHT BEFORE GO BLOCK STATEMENT');
GO_BLOCK('CRITERIA');
FIRST_RECORD;
J:=1;
K:=1;
WHILE :SYSTEM.LAST_RECORD = 'FALSE'
LOOP
FOR K IN 1..20 /* Form has 7 columns */
LOOP
MESSAGE('INSIDE LOOP');
If not name_in(:system.cursor_item) is NULL Then
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', name_in(:system.cursor_item));
Client_OLE2.release_obj(cell);
End If;
NEXT_ITEM;
END LOOP;
J:=J+1;
NEXT_RECORD;
END LOOP;
/* For the last record */
for k in 1..20
loop
If not name_in(:system.cursor_item) is NULL Then
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', name_in(:system.cursor_item));
Client_OLE2.release_obj(cell);
End If;
next_item;
end loop;
Client_OLE2.Release_Obj(worksheet);
Client_OLE2.Release_Obj(worksheets);
/* Save the Excel file created */
args := Client_OLE2.Create_Arglist;
Client_OLE2.Add_Arg(args,'c:\test.xls');
Client_OLE2.Invoke(workbook, 'SaveAs', args);
Client_OLE2.Destroy_Arglist(args);
/* release workbook */
Client_OLE2.Release_Obj(workbook);
Client_OLE2.Release_Obj(workbooks);
/* Release application */
Client_OLE2.Invoke(application, 'Quit');
Client_OLE2.Release_Obj(application);
MESSAGE('RIGHT BEFORE END');
END;
我遇到以下错误:
WebUtil错误:找不到oracle.forms.webutil.file.FileFunctions bean WEBUTIL_FILE.FILE_SELECTION_DIALOG_INT将不起作用