保护工作表选项可能会限制其他用户添加/删除行的能力,但是我也花了很多时间尝试解决条件格式问题。最后,我最终使用了几种解决方法;
- 我使用 appscript 进行条件格式化。这是最有效的解决方案,但是由于我不精通编写代码,我发现它很麻烦。下面的部分示例。
- 我还使用的更快的解决方法是有条件地格式化用户编辑的单元格旁边的单元格,然后我会保护这些单元格。
if (values[i] == 'SUB') {
sheet
.setRowHeight(i+1, 19)
.getRange('A'+n+':CB'+n)
.setBackgroundColor('#b7b7b7')
.setFontFamily("Abel").setFontSize(6).setFontColor('white').setFontWeight("bold")
.setVerticalAlignment(DocumentApp.VerticalAlignment.MIDDLE).setHorizontalAlignment("center")
.setBorder(null, null, true, null, null, null,'white',SpreadsheetApp.BorderStyle.SOLID_THICK) /////// top,left,bottom,right,vertical,horizontal,color,style;
sheet.getRange('O'+n+':O'+n).setBackgroundColor('white')
sheet.getRange('AF'+n+':AF'+n).setBackgroundColor('white')
sheet.getRange('AJ'+n+':AJ'+n).setBorder(null, null, null, true, null, null,'white',SpreadsheetApp.BorderStyle.SOLID_THICK)
sheet.getRange('AN'+n+':AN'+n).setBorder(null, null, null, true, null, null,'white',SpreadsheetApp.BorderStyle.SOLID_THICK)
sheet.getRange('AR'+n+':AR'+n).setBorder(null, null, null, true, null, null,'white',SpreadsheetApp.BorderStyle.SOLID_THICK)
sheet.getRange('AV'+n+':AV'+n).setBorder(null, null, null, true, null, null,'white',SpreadsheetApp.BorderStyle.SOLID_THICK)