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

DataRange.apply_format() does not work for Date Format #577

Open
rabdelazim opened this issue Mar 6, 2023 · 1 comment
Open

DataRange.apply_format() does not work for Date Format #577

rabdelazim opened this issue Mar 6, 2023 · 1 comment

Comments

@rabdelazim
Copy link

rabdelazim commented Mar 6, 2023

It's (always) possible I'm doing something wrong but I can't seem to get my column to set the Date format I need. Here's what I have:
First I get Columns "I" and "K" and move them to the first two columns (and delete the original columns I and K).

titles = client.spreadsheet_titles()
test_sheet = client.open(titles[0])
test_worksheets = test_sheet.worksheets()
active = test_worksheets[worksheet.index]
ord_to_ship_date = active.get_values("I1","I")
count = active.get_values("K1","K")
active.delete_cols(9)
active.delete_cols(10)
active.insert_cols(0,2)
active.update_values_batch(['A1:A', 'B1:B'], [ord_to_ship_date, count])

this works no problem.
Now the first column is a date field but it's in the wrong format. I need it to start with the day of the week followed by the day of month, month and year. I tried the following:

active.get_col(1, returnas = "range").apply_format(pygsheets.Cell('A2').set_number_format(pygsheets.FormatType.DATE, 'dddd+ mmmm yyy'))

This last call "succeeds" (i.e. no error message or anything. Just fails silently.) but doesn't update the format in my spreadsheet.

Any insight here would be greatly appreciated.

SO question for anyone interested: https://stackoverflow.com/questions/75654608/pygsheets-does-not-modify-date-format

@rabdelazim
Copy link
Author

It looks as though moving the column from one place to another adds a tick ` to the beginning of the value in the cell. I'm guessing this is to maintain the original formatting. Unfortunately the tick mark doesn't get removed before writing the data back to the spreadsheet so the date formatting doesn't get applied.
My workaround is to modify the date format before moving the column which makes me think this isn't quite a bug but would be nice to have better functionality around this. Theoretically it shouldn't matter if I change the format before or after the values are moved.

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