本文介绍了设置边框颜色&以电子表格的形式编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google Spreadsheet在边框按钮下方的工具栏中还有一个按钮,用于更改颜色并更改边框样式。



Google Apps中的这些内容可以被访问脚本?



$ setBorderColor 函数对文档而言似乎不适用于电子表格。 b

解决方案

报告的问题已修复,。 Range现在有这些方法:


  • ,像以前一样。

  • 新! b $ b

    文档中提供了示例;这里是如何设置一个红色的虚线边界:
    $ b

      var ss = SpreadsheetApp.getActiveSpreadsheet(); 
    var sheet = ss.getSheets()[0];

    var cell = sheet.getRange(B2);
    //在顶部和底部设置边界,但保持左右不变
    //同时将颜色设置为红色,将边框设置为DASHED。
    cell.setBorder(true,null,true,null,false,false,red,SpreadsheetApp.BorderStyle.DASHED);






    更正后,根据评论:文档是错误的,它应该是SpreadsheetApp.BorderStyle.DASHED / DOTTED / SOLID,而不是Range。 - gotofritz

    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 Google Apps Script?

    The setBorderColor function which is described for documents seems unavailable for spreadsheets.

    解决方案

    The reported issue has been fixed, as of 12 Jan 2016. Range now has these methods:

    Examples are provided in the documentation; here's how to set a dashed red border:

    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var sheet = ss.getSheets()[0];
    
    var cell = sheet.getRange("B2");
    // Sets borders on the top and bottom, but leaves the left and right unchanged
    // Also sets the color to "red", and the border to "DASHED".
    cell.setBorder(true, null, true, null, false, false, "red", SpreadsheetApp.BorderStyle.DASHED);
    


    Corrected, as per comment: the documentation is wrong, it should be SpreadsheetApp.BorderStyle.DASHED/DOTTED/SOLID, not Range. – gotofritz

    这篇关于设置边框颜色&以电子表格的形式编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 15:51