3

I am writing a dataframe to a spreadsheet, I bold, change font, etc, but I can't change the format to be a number format:

from gspread_formatting import *
import gspread
from df2gspread import df2gspread as d2g
import pandas as pd

d2g.upload(data, sheet.id, 'test_name', clean=True, credentials=creds, col_names=True, row_names=False)
worksheet = sheet.worksheet('test_name') 
worksheet.format("1", {
    "backgroundColor": {
      "red": 1.0,
      "green": 1.0,
      "blue": 1.0
    },
    "horizontalAlignment": "CENTER",
    "textFormat": {
      "fontSize": 12,
      "bold": True
    }})

worksheet.format("D:R", {            # <--- this does not work
      "numberFormat": {
      "type": "NUMBER"}
    })

    set_row_height(worksheet, '1:100', 40)
    set_column_width(worksheet, 'A:R', 125)

I am trying to follow this documentation. I also checked this answer.

But the format is still automatic and not a number.

Jonas Palačionis
  • 4,591
  • 4
  • 22
  • 55

1 Answers1

0

Is not a solution, I encountered with a similar problem, but my workaround was to create a Macro directly in the google sheet so it apply the format to the desired sheet.

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-ask). – Community Sep 19 '21 at 20:48