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

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
avalter
Posts: 4
Joined: Fri Mar 20, 2009 11:04 am

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

Post 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.
Last edited by Hagar Delest on Fri Mar 20, 2009 4:49 pm, edited 1 time in total.
Reason: tagged [Solved].
OOo 3.0.X on Ms Windows XP + OpenSUSE 11.1
B Marcelly
Volunteer
Posts: 1160
Joined: Mon Oct 08, 2007 1:26 am
Location: France, Paris area

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

Post by B Marcelly »

Hi,
As usual, read the Developer's Guide.
http://wiki.services.openoffice.org/wik ... med_Ranges
______
Bernard
avalter
Posts: 4
Joined: Fri Mar 20, 2009 11:04 am

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

Post 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?
OOo 3.0.X on Ms Windows XP + OpenSUSE 11.1
avalter
Posts: 4
Joined: Fri Mar 20, 2009 11:04 am

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

Post 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.
OOo 3.0.X on Ms Windows XP + OpenSUSE 11.1
avalter
Posts: 4
Joined: Fri Mar 20, 2009 11:04 am

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

Post 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.
OOo 3.0.X on Ms Windows XP + OpenSUSE 11.1
Post Reply