简体   繁体   English

使用OLE2的Oracle Forms无法在3层设置中保存Excel文档

[英]Oracle Forms using OLE2 not saving Excel document on 3-tier setup

System setup: 系统设置:

3-Tier environment
Client Machine - doesn't matter
Web-Tier - Not sure.  Probably Windows Server 2008 64 bit
       -Jdk 7u3
App Server - Windows Server 2008 64 bit
       -Weblogic Server 10.3.6
       -Excel 2010
       -Jdk 7u3
Database Server - Not sure. Probably Windows Server 2008 64 bit.
       -Oracle Database 11g

Programming using Oracle Forms 11.1.1.6

Now, my problem is that when we had designed they system, everything but the database was on one PC. 现在,我的问题是,当我们设计它们的系统时,除了数据库之外的所有东西都在一台PC上。 I was able to read and write Excel documents no problem at all. 我能够读写Excel文档完全没有问题。 Then we moved everything to a tiered setup where we had the client, app server and database server. 然后,我们将所有内容移至具有客户端,应用程序服务器和数据库服务器的分层设置。 Everything still worked great. 一切仍然很好。 Finally they set up the 3-tiered system and that's where I ran into my problems. 最终,他们建立了3层系统,这就是我遇到的问题。

When I have Oracle Forms write to the Excel document the code appears to execute without any errors until I try to copy the file from the App Server using Webutil. 当我将Oracle Forms写入Excel文档时,该代码似乎可以正常执行,直到我尝试使用Webutil从App Server复制文件为止。

PROCEDURE Export_to_Excel 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;
 p_filename VARCHAR(255);

 --p_file TOOL_RES.RFHANDLE;
 p_file Text_IO.File_Type;
 p_filename_client      VARCHAR2(500);
 v_filename                     VARCHAR2(500);
 v_error                            VARCHAR2(500);
 passed_filename            VARCHAR2(500);
