public String CSDRangeAddress(XCellRange range) { XPropertySet ps; ps= (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, range); return (String) ps.getPropertyValue("AbsoluteName"); } (withoud try and catch) Made it for me Thanks for your Help!
-----Ursprüngliche Nachricht----- Von: so-ham02-newsgate...@sun.com [mailto:so-ham02-newsgate...@sun.com] Im Auftrag von Daniel Rentz Gesendet: Dienstag, 18. Mai 2010 19:01 An: dev@api.openoffice.org Betreff: Re: AW: [api-dev] Range/Cell Address as Parameter for calc addin Hello, Martin Dobiasch schrieb: > My problem is now to convert the Address Object back to a String > > public String CSDRangeAddress(XCellRange range) > { > XCellRangeAddressable xAdd= > (XCellRangeAddressable)UnoRuntime.queryInterface( > XCellRangeAddressable.class, range); > CellRangeAddress address = xAdd.getRangeAddress(); > //do something here like address.EndRow= 12; > return "..."; > } > Is there an API-way to convert CellRangeAddress to a String? You can use the "AbsoluteName" property of the range, but this will return the sheet name too. http://api.openoffice.org/docs/common/ref/com/sun/star/sheet/SheetCellRange. html#AbsoluteName If you want to parse that string to remove the sheet name, please take into account that sheet names may contain periods too, e.g. "Sheet.1" where the "AbsoluteName" property gives $'Sheet.1'.$A$1:$B$2 and sheet names may contain apostroph characters, which are encoded by duplicating them, e.g. "Sheet'1" where the "AbsoluteName" property gives $'Sheet''1'.$A$1:$B$2 Maybe it is better to build the range address by yourself. Here is some pseudo code to build the column name from a zero-based column index (perhaps needs some adjustments for Java): String getColumnName( int column ) { String name; while( column >= 0 ) { name = String( 'A' + (column % 26) ) + name column = column / 26 - 1 } return name; } so you can build the range name with something like return getColumnName(address.StartColumn) + (address.StartRow+1) + ":" + getColumnName(address.EndColumn) + (address.EndRow+1); Regards Daniel --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org