2
我试图自动将新格式应用于我的电子表格,但虽然它看起来不会导致任何错误,但它不起作用。如何使用sheets.spreadsheets.batchUpdate()来应用格式?
我的目标是将持续时间格式应用于电子表格的G和H列(索引6和7)。我自动更新与在格式字符串数据电子表格不带括号:
[D]:[H]:[M]
凡d,H,并且M可以是单面或双面的数字。我想它在下面的格式不带括号的电子表格上显示:
[hh]:[mm]:[ss]
哪里有总是在每列至少两个数字。但是,电子表格似乎会自动选择格式,无论我要求的格式如何,它都会选择一种十进制数字格式。如何使用batchUpdate()函数将工作持续时间格式应用于这两列?
我的代码尝试如下。我正在使用Node.js Google API客户端库。
sheets.spreadsheets.batchUpdate({
spreadsheetId: '1AakOf_W90JdAtL0R8XeMmacWrnBx8wLKrMCdHdnNmhM',
resource: {
requests: [{
updateCells:{
range: {
startColumnIndex: 6,
endColumnIndex: 8
},
'fields': 'userEnteredFormat/numberFormat(pattern,type),effectiveFormat/numberFormat(pattern,type)',
rows:[{
values:[{
userEnteredFormat:{
numberFormat:{
pattern: '[hh]:[mm]:[ss]',
type: 'TIME'
}
},
effectiveFormat:{
numberFormat:{
pattern: '[hh]:[mm]:[ss]',
type: 'TIME'
}
}
}]
}]
}
}
]
}
}, function(err, response, responseBody){
if(err){
console.log(err);
console.log(err.code);
}
});