无效 BACKGROUND_COLOR?
Invalid BACKGROUND_COLOR?
谁能告诉我为什么这段代码会返回一个错误 "invalid color?"
好像是指BACKGROUND_COLOR属性。但是我想不通为什么。
function myFunction() {
var bibiDoc = {};
bibiDoc[DocumentApp.Attribute.BACKGROUND_COLOR] = 0x000000;
bibiDoc[DocumentApp.Attribute.FONT_FAMILY] = 'Courier New';
bibiDoc[DocumentApp.Attribute.FOREGROUND_COLOR] = 0x00FF00;
bibiDoc[DocumentApp.Attribute.FONT_SIZE] = 12;
var doc = DocumentApp.getActiveDocument();
var body = doc.getBody();
var par = body.appendParagraph("test");
par.setAttributes(bibiDoc);
}
您可以使用十六进制代码格式,但不要忘记将其放在引号内:
// Define a style with yellow background.
var highlightStyle = {};
highlightStyle[DocumentApp.Attribute.BACKGROUND_COLOR] = '#FFFF00';
highlightStyle[DocumentApp.Attribute.BOLD] = true;
// Insert "Hello", highlighted.
DocumentApp.getActiveDocument().editAsText()
.insertText(0, 'Hello\n')
.setAttributes(0, 4, highlightStyle);
这里有一份 Hex Codes 您可以尝试的列表。
谁能告诉我为什么这段代码会返回一个错误 "invalid color?"
好像是指BACKGROUND_COLOR属性。但是我想不通为什么。
function myFunction() {
var bibiDoc = {};
bibiDoc[DocumentApp.Attribute.BACKGROUND_COLOR] = 0x000000;
bibiDoc[DocumentApp.Attribute.FONT_FAMILY] = 'Courier New';
bibiDoc[DocumentApp.Attribute.FOREGROUND_COLOR] = 0x00FF00;
bibiDoc[DocumentApp.Attribute.FONT_SIZE] = 12;
var doc = DocumentApp.getActiveDocument();
var body = doc.getBody();
var par = body.appendParagraph("test");
par.setAttributes(bibiDoc);
}
您可以使用十六进制代码格式,但不要忘记将其放在引号内:
// Define a style with yellow background.
var highlightStyle = {};
highlightStyle[DocumentApp.Attribute.BACKGROUND_COLOR] = '#FFFF00';
highlightStyle[DocumentApp.Attribute.BOLD] = true;
// Insert "Hello", highlighted.
DocumentApp.getActiveDocument().editAsText()
.insertText(0, 'Hello\n')
.setAttributes(0, 4, highlightStyle);
这里有一份 Hex Codes 您可以尝试的列表。