Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear conditional formatting (not all formatting) in Google Apps script

I need a way to remove all conditional formatting by running a script (my client will be using this and he doesn't want to have to repeat the process of removing conditional formatting for each worksheet in each of a large number of spreadsheet files).

Is there any way to do this via Google Apps script? All I see is .clearFormat(), which unfortunately clears all formatting, of which a lot should not be deleted (eg, font color, bg color, font, font weight, font rotation, cell outlines)

How to do this in such a way that only one button needs to be pressed for each spreadsheet file?

like image 949
Hannah S. Avatar asked Jul 25 '17 01:07

Hannah S.


People also ask

How do I remove conditional formatting from Google?

Point your mouse to the condition that needs to be deleted and click the "Remove" icon. Conditional formatting will be cleared. If you don't remember the exact cell range you formatted, or if you want to get rid of formats as quickly as possible, then select the cell range and go to the Format menu - Clear formatting.

How do I bulk delete conditional formatting in Google Sheets?

To remove conditional formatting from a range of formatted cells, select the range and in the Ribbon, go to Home > Conditional Formatting > Clear Rules > Clear Rules from Selected Cells. As a result, all formatting rules are now cleared. Conditional formatting can also be removed from the entire sheet at once.


1 Answers

Google Apps Scripts now supports removing conditional formatting using clearConditionalFormatRules

var sheet = SpreadsheetApp.getActiveSheet();
sheet.clearConditionalFormatRules();

https://developers.google.com/apps-script/reference/spreadsheet/sheet#clearconditionalformatrules

like image 82
Abkarino Avatar answered Sep 22 '22 05:09

Abkarino