我想通过Google Sheet API设置单元格(或单元格组)的背景色。
我编写了此请求,当我编写该请求时,它完美地工作了.setFields("*")
,但是我不能这样做,因为它会覆盖我对该单元执行的所有先前请求。
因此,我.setFields("backgroundColor")
根据在此文档中看到的字段名称进行指定。但我得到一个错误:
"message" : "Invalid requests[1].repeatCell: Invalid field: background_color",
请注意,backgroundColor已成为background_color。
我尝试了其他字符串,例如color,backgroundcolor ...,但是没有任何效果。我不知道该怎么办。
Color XgoogleColor = new Color().setRed(1f).setGreen(0f).setBlue(0f); // Color.RED
return new Request()
.setRepeatCell(new RepeatCellRequest()
.setCell(new CellData()
.setUserEnteredFormat(new CellFormat()
.setBackgroundColor(XgoogleColor)
)
)
.setRange(new GridRange()
.setSheetId(sheetId)
.setStartRowIndex(startRow)
.setEndRowIndex(endRow)
.setStartColumnIndex(startColumn)
.setEndColumnIndex(endColumn)
)
.setFields("backgroundColor")
);
我相信您的情况和目标如下。
.setFields("*")
使用时,该脚本有效。backgroundColor
。在这种情况下,请进行以下修改。
.setFields("backgroundColor")
.setFields("userEnteredFormat.backgroundColor")
backgroundColor
被更新。本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句