question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for Conditional Formatting

See original GitHub issue

Hey,

Thanks for making this library, it has significantly lowered the bar to working with Google Sheets for me. It would be awesome to have support for Conditional Formatting on columns.

https://developers.google.com/sheets/api/samples/conditional-formatting

It looks like it could fit well in to the range style notation, with some kwargs for the formatting options. If I get a chance I will create a PR.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:5
  • Comments:7

github_iconTop GitHub Comments

7reactions
alugowskicommented, Jun 13, 2018

FYI, you can easily make your own calls into the API from within gspread. Given a worksheet reference, i.e. wks = sh.sheet1 or somesuch:

body = {'requests': [
    {'repeatCell': {
        'range': {'startRowIndex': 0, 'endRowIndex': 1},
        'cell': {'userEnteredFormat': {'textFormat': {'bold': True}}},
        'fields': 'userEnteredFormat.textFormat.bold',
    }}
]}
wks.spreadsheet.batch_update(body)

Where body is the request as you see in your sample link. The conditional formatting one is long, so instead the above body makes the first row bold.

You can copy/paste from Google’s examples, just remove the sheetId keys as gspread populates those for you.

1reaction
lavigne958commented, May 9, 2021

Hi @andrewgross, this is definitely something that can be done with gspread. You can do it yourself like mentioned by @alugowski but a helper function in theWorksheet object could be nice.

Hi @vikrant-pune, we you mention is a different issue and is getting off-topic. Please open a new issue with you message, backtrack and you code snippet and we’ll help you from there. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use conditional formatting to highlight information
Conditional formatting can help make patterns and trends in your data more apparent. To use it, you create rules that determine the format...
Read more >
Highlight patterns and trends with conditional formatting
Conditional formatting makes it easy to highlight certain values or make particular cells easy to identify. This changes the appearance of a cell...
Read more >
Use conditional formatting rules in Google Sheets - Computer
On your computer, open a spreadsheet in Google Sheets. Select the cells you want to apply format rules to. Click Format and then...
Read more >
Excel Conditional Formatting tutorial with examples - Ablebits
To conditionally format your data, you can utilize preset rules such as Color Scales, Data Bars and Icon Sets or create custom rules...
Read more >
How to Combine Conditional Formatting with an IF Statement
For example, if you want to apply conditional formatting using a condition that “If a cell value is greater than a set value,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found