现在我使用下面的代码来格式化和插入值。
function AddName () {
const range1 = ['Q4:Q','S4:S','U4:U','W4:W','Y4:Y','AA4:AA','AC4:AC','AE4:AE',
'AG4:AG','AI4:AI','AK4:AK','AM4:AM','AO4:AO','AQ4:AQ','AS4:AS','AU4:AU','AW4:AW','AY4:AY','BA4:BA',
'BC4:BC','BE4:BE','BG4:BG','BI4:BI','BK4:BK','BM4:BM','BO4:BO','BQ4:BQ','BS4:BS','BU4:BU','BW4:BW',
'BY4:BY','CA4:CA','CC4:CC','CE4:CE','CG4:CG','CI4:CI','CK4:CK','CM4:CM','CO4:CO','CQ4:CQ','CS4:CS',
'CU4:CU','CW4:CW','CY4:CY','DA4:DA','DC4:DC','DE4:DE','DG4:DG','DI4:DI','DK4:DK','DM4:DM','DO4:DO',
'DQ4:DQ','DS4:DS','DU4:DU','DW4:DW','DY4:DY','EA4:EA','EC4:EC','EE4:EE','EG4:EG','EI4:EI','EK4:EK',
'EM4:EM','EO4:EO'];
range1.reverse().forEach(c => sheet.getRange(c).setNumberFormat('0.00%'));
const range = ['Q1','S1','U1','W1','Y1','AA1','AC1','AE1','AG1','AI1','AK1',
'AM1','AO1','AQ1','AS1','AU1','AW1','AY1','BA1','BC1','BE1','BG1','BI1','BK1','BM1','BO1','BQ1',
'BS1','BU1','BW1','BY1','CA1','CC1','CE1','CG1','CI1','CK1','CM1','CO1','CQ1','CS1','CU1','CW1',
'CY1','DA1','DC1','DE1','DG1','DI1','DK1','DM1','DO1','DQ1','DS1','DU1','DW1','DY1','EA1','EC1',
'EE1','EG1','EI1','EK1','EM1','EO1'];
range.reverse().forEach(c => sheet.getRange(c).setValue('% наценки'));
}
是否可以进一步降低请求成本并加快脚本速度?格式化很多文件时,它会为我节省很多时间