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);
}
});