Difference between revisions of "Talk:Documentation/DevGuide/Spreadsheets/Example: Adding a New Spreadsheet"

From Apache OpenOffice Wiki
Jump to: navigation, search
(add comment)
 
(One intermediate revision by one other user not shown)
Line 10: Line 10:
 
As per the API, the method [http://api.openoffice.org/docs/common/ref/com/sun/star/container/XNameAccess.html#getByName getByName] returns com.sun.star.uno.Any as data type.
 
As per the API, the method [http://api.openoffice.org/docs/common/ref/com/sun/star/container/XNameAccess.html#getByName getByName] returns com.sun.star.uno.Any as data type.
  
I found the way on getting the right Interface reading the [http://www.javaworld.com/javaworld/jw-05-2008/jw-05-spreadsheets.html?page=2http://www.javaworld.com/javaworld/jw-05-2008/jw-05-spreadsheets.html?page=2 JavaWorld article] and it works well.
+
I think it should:
 
+
 
Here the snippet:
+
+
 
  xSheet = (XSpreadsheet) UnoRuntime.queryInterface(XSpreadsheet.class, xSheets.getByName(aName));
 
  xSheet = (XSpreadsheet) UnoRuntime.queryInterface(XSpreadsheet.class, xSheets.getByName(aName));
 
   
 
   
Line 20: Line 18:
  
 
--[[User:Javacioc|Javacioc]] 22:13, 15 November 2009 (UTC)
 
--[[User:Javacioc|Javacioc]] 22:13, 15 November 2009 (UTC)
 +
 +
yes, this is wrong in the code snippet but correct in the SDK sample. I have changed the code snippet!
 +
 +
--[[User:Jsc|Jsc]] 14:54, 18 November 2009 (UTC)

Latest revision as of 13:53, 18 November 2009

In the insertSpreadsheet() method of the example, the assignement

xSheet = xSheets.getByName(aName);

cannot be casted to com.sun.star.sheet.XSpreadsheet as per Exception reported as follow:

java.lang.ClassCastException: com.sun.star.uno.Any cannot be cast to com.sun.star.sheet.XSpreadsheet

As per the API, the method getByName returns com.sun.star.uno.Any as data type.

I think it should:

xSheet = (XSpreadsheet) UnoRuntime.queryInterface(XSpreadsheet.class, xSheets.getByName(aName));

I'm using Netbeans 6.7.1 with OpenOffice.org API Plugin v.2.0.6, the SDK is 3.1.1

--Javacioc 22:13, 15 November 2009 (UTC)

yes, this is wrong in the code snippet but correct in the SDK sample. I have changed the code snippet!

--Jsc 14:54, 18 November 2009 (UTC)

Personal tools