Set border color & style in spreadsheet programmatically

前端 未结 3 1884
南方客
南方客 2020-12-15 05:08

Google Spreadsheet has in the toolbar under the border button also a button to change the color and change the border style.

How can these be accessed within a Googl

3条回答
  •  悲哀的现实
    2020-12-15 05:40

    You can do a little trick. Copy the formatting in a coloured border cell to where ever you want.

    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var source = ss.getSheets()[0];
    var destination = ss.getSheets()[1];
    
    var blueBorderRange = source.getRange("B2:D4");
    
    // This copies the formatting in B2:D4 from the source sheet to
    // D4:F6 in the second sheet
    blueBorderRange.copyFormatToRange(destination, 4, 6, 4, 6);
    

提交回复
热议问题