Google 工作表 API (Java) - 更新格式

Google Sheets API (Java) - Update Formatting

我在 Java 中找不到有关使用 API 更新格式的文档。我的目标是修改行高和单元格背景颜色。有谁知道这是如何完成的,或者可以 link 我查看文档吗?

我正在使用 Google Sheet API v4.

编辑:

在我回顾时,我现在意识到 Google API 文档实际上很容易阅读。感谢所有帮助过我的人。

Adjusting column width or row height

Setting cell background color

关于如何将颜色设置为蓝色的示例:

blue = 255/255 = 1
red = 0/255 = 0
green = 0/255 = 0

示例请求正文:

{
  "requests": [
    {
      "updateCells": {
        "rows": [
          {
            "values": [
              {
                "userEnteredFormat": {
                  "backgroundColor": {
                    "blue": 1,
                    "red": 0,
                    "green": 0
                  }
                }
              }
            ]
          }
        ],
        "range": {
          "endColumnIndex": 1,
          "endRowIndex": 1,
          "sheetId": 0,
          "startColumnIndex": 0,
          "startRowIndex": 0
        },
        "fields": "userEnteredFormat"
      }
    },
    {
      "updateDimensionProperties": {
        "range": {
          "sheetId": 0,
          "dimension": "ROWS",
          "startIndex": 0,
          "endIndex": 2
        },
        "properties": {
          "pixelSize": 160
        },
        "fields": "pixelSize"
      }
    }
  ]
}

示例输出:

其他参考资料:

Java Quickstart - How to use Sheets API

Basic Formatting - How to change appearance of sheets and cells

Sheets API -Samples

Sheets API - REST Resources