簡體   English   中英

我們如何使用 php 更改 google docs api 表中整行的背景顏色?

[英]How we can change the background color for the entire row in table with google docs api using php?

我想在一個 go 更改整行表格的背景顏色。但是我可以從下面的代碼請求中為特定單元格設置背景顏色。

$requests = [
    new Google_Service_Docs_Request([
        'insertTable' => [
            'location' => ['index' => 1],
            'columns' => 2,
            'rows' => 2
        ]
    ]),
    new Google_Service_Docs_Request([
    "updateTableCellStyle" => [
        "tableCellStyle" => [
          "backgroundColor" => [
            "color" => [
                "rgbColor" => [
                    "red" => 0.8,
                    "green" => 0.8,
                    "blue" => 0.8,
                ]
            ]
        ]
    ],
        "fields" => "backgroundColor",
        "tableRange" => [
            "columnSpan" => 1,
            "rowSpan" => 1,
            "tableCellLocation" => [
              "columnIndex" => 1,
              "rowIndex" => 1,
              "tableStartLocation" => [
                "index" => 2
              ]
            ]
        ]
    ]
]),
];

任何人都可以告訴我我必須在上面的代碼中修改什么,或者我在使用 PHP 為 go 和 google 文檔 api 中的整行添加背景顏色時犯了什么錯誤。

從你的請求體中,發現插入的表格有2列。 在這種情況下,當你想為第2行的“A”和“B”列都設置背景顏色時,如何進行以下修改?

從:

"tableRange" => [
    "columnSpan" => 1,
    "rowSpan" => 1,
    "tableCellLocation" => [
      "columnIndex" => 1,
      "rowIndex" => 1,
      "tableStartLocation" => [
        "index" => 2
      ]
    ]
]

到:

"tableRange" => [
    "columnSpan" => 2,
    "rowSpan" => 1,
    "tableCellLocation" => [
      "rowIndex" => 1,
      "tableStartLocation" => [
        "index" => 2
      ]
    ]
]

筆記:

  • 例如,當你想為第1行的“A”和“B”列都設置背景色時,請修改如下。

     "tableRange" => [ "columnSpan" => 2, "rowSpan" => 1, "tableCellLocation" => [ "rowIndex" => 0, // Modified "tableStartLocation" => [ "index" => 2 ] ] ]

參考:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM