我正在使用Oracle表格10g。它是基于Web的Oracle表单应用程序。我想从Oracle Forms 10g生成Excel报告。我配置了WEBUTIL并使用CLIENT_OLE2包。在触发器WHEN-BUTTON-PRESSED中声明的过程。当按下按钮时,表格突然冻结,他们无能为力。退出按钮和菜单选项停止工作。它不给出任何消息,也不执行任何操作。
程序代码:
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;
cell client_ole2.obj_type;
arglist client_ole2.list_type;
row_num number;
col_num number;
fontObj client_ole2.obj_type;
cursor rec is SELECT so.descr saleorgdescr,ih.invdate invdatemaster, ih.docNUM docnum,
TO_CHAR(ih.invdate,'mon-yyyy') invmonth
FROM ARMINVHEAD ih, SDMSALEORG so
WHERE
ih.status='69'
AND TO_DATE(ih.INVDATE,'DD-MM-RRRR')
BETWEEN
TO_DATE('01-01-2008','DD-MM-RRRR')
AND
TO_DATE('01-01-2009','DD-MM-RRRR')
order by IH.INVDATE, ih.docnum;
procedure SetCellValue(rowid number,colid number,cellValue varchar) is
begin
arglist := client_ole2.create_arglist;
client_ole2.add_arg(arglist,rowid);
client_ole2.add_arg(arglist,colid);
cell:= client_ole2.get_obj_property(worksheet,'Cells',arglist);
fontObj := client_ole2.get_obj_property(cell,'Font');
client_ole2.destroy_arglist(arglist);
client_ole2.set_property(cell,'value',cellValue);
client_ole2.set_property(fontObj,'Size',16);
client_ole2.set_property(fontObj,'BOLD',1);
client_ole2.set_property(fontObj,'ColorIndex',7);
client_ole2.release_obj(cell);
end SetCellValue;
procedure app_init is
begin
application := client_ole2.create_obj('Excel.Application');
client_ole2.set_property(application,'Visible',true);
workbooks := client_ole2.get_obj_property(application,'workbooks');
workbook := client_ole2.Get_Obj_Property(workbooks,'add');
worksheets := client_ole2.get_obj_property(application,'worksheets');
worksheet := client_ole2.Get_Obj_Property(worksheets,'add');
client_ole2.set_property(worksheet,'Name','Emp Sheet');
end app_init;
procedure save_excel(path varchar,filename varchar) is
begin
client_OLE2.Release_Obj(worksheet);
client_OLE2.Release_Obj(worksheets);
-- Save the Excel file created
If path is not null then
Arglist := client_OLE2.Create_Arglist;
client_OLE2.Add_Arg(Arglist,path||'\'||file_name||'.xls');
client_OLE2.Invoke(workbook, 'SaveAs', Arglist);
client_OLE2.Destroy_Arglist(Arglist);
end if;
end save_excel;
begin
app_init;
row_num:=1;
col_num:=1;
SetCellValue(row_num,col_num,'saleorgdescr');
col_num:=col_num + 1;
SetCellValue(row_num,col_num,'invdatemaster');
col_num:=col_num + 1;
SetCellValue(row_num,col_num,'docnum');
col_num:=col_num + 1;
SetCellValue(row_num,col_num,'invmonth');
for i in rec loop
row_num:=row_num + 1;
col_num:=1;
SetCellValue(row_num,col_num,i.saleorgdescr);
col_num:=2;
SetCellValue(row_num,col_num,i.invdatemaster);
col_num:=3;
SetCellValue(row_num,col_num,i.docnum);
col_num:=4;
SetCellValue(row_num,col_num,i.invmonth);
end loop;
save_excel('C:','emp_data');
client_OLE2.Release_Obj(workbook);
client_OLE2.Release_Obj(workbooks);
client_OLE2.Release_Obj(application);
end;
答案 0 :(得分:0)
很可能您缺少以下两组之一中列出的文件:
- 中的个文件
frmwebutil.jar
,jacob.jar
(也许也frmall_jinit.jar
)\forms\java
目录或
- 中的个文件
jacob-1.14.3-x86.dll
,JNIsharedstubs.dll
和d2kwut60.dll
C:\Program Files (x86)\Java\jre1.8.0_xxx\bin
目录
假设您的 Oracle Fusion Middleware Home 为C:\ORACLE_10g
。如果该目录中不存在它们,那么只需将它们手动移动到那里即可。
- 此外,它们最好以
CLASSPATH
的形式包含在CLASSPATH=C:\ORACLE_10g\forms\java\jacob.jar;C:\ORACLE_10g\forms\java\frmwebutil.jar;
中和
- 在添加文件时
C:\Program Files (x86)\Java\jre1.8.0_xxx\lib\security\java.policy
编辑
permission java.security.AllPermission;
到文件底部
在最后一个花括号前加上分号};
就在Forms应用程序运行之前,Oracle会提示您对那些文件进行签名。它们需要通过选中always
选项进行签名。