谷歌表水平对齐 [英] google sheets horizontal alignment

查看:45
本文介绍了谷歌表水平对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将单元格格式更改为文本的水平对齐方式.无法正常工作.到目前为止,这是我的代码.

I'm trying to change a cell format to horizontal alignment for the text. Can't get it to work. Here is my code so far.

data={
  "requests":[
  {
    "horizontalAlignment": {
        'range': {
            "sheetId": sheetId,
            "startRowIndex": 0,
            "endRowIndex": 10,
            "startColumnIndex": 0,
            "endColumnIndex": 1
        },
        'Center'
    }
  }

  ]
}


result = g.service.spreadsheets().batchUpdate(spreadsheetId=key, body=data).execute()

不确定如何在其中使用水平对齐方式指定范围.

not sure how to specify the range in there with the horizontal alignment.

推荐答案

此修改如何?

data={
  "requests": 
  [
    {
      "updateCells": 
      {
        "rows": 
        [
          {
            "values": 
            [
              {
                "userEnteredFormat": 
                {
                  "horizontalAlignment": "CENTER"
                }
              }
            ]
          }
        ],
        "range": 
        {
          "sheetId": sheetId,
          "startRowIndex": 0,
          "endRowIndex": 10,
          "startColumnIndex": 0,
          "endColumnIndex": 1
        },
        "fields": "userEnteredFormat"
      }
    }
  ]
}

result = g.service.spreadsheets().batchUpdate(spreadsheetId=key, body=data).execute()

参考:

  • REST资源:电子表格
  • 如果我误解了您的问题,请告诉我.我想修改我的答案.

    If I misunderstand your question, please tell me. I would like to modify my answer.

    这篇关于谷歌表水平对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