Hello Everyone
Thank you for your reply. Let me explain some details about my work. I
need to develop a charging scehma.Here is a very simple example.
A B
1 Unit Cost 10
2 Quantity 2
3 Charge 20
The name of cells (I suppose those names have been defined before use)
B1 : unitcost, B2: quantity, B3 : charge B3=B1*B2
The rating engine will insert the Quantity into the speadsheet
automatically(it is 2 in the example). THe spreadsheet will perform the
calculation (B3=B1*B2) and put the result (it is 20 ) into B3.
The rating engine will insert the value of Quantity according to the
name of the cell. It only gives the data to the cell named "quantity".
Finally ,the rating engine will get the result from the cell named
"charge". I can not modify the rating engine.
I think the answer given by those people will not change the name of
cells(B2,B3). I also read a similar example in the guide of developers
////////////////////////////////////////////////////////////////////////////////////////////////////////
com.sun.star.beans.XPropertySet xDocProp =
(com.sun.star.beans.XPropertySet)
UnoRuntime.queryInterface(
com.sun.star.beans.XPropertySet.class, xDocument );
Object aRangesObj = xDocProp.getPropertyValue( "NamedRanges" );
com.sun.star.sheet.XNamedRanges xNamedRanges =
(com.sun.star.sheet.XNamedRanges)
UnoRuntime.queryInterface(
com.sun.star.sheet.XNamedRanges.class, aRangesObj );
com.sun.star.table.CellAddress aRefPos = new
com.sun.star.table.CellAddress();
aRefPos.Sheet = 0;
aRefPos.Column = 6;
aRefPos.Row = 44;
xNamedRanges.addNewByName( "ExampleName", "SUM(G43:G44)",
aRefPos, 0 );
// use the named range in formulas
xSheet.getCellByPosition( 6, 44 ).setFormula( "=ExampleName" );
xSheet.getCellByPosition( 7, 44 ).setFormula( "=ExampleName" );
////////////////////////////////////////////////////////////////////////////////////////////////////////
However, it seems do not give a possible answer.:(
Stephan Wunderlich schrieb:
> Hi,
>
>> I'd like to know how the set the names of cells of spreadsheets
>> through Java Program ?
>> eg.rename the cell(A1) as "example"
>
>
> you can't rename a Cell ... could it be that you want to add a named
> Range consisting of one Cell ?
>
> something like
>
> Dim sBase As New com.sun.star.table.CellAddress
>
> oDoc = ThisComponent
> oNamedRanges = oDoc.getPropertyValue("NamedRanges")
Or, more simple in Basic
oNamedRanges = oDoc.NamedRanges
>
> sBase.sheet = 0
> sBase.Column = 0
> sBase.Row = 0
>
> oNamedRanges.addNewByName("MyRange", "A1:B3", sBase, 0)
This will not work, because it will create a relative address depending
on the position where the named range is used. Try this:
oNamedRanges.addNewByName("MyRange", "$A$1", sBase, 0)
Note the dollar signs, they will create an absolute reference to cell A1.
Regards
Daniel
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]