colors - 以编程方式在电子表格中设置边框颜色和样式

标签 colors google-apps-script border google-sheets

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

如何在Google Apps脚本中访问这些内容?

为文档描述的setBorderColor函数似乎不适用于电子表格。

最佳答案

报告的问题已修复,as of 12 Jan 2016。 Range现在具有以下方法:

  • setBorder(top, left, bottom, right, vertical, horizontal),和以前一样。
  • setBorder(top, left, bottom, right, vertical, horizontal, color, style)新功能!

  • 文档中提供了示例;这是设置虚线红色边框*的方法:

    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);
    

    *根据评论已更正:文档错误,应为SpreadsheetApp.BorderStyle.DASHED / DOTTED / SOLID,而不是Range。 –戈托弗里茨

    关于colors - 以编程方式在电子表格中设置边框颜色和样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12900359/

    相关文章:

    google-apps-script - 从 Google 电子表格接收实时更新

    Android GridView 绘制分隔线

    python - 使用 python-docx 指定表格中的边框外观

    android - 黑透明和白透明有区别吗?

    javascript - Highcharts Heatmap colorAxis 停止渐变

    css - 如何处理可能与背景颜色相似的边框颜色?

    php - 从昨天开始,即 26/05/2015,网站表单数据停止保存到 Google 电子表格中

    javascript - 如何将字符串格式从 00/00/0000 更改为 00.00.0000

    java - Substance UI 和自定义 JComponent 的 TitledBorder 问题

    javascript - 如何确保文本/链接的 CSS 不透明度更改不会更改 Firefox/Windows 中的颜色值?