У меня много листов, я положил их в папку.
Я хочу применить форматирование ко всем листам. например, создание границ, выделение жирным шрифтом первой строки и применение условного форматирования. другая вещь идет отлично, но возникает некоторая проблема с условным форматированием. он говорит TypeError: Sheet не является объектом XML. на каждом запуске условного форматирования. код:
function ledgerformatting() {
var fol = "1mg729p0ARzfxbdWTJQ23zELfeXQElP-v";
var folders = DriveApp.getFolderById(fol).getFiles();
while (folders.hasNext()) {
var folder = folders.next().getId();
var spreadsheet = SpreadsheetApp.openById(folder).getActiveSheet()
spreadsheet.getRange('A1').activate();
spreadsheet.getCurrentCell().setValue('date');
spreadsheet.getRange('C1').activate();
spreadsheet.getCurrentCell().setValue('debited');
spreadsheet.getRange('D1').activate();
spreadsheet.getCurrentCell().setValue('credited');
spreadsheet.getRange('A1:E1').activate();
spreadsheet.getActiveRangeList().setFontWeight('bold')
.setHorizontalAlignment('right')
.setBorder(null, null, true, null, null, null, '#000000', SpreadsheetApp.BorderStyle.SOLID_THICK);
spreadsheet.getRange('E:E').activate();
var conditionalFormatRules = spreadsheet..getConditionalFormatRules();
conditionalFormatRules.push(SpreadsheetApp.newConditionalFormatRule()
.setRanges([spreadsheet.getRange('E1:E1000')])
.whenCellNotEmpty()
.setBackground('#B7E1CD')
.build());
spreadsheet.getActiveSheet().setConditionalFormatRules (conditionalFormatRules);
conditionalFormatRules = spreadsheet.getActiveSheet ().getConditionalFormatRules();
conditionalFormatRules.splice(conditionalFormatRules.length - 1, 1, SpreadsheetApp.newConditionalFormatRule()
.setRanges([spreadsheet.getRange('E1:E1000')])
.whenFormulaSatisfied('=if')
.setBackground('#B7E1CD')
.build());
spreadsheet.getActiveSheet().setConditionalFormatRules (conditionalFormatRules);
conditionalFormatRules = spreadsheet.getActiveSheet ().getConditionalFormatRules();
conditionalFormatRules.splice(conditionalFormatRules.length - 1, 1, SpreadsheetApp.newConditionalFormatRule()
.setRanges([spreadsheet.getRange('E1:E1000')])
.whenFormulaSatisfied('=i')
.setBackground('#B7E1CD')
.build());
spreadsheet.getActiveSheet().setConditionalFormatRules (conditionalFormatRules);
conditionalFormatRules = spreadsheet.getActiveSheet ().getConditionalFormatRules();
conditionalFormatRules.splice(conditionalFormatRules.length - 1, 1, SpreadsheetApp.newConditionalFormatRule()
.setRanges([spreadsheet.getRange('E1:E1000')])
.whenFormulaSatisfied('=$B1')
.setBackground('#B7E1CD')
.build());
spreadsheet.getActiveSheet().setConditionalFormatRules (conditionalFormatRules);
conditionalFormatRules = spreadsheet.getActiveSheet ().getConditionalFormatRules();
conditionalFormatRules.splice(conditionalFormatRules.length - 1, 1, SpreadsheetApp.newConditionalFormatRule()
.setRanges([spreadsheet.getRange('E1:E1000')])
.whenFormulaSatisfied('=$B1:B')
.setBackground('#B7E1CD')
.build());
spreadsheet.getActiveSheet().setConditionalFormatRules (conditionalFormatRules);
conditionalFormatRules = spreadsheet.getActiveSheet ().getConditionalFormatRules();
conditionalFormatRules.splice(conditionalFormatRules.length - 1, 1, SpreadsheetApp.newConditionalFormatRule()
.setRanges([spreadsheet.getRange('E1:E1000')])
.whenFormulaSatisfied('=$B1:B2')
.setBackground('#B7E1CD')
.build());
spreadsheet.getActiveSheet().setConditionalFormatRules(conditionalFormatRules);
conditionalFormatRules = spreadsheet.getActiveSheet().getConditionalFormatRules();
conditionalFormatRules.splice(conditionalFormatRules.length - 1, 1, SpreadsheetApp.newConditionalFormatRule()
.setRanges([spreadsheet.getRange('E1:E1000')])
.whenFormulaSatisfied('=$B1:B2=""')
.setBackground('#B7E1CD')
.build());
spreadsheet.getActiveSheet().setConditionalFormatRules(conditionalFormatRules);
conditionalFormatRules = spreadsheet.getActiveSheet().getConditionalFormatRules();
conditionalFormatRules.splice(conditionalFormatRules.length - 1, 1, SpreadsheetApp.newConditionalFormatRule()
.setRanges([spreadsheet.getRange('E1:E1000')])
.whenFormulaSatisfied('=$B1:B2=""')
.build());
spreadsheet.getActiveSheet().setConditionalFormatRules(conditionalFormatRules);
conditionalFormatRules = spreadsheet.getActiveSheet().getConditionalFormatRules();
conditionalFormatRules.splice(conditionalFormatRules.length - 1, 1, SpreadsheetApp.newConditionalFormatRule()
.setRanges([spreadsheet.getRange('E1:E1000')])
.whenFormulaSatisfied('=$B1:B2=""')
.setFontColor('#FFFFFF')
.build());
spreadsheet.getActiveSheet().setConditionalFormatRules (conditionalFormatRules);
};
}