|
1 |
| -from typing import Optional |
| 1 | +from typing import List, Optional |
2 | 2 |
|
3 | 3 | from office365.entity import Entity
|
4 | 4 | from office365.onedrive.workbooks.ranges.format import WorkbookRangeFormat
|
5 | 5 | from office365.onedrive.workbooks.ranges.sort import WorkbookRangeSort
|
6 | 6 | from office365.onedrive.workbooks.ranges.view import WorkbookRangeView
|
7 | 7 | from office365.runtime.paths.resource_path import ResourcePath
|
8 | 8 | from office365.runtime.queries.function import FunctionQuery
|
| 9 | +from office365.runtime.queries.service_operation import ServiceOperationQuery |
9 | 10 |
|
10 | 11 |
|
11 | 12 | class WorkbookRange(Entity):
|
12 | 13 | """Range represents a set of one or more contiguous cells such as a cell, a row, a column, block of cells, etc."""
|
13 | 14 |
|
| 15 | + def cell(self, row, column): |
| 16 | + """ |
| 17 | + Gets the range object containing the single cell based on row and column numbers. The cell can be outside |
| 18 | + the bounds of its parent range, so long as it's stays within the worksheet grid. |
| 19 | + :param int row: Row number of the cell to be retrieved. Zero-indexed. |
| 20 | + :param int column: Column number of the cell to be retrieved. Zero-indexed. |
| 21 | + """ |
| 22 | + return_type = WorkbookRange(self.context) |
| 23 | + params = {"row": row, "column": column} |
| 24 | + qry = FunctionQuery(self, "cell", params, return_type=return_type) |
| 25 | + self.context.add_query(qry) |
| 26 | + return return_type |
| 27 | + |
| 28 | + def clear(self, apply_to=None): |
| 29 | + """Clear range values such as format, fill, and border. |
| 30 | + :param str apply_to: |
| 31 | + """ |
| 32 | + payload = {"applyTo": apply_to} |
| 33 | + qry = ServiceOperationQuery(self, "clear", parameters_type=payload) |
| 34 | + self.context.add_query(qry) |
| 35 | + return self |
| 36 | + |
| 37 | + def insert(self, shift): |
| 38 | + """ |
| 39 | + Inserts a cell or a range of cells into the worksheet in place of this range, and shifts the other cells to |
| 40 | + make space. Returns a new Range object at the now blank space. |
| 41 | + :param str shift: Specifies which way to shift the cells. The possible values are: Down, Right. |
| 42 | + """ |
| 43 | + return_type = WorkbookRange(self.context) |
| 44 | + payload = {"shift": shift} |
| 45 | + qry = ServiceOperationQuery( |
| 46 | + self, "insert", parameters_type=payload, return_type=return_type |
| 47 | + ) |
| 48 | + self.context.add_query(qry) |
| 49 | + return return_type |
| 50 | + |
14 | 51 | def visible_view(self):
|
15 |
| - """""" |
| 52 | + """Get the range visible from a filtered range.""" |
16 | 53 | return_type = WorkbookRangeView(self.context)
|
17 | 54 | qry = FunctionQuery(self, "visibleView", return_type=return_type)
|
18 | 55 | self.context.add_query(qry)
|
@@ -63,6 +100,20 @@ def sort(self):
|
63 | 100 | WorkbookRangeSort(self.context, ResourcePath("sort", self.resource_path)),
|
64 | 101 | )
|
65 | 102 |
|
| 103 | + @property |
| 104 | + def values(self): |
| 105 | + # type: () -> List |
| 106 | + """Represents the raw values of the specified range. The data returned could be of type string, number, |
| 107 | + or a boolean. Cell that contains an error returns the error string.""" |
| 108 | + return self.properties.get("values", None) |
| 109 | + |
| 110 | + @property |
| 111 | + def value_types(self): |
| 112 | + # type: () -> List |
| 113 | + """Represents the type of data of each cell. The possible values are: |
| 114 | + Unknown, Empty, String, Integer, Double, Boolean, Error.""" |
| 115 | + return self.properties.get("valueTypes", None) |
| 116 | + |
66 | 117 | @property
|
67 | 118 | def worksheet(self):
|
68 | 119 | """The worksheet containing the current range"""
|
|
0 commit comments