Hello,
overall I am using webutil in Forms 10g successfully, but stumbled over the following problem with Excel.
My Environment:
Forms 10g 10.1.2.3.0
Jacob 1.6
Excel 2010
Java 1.6.0_45
When I am reading a number property from Excel, webutil sometimes just throws an exception with the not so helpful error number "-1".
This first happened to me with the code at the end, but different examples are possible.
With a font size of 22, the "Top" of the "Range" is 57, with font size 21 webutil throws the exception.
To check that my calling of Excel is correct, I implemented this example also in C# using Excel.Interop and in Java with directly calling Jacob. Both versions showed the same value for font size 22, but didn't crash with font size 21. Both show me the value 56,25 instead.
I later remembered to set webutils logging to "detailed" which also showed me a value of 56,25.
2016-Aug-04 14:25:44.199 WUO[setProperty()] Setting property WUO_OLE2_PROPNAME to Top
2016-Aug-04 14:25:44.199 WUO[getProperty()] Getting property WUO_OLE2_GET_PROPERTY
2016-Aug-04 14:25:44.199 WUO[getProperty()] Value of WUO_OLE2_GET_PROPERTY=56,25
2016-Aug-04 14:25:45.325 WUO[getProperty()] Getting property WUO_OLE2_ERROR
2016-Aug-04 14:25:45.325 WUO[getProperty()] Value of WUO_OLE2_ERROR=-1,null,null,null,-1
2016-Aug-04 14:25:46.165 WUO[getProperty()] Getting property WUO_OLE2_ERROR
2016-Aug-04 14:25:46.165 WUO[getProperty()] Value of WUO_OLE2_ERROR=-1,null,null,null,-1
And then something dawned upon me: please note the "," instead of a ".".
My PC runs with a german locale, so my Excel does so too. The Oracle Forms application runs with AMERICAN_AMERICA.WE8ISO8859P1 and thus a "." for the decimal point.
I think webutil tries to convert this to a NUMBER and just fails because of the unexpected format.
So what can i do to get Excel to return numbers in the american format? Can I somehow start Excel with a different locale?
This has to work on a lot of computers with both german, english and chinese locales.
Thanks in advance
Markus
Here the example code:
DECLARE
application CONSTANT CLIENT_OLE2.obj_type := CLIENT_OLE2.create_obj( 'Excel.Application' );
workbooks CONSTANT CLIENT_OLE2.obj_type := CLIENT_OLE2.get_obj_property( application, 'Workbooks' );
workbook CONSTANT CLIENT_OLE2.obj_type := CLIENT_OLE2.invoke_obj( workbooks, 'Add' );
worksheets CONSTANT CLIENT_OLE2.obj_type := CLIENT_OLE2.get_obj_property( workbook, 'WorkSheets' );
args CONSTANT CLIENT_OLE2.obj_type := CLIENT_OLE2.create_arglist();
BEGIN
CLIENT_OLE2.add_arg( args, 1 );
DECLARE
worksheet CONSTANT CLIENT_OLE2.obj_type := CLIENT_OLE2.get_obj_property( worksheets, 'Item', args );
BEGIN
CLIENT_OLE2.destroy_arglist( args );
CLIENT_OLE2.invoke( worksheet, 'Activate' );
CLIENT_OLE2.set_property( application, 'Visible', 1 );
CLIENT_OLE2.set_property( application, 'DisplayAlerts', 1 );
DECLARE
args CONSTANT CLIENT_OLE2.obj_type := CLIENT_OLE2.create_arglist();
cell CLIENT_OLE2.obj_type;
BEGIN
CLIENT_OLE2.add_arg( args, 1 );
CLIENT_OLE2.add_arg( args, 1 );
cell := CLIENT_OLE2.get_obj_property( worksheet, 'Cells', args );
CLIENT_OLE2.destroy_arglist( args );
CLIENT_OLE2.set_property( cell, 'Value', 'BLAHBLAH' );
DECLARE
font CONSTANT CLIENT_OLE2.obj_type := CLIENT_OLE2.get_obj_property( cell, 'Font' );
BEGIN
CLIENT_OLE2.set_property( font, 'Name', 'Wingdings' );
CLIENT_OLE2.set_property( font, 'Size', 21 ); -- < CRASH WITH Size=21, NOT WITH Size=22
CLIENT_OLE2.set_property( font, 'Bold', 1 );
END;
END;
DECLARE
args CONSTANT CLIENT_OLE2.obj_type := CLIENT_OLE2.create_arglist();
cell CLIENT_OLE2.obj_type;
BEGIN
CLIENT_OLE2.add_arg( args, 'G4' );
cell := CLIENT_OLE2.get_obj_property( worksheet, 'Range', args );
CLIENT_OLE2.destroy_arglist( args );
CLIENT_OLE2.set_property( cell, 'Value', 'BLAH' );
message( 'Left: ' || CLIENT_OLE2.get_num_property( cell, 'Left' ) );
message( 'Top: ' || CLIENT_OLE2.get_num_property( cell, 'Top' ) ); -- < CRASH HAPPENS HERE
END;
END;
CLIENT_OLE2.release_obj( workbooks );
CLIENT_OLE2.release_obj( application );
EXCEPTION
WHEN CLIENT_OLE2.ole_error THEN
message( 'ole_error' );
message( 'errno: ' || CLIENT_OLE2.last_exception() );
DECLARE
ole_error_message VARCHAR2( 4000 );
BEGIN
IF( CLIENT_OLE2.last_exception( ole_error_message ) != 0 )
THEN
message( ole_error_message );
END IF;
END;
CLIENT_OLE2.release_obj( application );
END;