PRB: ClassCastException Error When Using Excel Object in JavaLast reviewed: January 29, 1998Article ID: Q169806 |
The information in this article applies to:
SYMPTOMSAttempting to create a new _ExcelApplicaton object and casting it to an Application interface, generates the following exception:
exception:java.lang.ClassCastException:xl5en32/_ExcelApplication RESOLUTIONTo work around the problem call getDispatch on the Application object, in order to get at its COM interface. For the code mentioned in the MORE INFORMATION section, the workaround is to use a Workspace, and it's method .Application() to return an application object, and then use the getDispatch to get the Application interface:
import xl5en32.*; import com.ms.com.*; public void TestExcel() { Variant v1 = new Variant(); Application app; // Create A new worksheet Worksheet wks = (Worksheet)new _ExcelSheet(); // Get hold of a dispatch on the application v1 = wks.Application(); app = (Application)v1.getDispatch(); } MORE INFORMATION
Steps to Reproduce Behavior
REFERENCESFor the latest Knowledge Base articles and other support information on Visual J++ and the SDK for Java, see the following page on the Microsoft Technical Support site:
http://support.microsoft.com/support/visualj/ http://support.microsoft.com/support/java/ |
Additional query words: excel exception java
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |