Follow up to this question using Google Apps Script: Set border color & style in spreadsheet programmatically
The format is in this order: .setBorder( top, left, bottom, right, vertical, horizontal, color, style )
According to the documentation,
"true" turns on format
"false" turns off format
"null" leaves it unchanged
My problem: "null" is turning the format off!
I have a very simple script for testing purposes:
var right = "red";
var left = "blue";
range.setBorder( null, null, null, true, null, null, right, null );
range.setBorder( null, true, null, null, null, null, left, null );
Shouldn't this set the right border red and the left border blue?
The result is only the blue. If I omit the blue line, it'll result in the red.
It seems the only way to get 2+ colors in a single cell is to do .setBorder separately using "null". But "null" is working as "false" and turning off the previous border.
SpreadsheetApp.flush() should solve the problem:
range.setBorder( null, null, null, true, null, null, right, null );
SpreadsheetApp.flush();
range.setBorder( null, true, null, null, null, null, left, null );