Hm. Just tried the following code. It works as expected - changes the 'D10:E20' range colored background to white and the cells A1 and A2 contain the text
i.e. the range background is 'none' and not white. The function is
function myFunction() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var range = sheet.getRange('D10:E20');
sheet.getRange('A1').setValue(range.getBackgroundColor());
range.setBackground('none');
sheet.getRange('A2').setValue(range.getBackgroundColor());
}
Edit 00: I am sorry, I misunderstood you. Fixing my fault, I created a text document and a small script (see bellow). In the document, I created a new table and, without any further modifications, I started the script. The results are
- The cell[0, 0] contains the
Background is null text and the code throws the We're sorry, a server error occurred. Please wait a bit and try again. (line 14) exception in the cell00.setBackgroundColor(bg00); line. Wrong.
In the document editor I changed the cell[0, 0] background, by the Table->Table properties dialog, to the yellow. The results are
- The cell[0, 0] text is
#ffff00. No errors. Correct.
I changed the cell background to None. The results are
- The cell[0, 0] contains the
Background is empty text and the code throws the Invalid color value. (line 14) exception in the cell00.setBackgroundColor(bg00); line. Wrong.
My opinion is that the points marked as Wrong is a bug. You have to file an issue to the issue tracker. For sure, you can use my code and this text to describe the problem.
function testDoc() {
var doc = DocumentApp.openById('the-text-document-id');
var cell00 = doc.getTables()[0].getCell(0, 0);
var bg00 = cell00.getBackgroundColor();
if (bg00 == null) {
cell00.setText('Background is null');
}
else if (bg00 == '') {
cell00.setText('Background is empty');
}
else {
cell00.setText(bg00);
}
cell00.setBackgroundColor(bg00);
}