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: [email protected]
For additional commands, e-mail: [email protected]