BEGIN

 -- Retrieve user specific directory to create new file in
 p_filename := Webutil_file_transfer.get_work_area;

 -- Start Excel 
 application:=OLE2.CREATE_OBJ('Excel.Application');

 -- 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');

 -- Set up the Header worksheet
 args:=OLE2.CREATE_ARGLIST; 
 OLE2.ADD_ARG(args, 1);
 worksheet:=OLE2.GET_OBJ_PROPERTY(worksheets,'Item',args);
 OLE2.DESTROY_ARGLIST(args);
 OLE2.set_property(worksheet,'Name','Header');

 -- Build header form
 populate_header(worksheet);

 -- 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 );


 -- Set up the Item worksheet
 args:=OLE2.CREATE_ARGLIST; 
 OLE2.ADD_ARG(args, 2);
 worksheet:=OLE2.GET_OBJ_PROPERTY(worksheets,'Item',args);
 OLE2.DESTROY_ARGLIST(args);
 OLE2.set_property(worksheet,'Name','Item List');

 -- Build Item sheet
 populate_item_sheet(worksheet);

 -- Delete the last worksheet that excel automatically creates
 args:=OLE2.CREATE_ARGLIST; 
 OLE2.ADD_ARG(args, 3);
 worksheet:=OLE2.GET_OBJ_PROPERTY(worksheets,'Item',args);
 OLE2.DESTROY_ARGLIST(args);
 OLE2.invoke(worksheet, 'Delete');

 -- Save as worksheet
 OLE2.SET_PROPERTY(application,'DisplayAlerts',FALSE);
 IF p_filename is not null THEN
        args := OLE2.CREATE_ARGLIST;
        OLE2.ADD_ARG( args, p_filename || :PARAMETER_B1.FILENAME || '.xlsx');
        OLE2.ADD_ARG( args, 56 );
        OLE2.INVOKE( workbook,'SaveAs',args );
        OLE2.DESTROY_ARGLIST( args );
 END IF;

 -- Close workbook
 OLE2.INVOKE( workbook ,'Close');

 -- 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); 

 --Check if file was writen correctly
 p_file := text_io.fopen(p_filename || :PARAMETER_B1.FILENAME || '.xlsx','r');
 Text_IO.Fclose(p_file);

 --Added the following code
 passed_filename := :PARAMETER_B1.FILENAME || '.xlsx';
 v_filename := p_filename || passed_filename;

 -- Popup a dialog box to allow user to select the location to save the file
 p_filename_client := CLIENT_GET_FILE_NAME ( 'C:\', passed_filename, NULL, 'Select A Directory', SAVE_FILE, FALSE );

 if p_filename_client is null then
      message ('Creation of the spreadsheet has been canceled.');
        raise form_trigger_failure;
 end if;

 -- File Transfer to Client
 PROCESS_COMM_FILE_CLIENT.FILE_TRANSFER('O', p_filename_client, v_filename, null, v_error);

 EXCEPTION
      WHEN others THEN
        Text_IO.Fclose(p_file);
                message( SQLERRM( SQLCODE ) ) ;
        if p_filename_client is not null then
          MESSAGE('An error occurred while creating file.');
      end if;
END; 

The code fails at the FILE_TRANSFER because the form does not get created on the App Server like it is supposed to. 该代码在FILE_TRANSFER处失败,因为该窗体未按预期在App Server上创建。

A related problem that is occuring is that when I try to upload the excel document and read it in to oracle I get a ORA-305500 error. 发生的一个相关问题是,当我尝试上传excel文档并将其读入oracle时,出现ORA-305500错误。 I have tried to have the DBA uninstall and reinstall Excel and made sure all of the features/add-ons were included during the installation but the problem still hasn't been fixed. 我试图卸载DBA并重新安装Excel,并确保在安装过程中包括了所有功能/附加组件,但问题仍未得到解决。

Could someone please give me some suggestions on what to do to fix this problem or continue to problem shoot this? 有人可以给我一些有关解决此问题或继续解决问题的建议吗?

Thanks, 谢谢,

Bill 法案

Check your $ORACLE_HOME/forms/server/webutil.cfg , if there is any restriction in reading directories. 检查$ORACLE_HOME/forms/server/webutil.cfg ,如果在读取目录中没有任何限制。

Basically, check the parameters "transfer.appsrv.read.<n>=/.../.../". 基本上检查参数"transfer.appsrv.read.<n>=/.../.../".

If the problem relates to the actual generation of the file using OLE, then I would sugest that you create the directory: 如果问题与使用OLE实际生成文件有关,那么我建议您创建目录:

C:\Windows\System32\config\systemprofile

The OLE code in Oracle Forms checks in this directory for OLE configuration settings. Oracle Forms中的OLE代码在此目录中检查OLE配置设置。 It doesn't matter if the directory is empty, only that it exists! 目录是否为空并不重要,只有目录存在!

If I am understanding your problem, you intend to save the file in the client machine. 如果我了解您的问题,则打算将文件保存在客户端计算机中。 Now assuming you are using WEB_FORMS (ie you use a web browser to access forms application), you can use the code below to save the file from AS to client machine, instead of PROCESS_COMM_FILE_CLIENT.FILE_TRANSFER . 现在,假设您正在使用WEB_FORMS(即,使用Web浏览器访问表单应用程序),则可以使用以下代码将文件从AS保存到客户端计算机,而不是PROCESS_COMM_FILE_CLIENT.FILE_TRANSFER The OLE objects create the file at the AS, you need to get the file from AS (App server) to local machine- OLE对象在AS处创建文件,您需要将文件从AS(应用服务器)获取到本地计算机,

l_success := webutil_file_transfer.AS_to_Client_with_progress 
     (clientFile => 'c:\fine.xlsx' 
     ,serverFile => 'c:\data\file.xlsx' 
     ,progressTitle => 'Save file in progress' 
     ,progressSubTitle => 'Please wait');
if l_success then 
     message('File saved successfully'); 
else 
     message('Cannot save file'); 
end if;

The abve code should show a "Save file in progress" pop up box with progress bar to show that your file is being saved to local machine. 上面的代码应显示一个带有进度条的“正在保存文件”弹出框,以表明您的文件已保存到本地计算机。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Pandas 突然无法打开 Excel 文件(在 OLE2 复合文档中找不到工作簿 - Pandas suddenly cannot open Excel file (can't find workbook in OLE2 compound document 如何在 OLE2 ABAP 中对受保护的 excel 文件启用过滤器 - How to enable filters on protected excel file in OLE2 ABAP OLE2命令用于返回Excel文件中的列数 - OLE2 command for returning the number of columns in an Excel file 使用 Client_OLE2 从 Oracle Forms 12c 将数据导出到 Excel - Export Data to Excel from Oracle Forms 12c Using Client_OLE2 使用OLE删除Excel文档中的冒号过滤器 - Remove colones filters in excel document using OLE Ole :: Storage :: FormatError:OLE2签名无效 - Ole::Storage::FormatError: OLE2 signature is invalid Excel 正在等待 Word 文档完成 OLE 操作 - Excel is waiting for a Word document to complete an OLE action 使用Win32 :: OLE Perl模块将Excel中的一系列单元格保存为HTML - Saving a range of Cells in Excel as HTML using Win32::OLE Perl module 使用Ruby和Win32ole将样式(格式)添加到MS Excel文档的单元格中 - Add style (format) to cell of MS Excel document using Ruby with win32ole 无效的标题签名; 读取0x54535543092E4F4E,预期为0xE11AB1A1E011CFD0-您的文件似乎不是有效的OLE2文档 - Invalid header signature; read 0x54535543092E4F4E, expected 0xE11AB1A1E011CFD0 - Your file appears not to be a valid OLE2 document
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM