你想更新“ab1:ad1”(
{startRowIndex: 0, endRowIndex: 1, startColumnIndex: 27, endColumnIndex: 30}
)如果我的理解是正确的,那么这次修改怎么样?
修改点:
-
更新3列时,还需要更新值。在您的情况下,需要更新3列。所以需要创造
{values: [{userEnteredFormat: ###}, {userEnteredFormat: ###}, {userEnteredFormat: ###}]}
.
修改请求:
{
"requests":
[
{
"updateCells":
{
"rows":
[
{
"values":
[
{
"userEnteredFormat":
{
"horizontalAlignment": align , #'CENTER','LEFT','RIGHT',
"textFormat":
{
"fontFamily": fontFamily,
"fontSize": fontSize
}
}
},
{
"userEnteredFormat":
{
"horizontalAlignment": align , #'CENTER','LEFT','RIGHT',
"textFormat":
{
"fontFamily": fontFamily,
"fontSize": fontSize
}
}
},
{
"userEnteredFormat":
{
"horizontalAlignment": align , #'CENTER','LEFT','RIGHT',
"textFormat":
{
"fontFamily": fontFamily,
"fontSize": fontSize
}
}
}
]
}
],
"range":
{
"sheetId": sheetId,
"startRowIndex": startRowIndex,
"endRowIndex": endRowIndex,
"startColumnIndex": startColumnIndex,
"endColumnIndex": endColumnIndex
},
"fields": "userEnteredFormat",
}
}
]
}
如果我误解了你的问题,请告诉我。我想修改一下。
编辑:
如果要反映许多单元格的格式,可以使用
repeatCell
. 请求主体如下。在此示例中,该范围内的所有单元格都将被修改。
修改请求:
{
"requests":
[
{
"repeatCell":
{
"cell":
{
"userEnteredFormat":
{
"horizontalAlignment": align , #'CENTER','LEFT','RIGHT',
"textFormat":
{
"fontFamily": fontFamily,
"fontSize": fontSize
}
}
},
"range":
{
"sheetId": sheetId,
"startRowIndex": startRowIndex,
"endRowIndex": endRowIndex,
"startColumnIndex": startColumnIndex,
"endColumnIndex": endColumnIndex
},
"fields": "userEnteredFormat"
}
}
]
}
参考文献: