Skip to content

Commit b916680

Browse files
committed
Start Adding Range Service
1 parent f3c15ab commit b916680

File tree

9 files changed

+728
-11
lines changed

9 files changed

+728
-11
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,5 +129,4 @@ dmypy.json
129129
.pyre/
130130

131131
# Alex Folder.
132-
.vscode/
133132
config/

.vscode/launch.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Python: Run Client",
9+
"type": "python",
10+
"request": "launch",
11+
"program": "${workspaceFolder}/samples/use_client.py",
12+
"console": "integratedTerminal"
13+
}
14+
]
15+
}

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,3 @@ pay monthly fees.
139139

140140
**YouTube:**
141141
If you'd like to watch more of my content, feel free to visit my YouTube channel [Sigma Coding](https://www.youtube.com/c/SigmaCoding).
142-
143-
<!-- **Hire Me:**
144-
If you have a project, you think I can help you with feel free to reach out at [[email protected]](mailto:[email protected]?subject=[GitHub]%20Project%20Proposal) or fill out the [contract request form](https://forms.office.com/Pages/ResponsePage.aspx?id=DQSIkWdsW0yxEjajBLZtrQAAAAAAAAAAAAa__aAmF1hURFg5ODdaVTg1TldFVUhDVjJHWlRWRzhZRy4u) -->

ms_graph/client.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from ms_graph.mail import Mail
2222

2323
from ms_graph.workbooks_and_charts.workbook import Workbooks
24-
24+
from ms_graph.workbooks_and_charts.range import Range
2525

2626
class MicrosoftGraphClient:
2727

@@ -477,3 +477,17 @@ def workbooks(self) -> Workbooks:
477477
workbook_service: Workbooks = Workbooks(session=self.graph_session)
478478

479479
return workbook_service
480+
481+
def range(self) -> Range:
482+
"""Used to access the Range Services and metadata.
483+
484+
### Returns
485+
---
486+
Range:
487+
The `Range` services Object.
488+
"""
489+
490+
# Grab the `Range` Object for the session.
491+
range_service: Range = Range(session=self.graph_session)
492+
493+
return range_service

ms_graph/utils/range.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
from dataclasses import dataclass
2+
3+
4+
@dataclass
5+
class RangeProperties:
6+
7+
"""
8+
### Overview
9+
----
10+
A python dataclass which is used to represent Range Properties.
11+
The Microsoft Graph API allows users to update Range objects and
12+
this utility makes constructing those updates in a concise way that
13+
is python friendly.
14+
15+
### Parameters
16+
----
17+
column_hidden : bool (optional, Default=None)
18+
Represents if all columns of the current range are hidden.
19+
20+
formulas : list (optional, Default=None)
21+
Represents the formula in A1-style notation.
22+
23+
formulas_local : list (optional, Default=None)
24+
Represents the formula in A1-style notation, in the user's
25+
language and number-formatting locale. For example, the
26+
English "=SUM(A1, 1.5)" formula would become
27+
"=SUMME(A1; 1,5)" in German.
28+
29+
formulas_r1c1 : list (optional, Default=None)
30+
Represents the formula in R1C1-style notation.
31+
32+
number_format : str (optional, Default=None)
33+
Represents Excel's number format code for the given cell.
34+
35+
row_hidden : bool (optional, Default=None)
36+
Represents if all rows of the current range are hidden.
37+
38+
values : list (optional, Default=None)
39+
Represents the raw values of the specified range. The
40+
data returned could be of type string, number, or a
41+
boolean. Cell that contain an error will return the
42+
error string.
43+
"""
44+
45+
column_hidden: bool
46+
row_hidden: bool
47+
formulas: list
48+
formulas_local: list
49+
formulas_r1c1: list
50+
number_format: str
51+
values: list
52+
53+
def to_dict(self) -> dict:
54+
"""Generates a dictionary containing all the field
55+
names and values.
56+
57+
### Returns
58+
----
59+
dict
60+
The Field Name and Values.
61+
"""
62+
63+
class_dict = {
64+
"columnHidden": self.column_hidden,
65+
"rowHidden": self.row_hidden,
66+
"formulas": self.formulas,
67+
"numberFormat": self.number_format,
68+
"formulasR1C1": self.formulas_r1c1,
69+
"formulasLocal": self.formulas_local,
70+
"values": self.values,
71+
}
72+
73+
return class_dict

ms_graph/workbooks_and_charts/enums.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from enum import Enum
22

3+
34
class CalculationTypes(Enum):
45
"""Specifies the calculation types used in the
56
`WorkbookApplication` calculate method.
@@ -10,9 +11,9 @@ class CalculationTypes(Enum):
1011
>>> CalculationTypes.RECALCULATE.value
1112
"""
1213

13-
RECALCULATE = 'Recaulcaute'
14-
FULL = 'Full'
15-
FULLREBUILD = 'FullRebuild'
14+
RECALCULATE = "Recaulcaute"
15+
FULL = "Full"
16+
FULLREBUILD = "FullRebuild"
1617

1718

1819
class WorksheetVisibility(Enum):
@@ -25,6 +26,20 @@ class WorksheetVisibility(Enum):
2526
>>> WorksheetVisibility.VISIBLE.value
2627
"""
2728

28-
VISIBLE = 'Visible'
29-
HIDDEN = 'Hidden'
30-
VERYHIDDEN = 'VeryHidden'
29+
VISIBLE = "Visible"
30+
HIDDEN = "Hidden"
31+
VERYHIDDEN = "VeryHidden"
32+
33+
34+
class RangeShift(Enum):
35+
"""Specifies the shift directions used in the
36+
`Range` `insert_range` method.
37+
38+
### Usage:
39+
----
40+
>>> from ms_graph.workbooks_and_charts.enums import RangeShift
41+
>>> RangeShift.DOWN.value
42+
"""
43+
44+
DOWN = "Down"
45+
RIGHT = "Right"

0 commit comments

Comments
 (0)