Skip to content

Commit

Permalink
Start Adding Range Service
Browse files Browse the repository at this point in the history
  • Loading branch information
areed1192 committed Dec 31, 2021
1 parent f3c15ab commit b916680
Show file tree
Hide file tree
Showing 9 changed files with 728 additions and 11 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,4 @@ dmypy.json
.pyre/

# Alex Folder.
.vscode/
config/
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Run Client",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/samples/use_client.py",
"console": "integratedTerminal"
}
]
}
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,3 @@ pay monthly fees.

**YouTube:**
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).

<!-- **Hire Me:**
If you have a project, you think I can help you with feel free to reach out at [coding.sigma@gmail.com](mailto:coding.sigma@gmail.com?subject=[GitHub]%20Project%20Proposal) or fill out the [contract request form](https://forms.office.com/Pages/ResponsePage.aspx?id=DQSIkWdsW0yxEjajBLZtrQAAAAAAAAAAAAa__aAmF1hURFg5ODdaVTg1TldFVUhDVjJHWlRWRzhZRy4u) -->
16 changes: 15 additions & 1 deletion ms_graph/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from ms_graph.mail import Mail

from ms_graph.workbooks_and_charts.workbook import Workbooks

from ms_graph.workbooks_and_charts.range import Range

class MicrosoftGraphClient:

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

return workbook_service

def range(self) -> Range:
"""Used to access the Range Services and metadata.
### Returns
---
Range:
The `Range` services Object.
"""

# Grab the `Range` Object for the session.
range_service: Range = Range(session=self.graph_session)

return range_service
73 changes: 73 additions & 0 deletions ms_graph/utils/range.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
from dataclasses import dataclass


@dataclass
class RangeProperties:

"""
### Overview
----
A python dataclass which is used to represent Range Properties.
The Microsoft Graph API allows users to update Range objects and
this utility makes constructing those updates in a concise way that
is python friendly.
### Parameters
----
column_hidden : bool (optional, Default=None)
Represents if all columns of the current range are hidden.
formulas : list (optional, Default=None)
Represents the formula in A1-style notation.
formulas_local : list (optional, Default=None)
Represents the formula in A1-style notation, in the user's
language and number-formatting locale. For example, the
English "=SUM(A1, 1.5)" formula would become
"=SUMME(A1; 1,5)" in German.
formulas_r1c1 : list (optional, Default=None)
Represents the formula in R1C1-style notation.
number_format : str (optional, Default=None)
Represents Excel's number format code for the given cell.
row_hidden : bool (optional, Default=None)
Represents if all rows of the current range are hidden.
values : list (optional, Default=None)
Represents the raw values of the specified range. The
data returned could be of type string, number, or a
boolean. Cell that contain an error will return the
error string.
"""

column_hidden: bool
row_hidden: bool
formulas: list
formulas_local: list
formulas_r1c1: list
number_format: str
values: list

def to_dict(self) -> dict:
"""Generates a dictionary containing all the field
names and values.
### Returns
----
dict
The Field Name and Values.
"""

class_dict = {
"columnHidden": self.column_hidden,
"rowHidden": self.row_hidden,
"formulas": self.formulas,
"numberFormat": self.number_format,
"formulasR1C1": self.formulas_r1c1,
"formulasLocal": self.formulas_local,
"values": self.values,
}

return class_dict
27 changes: 21 additions & 6 deletions ms_graph/workbooks_and_charts/enums.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from enum import Enum


class CalculationTypes(Enum):
"""Specifies the calculation types used in the
`WorkbookApplication` calculate method.
Expand All @@ -10,9 +11,9 @@ class CalculationTypes(Enum):
>>> CalculationTypes.RECALCULATE.value
"""

RECALCULATE = 'Recaulcaute'
FULL = 'Full'
FULLREBUILD = 'FullRebuild'
RECALCULATE = "Recaulcaute"
FULL = "Full"
FULLREBUILD = "FullRebuild"


class WorksheetVisibility(Enum):
Expand All @@ -25,6 +26,20 @@ class WorksheetVisibility(Enum):
>>> WorksheetVisibility.VISIBLE.value
"""

VISIBLE = 'Visible'
HIDDEN = 'Hidden'
VERYHIDDEN = 'VeryHidden'
VISIBLE = "Visible"
HIDDEN = "Hidden"
VERYHIDDEN = "VeryHidden"


class RangeShift(Enum):
"""Specifies the shift directions used in the
`Range` `insert_range` method.
### Usage:
----
>>> from ms_graph.workbooks_and_charts.enums import RangeShift
>>> RangeShift.DOWN.value
"""

DOWN = "Down"
RIGHT = "Right"
Loading

0 comments on commit b916680

Please sign in to comment.