系统设置:
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
现在,我的问题是,当我们设计他们的系统时,除了数据库之外的所有东西都在一台 PC 上。我能够读取和写入 Excel 文档完全没有问题。然后,我们将所有内容都转移到分层设置中,其中包含客户端、应用程序服务器和数据库服务器。一切仍然很好。最后他们建立了三层系统,这就是我遇到问题的地方。
当我让 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;
代码在 FILE_TRANSFER 处失败,因为表单没有像预期的那样在 App Server 上创建。
发生的一个相关问题是,当我尝试上传 excel 文档并将其读入 oracle 时,我收到 ORA-305500 错误。我已尝试让 DBA 卸载并重新安装 Excel,并确保在安装过程中包含所有功能/附加组件,但问题仍未解决。
有人可以给我一些关于如何解决这个问题或继续解决这个问题的建议吗?
谢谢,
账单