【发布时间】:2020-11-06 20:40:15
【问题描述】:
我正在尝试使用 Node.js 更改谷歌表格中单元格/文本颜色/边框的颜色。我有一些数据,我想将这些数据放在工作表中,并根据条件突出显示某些行。当我使用sheets.spreadsheets.values.update 时,输入数据部分有效。作为突出显示的基本测试,我尝试像这样更改单元格 A1 的一些属性:
sheets.spreadsheets
.batchUpdate({
spreadsheetId: masterOrderSheetID,
resource: {
requests: [
{
updateCells: {
start: {
sheetId: 0,
rowIndex: 0,
columnIndex: 0,
},
fields: '*',
rows: [
{
values: [
{
effectiveValue: {
stringValue: 'hello please',
},
effectiveFormat: {
backgroundColor: {
red: 1,
green: 0,
blue: 0,
alpha: 0.5,
},
backgroundColorStyle: {
rgbColor: {
red: 1,
green: 0,
blue: 0,
alpha: 0.5,
},
},
textRotation: {
angle: 45,
},
},
},
],
},
],
},
},
],
includeSpreadsheetInResponse: true,
responseIncludeGridData: true,
},
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
但所发生的只是单元格 A1 上的格式被重置(我手动将其设置为粗体,然后取消设置粗体)。该值未设置为'hello please'。
如何设置单元格(或单元格范围)的颜色?
【问题讨论】:
标签: node.js google-sheets google-api