|
| 1 | +from typing import Optional |
| 2 | + |
1 | 3 | from office365.entity import Entity |
| 4 | +from office365.onedrive.workbooks.ranges.range import WorkbookRange |
2 | 5 | from office365.runtime.paths.resource_path import ResourcePath |
| 6 | +from office365.runtime.queries.function import FunctionQuery |
3 | 7 |
|
4 | 8 |
|
5 | 9 | class WorkbookNamedItem(Entity): |
6 | 10 | """Represents a defined name for a range of cells or value. Names can be primitive named objects |
7 | 11 | (as seen in the type below), range object, reference to a range. This object can be used to obtain range |
8 | 12 | object associated with names.""" |
9 | 13 |
|
| 14 | + def range(self): |
| 15 | + """Returns the range object that is associated with the name. Throws an exception if the named item's type |
| 16 | + isn't a range.""" |
| 17 | + return_type = WorkbookRange( |
| 18 | + self.context, ResourcePath("range", self.resource_path) |
| 19 | + ) |
| 20 | + qry = FunctionQuery(self, "range", return_type=return_type) |
| 21 | + self.context.add_query(qry) |
| 22 | + return return_type |
| 23 | + |
10 | 24 | @property |
11 | 25 | def name(self): |
12 | | - """The name of the object. Read-only. |
13 | | - :rtype str or None |
14 | | - """ |
| 26 | + # type: () -> Optional[str] |
| 27 | + """The name of the object.""" |
15 | 28 | return self.properties.get("name", None) |
16 | 29 |
|
17 | 30 | @property |
18 | 31 | def comment(self): |
19 | | - """Represents the comment associated with this name. |
20 | | - :rtype str or None |
21 | | - """ |
| 32 | + # type: () -> Optional[str] |
| 33 | + """Represents the comment associated with this name.""" |
22 | 34 | return self.properties.get("comment", None) |
23 | 35 |
|
24 | 36 | @property |
|
0 commit comments