Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get cell colors and other decorations #1313

Open
Halone228 opened this issue Oct 6, 2023 · 3 comments
Open

Get cell colors and other decorations #1313

Halone228 opened this issue Oct 6, 2023 · 3 comments

Comments

@Halone228
Copy link

Halone228 commented Oct 6, 2023

In my task, I need to get the color of the cell and different logic will be executed from the color.
I managed to find a small amount of information on how to get such data, namely, to pass the includeGridData parameter with the value true to the get method. Finded solution. Code example of working prototype

url = f"{urls.SPREADSHEETS_API_V4_BASE_URL}/{j.id}?includeGridData=true&ranges=Q1"
data = acc.request('get', url)
print(data.json()['sheets'][0]['data'][0]['rowData'][0]['values'][0]['effectiveFormat']['backgroundColor'])

acc its service_account

{'blue': 0.65882355, 'green': 0.84313726, 'red': 0.7137255}
{'backgroundColor': {'blue': 0.65882355, 'green': 0.84313726, 'red': 0.7137255},
 'backgroundColorStyle': {'rgbColor': {'blue': 0.65882355,
                                       'green': 0.84313726,
                                       'red': 0.7137255}},
 'borders': {'bottom': {'color': {},
                        'colorStyle': {'rgbColor': {}},
                        'style': 'SOLID',
                        'width': 1},
             'left': {'color': {},
                      'colorStyle': {'rgbColor': {}},
                      'style': 'SOLID',
                      'width': 1},
             'right': {'color': {},
                       'colorStyle': {'rgbColor': {}},
                       'style': 'SOLID',
                       'width': 1},
             'top': {'color': {},
                     'colorStyle': {'rgbColor': {}},
                     'style': 'SOLID',
                     'width': 1}},
 'horizontalAlignment': 'CENTER',
 'hyperlinkDisplayType': 'PLAIN_TEXT',
 'padding': {'bottom': 2, 'left': 3, 'right': 3, 'top': 2},
 'textFormat': {'bold': False,
                'fontFamily': 'Arial',
                'fontSize': 10,
                'foregroundColor': {},
                'foregroundColorStyle': {'rgbColor': {}},
                'italic': False,
                'strikethrough': False,
                'underline': False},
 'verticalAlignment': 'MIDDLE',
 'wrapStrategy': 'WRAP'}

result of pprint(data.json()['sheets'][0]['data'][0]['rowData'][0]['values'][0]['effectiveFormat'])
The 'values' key stores data for a specific row specified in the range, and 'rowData' stores all rows specified in the range.

@lavigne958
Copy link
Collaborator

Hi I'm sorry but I don't understand where is the issue with gspread.

Did you try to use gspread to get the data and the cell values ?

@Halone228
Copy link
Author

There are no problems with gspread, I marked this issue as a Feature Request

@lavigne958
Copy link
Collaborator

I see, you might be looking for the package gspread-format then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants