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

Problem with an absolute reference for add_validation #1539

Open
hippiuS opened this issue Jan 11, 2025 · 0 comments
Open

Problem with an absolute reference for add_validation #1539

hippiuS opened this issue Jan 11, 2025 · 0 comments

Comments

@hippiuS
Copy link

hippiuS commented Jan 11, 2025

Describe the bug
When adding validation like one_of_range for a range, for example, A5:A, an absolute reference is placed instead of the specified reference. For example, =Sheet1!$C5:$W5 turns into =Sheet1!$C$5:$W$5

To Reproduce
Steps to reproduce the behavior:

  1. Run the code from the code example block

Expected behavior
I expect to get a non-absolute reference to the range in the values field, as in Screenshot 1. For the screenshot, I did it through the browser.

Code example*

from gspread.auth import authorize
from google.oauth2.service_account import Credentials
from gspread.utils import ValidationConditionType

credentials_path = PATH_TO_CREDS_HERE
sheet_id = SHEET_ID_HERE

scopes = [
    "https://www.googleapis.com/auth/spreadsheets",
    "https://www.googleapis.com/auth/drive",
]
creds = Credentials.from_service_account_file(credentials_path, scopes=scopes)
client = authorize(creds)
spreadsheet = client.open_by_key(sheet_id )
worksheet = spreadsheet.sheet1

worksheet.add_validation(
    range="A5:A",
    condition_type=ValidationConditionType.one_of_range,
    values=["=Sheet1!$С5:$W5"],
    inputMessage="Select a value from the list",
    strict=True,
    showCustomUi=True
)

Screenshots
should be:
should be
I got:
I got

Environment info:

  • Operating System: Windows
  • Python version: 3.12.3
  • gspread version: 6.1.4

Additional context
Perhaps this is a problem with the API implementation from Google itself, I tried adding it via batch_update and it also didn't work as expected.

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

No branches or pull requests

1 participant