Page 1 of 1

[Solved] [Calc] How can I set name of the range

Posted: Fri Mar 20, 2009 11:16 am
by avalter
Hello,

I can't find way to set name of the range.
SpreadSheetDocument have property NamedRanges (I need to get this property to set name of the ranges), but I can't find type SpreadSheetDocument in the CLI assemblies. There is only XSpreadSheetDocument, but unfortunately this interface haven't "NamedRanges" (Any other interface in the cli assembles haven't this property too).

Can anybody help me?

Thanks,
Anton Valter.

Re: How i can set name of the range. (Calc)

Posted: Fri Mar 20, 2009 11:38 am
by B Marcelly
Hi,
As usual, read the Developer's Guide.
http://wiki.services.openoffice.org/wik ... med_Ranges
______
Bernard

Re: How i can set name of the range. (Calc)

Posted: Fri Mar 20, 2009 12:06 pm
by avalter
Thanks.
I read few days ago. but i can't "translate" sample from java into C# next line:

com.sun.star.sheet.XNamedRanges xNamedRanges = (com.sun.star.sheet.XNamedRanges) UnoRuntime.queryInterface(com.sun.star.sheet.XNamedRanges.class, aRangesObj);

Because i haven't UnoRuntime object.. Do you have any idea?

Re: How i can set name of the range. (Calc)

Posted: Fri Mar 20, 2009 12:46 pm
by avalter
There is a text in the "DevGuide->Named Ranges": "The collection of named ranges is accessed using the document's NamedRanges property."

How i can get this property if i have object XSpreadSheetDocument?

Thanks.

Re: How i can set name of the range. (Calc)

Posted: Fri Mar 20, 2009 3:01 pm
by avalter
Resolved.
// SpreadSheetDocument _doc;
unoidl.com.sun.star.beans.XPropertySet xps = _doc as unoidl.com.sun.star.beans.XPropertySet;
XNamedRanges namedrange = (XNamedRanges)xps.getPropertyValue("NamedRanges").Value;
namedrange.addNewByName("TEST", "$Sheet1.$A$1", new unoidl.com.sun.star.table.CellAddress(0, 1, 1), 0);

Thanks.