【问题标题】:Google Document - Background ColorGoogle 文档 - 背景颜色
【发布时间】:2012-06-19 17:23:05
【问题描述】:

如何去除文档元素的背景色(也就是设置为 null)?

我尝试将值设置为“null”,但是,系统给了我这个错误: “很抱歉,发生服务器错误。请稍等,然后重试。(第 14 行)”

如果我将第 14 行 (activeSel.setBackgroundColor) 注释掉,脚本就可以正常工作

function clearDoc(){
  var doc = DocumentApp.openById(DOC1Id);
  var activeSel = doc.getActiveSection().getParagraphs()[2];
  var attr = activeSel.getAttributes(); // BACKGROUND_COLOR = "#ff0000"
  activeSel.setBackgroundColor(null); // errors out
  return
}

【问题讨论】:

  • 我按照文档中的建议尝试了 setAttributes(object) 但也没有任何结果...它抛出错误 Exception : null
  • 感谢您查看 Serge :)

标签: document google-docs google-apps-script


【解决方案1】:

现在将 Background_COLOR 设置为 null(或使用 setBackgroundColor)会清除背景颜色。上面给出的示例不再出错。

【讨论】:

  • 确认setBackfroundColor(null) 完美运行!感谢@kacrouse 和 Google Apps 脚本团队
【解决方案2】:

您是否尝试将背景颜色设置为白色(“#ffffff”)?

【讨论】:

  • Eric -- 是的,这是我目前的解决方法。但是,该解决方案并不能解决问题。例如,假设您的文档的背景是图像或其他颜色。 “白色”解决方案将出现。感谢您的建议! :)
  • 我明白了,白色和无背景是有区别的,UI让你设置。请为此在问题跟踪器上提交功能请求。 code.google.com/p/google-apps-script-issues/issues/list
  • 感谢 Eric 的支持 :) 发布功能请求:Issue 2101
猜你喜欢
  • 1970-01-01
  • 2016-08-21
  • 1970-01-01
  • 1970-01-01
  • 2013-10-18
  • 2018-06-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多