Apps脚本-具有正确GlyphType的AppendListItem [英] Apps Script - AppendListItem with Correct GlyphType
问题描述
我正在尝试使用以下代码复制一个ListItem及其关联的GlyphType.
I'm trying to copy a ListItem with its associated GlyphType with the following code.
if( type == DocumentApp.ElementType.LIST_ITEM ) {
Logger.log("Glyph: " + element.getGlyphType());
newDocBody.appendListItem(element).setGlyphType(element.getGlyphType());
}
日志输出显示GlyphType为NUMBER,但下一行将新ListItem的GlyphType设置为BULLET.
The log output shows a GlyphType of NUMBER but the next line sets the GlyphType of the new ListItem as BULLET.
根据我对文档的了解, getGlyphType( )返回GlyphType对象,因此不能用于 setGlyphType()?
From what I understand of the docs, getGlyphType() returns an GlyphType object, so couldn't this be used for setGlyphType()?
推荐答案
GlyphType是属于DocumentApp类的ENUM对象(基本上是由名称引用的ID的负载),并且可以作为任何其他静态属性来访问.
GlyphType is an ENUM object (basically, a load of IDs referenced by names) belonging to the DocumentApp class, and is accessed as any other static property.
因此,如果您希望将项目符号设置为大写字母,您会说类似以下内容:
So, if you wanted to set the bullets to be uppercase letters, you'd say something like:
myDocBody.appendListItem( "List item text" )
.setGlyphType( DocumentApp.GlyphType.LATIN_UPPER );
https://developers上提供了可能的选项列表. .google.com/apps-script/reference/document/glyph-type
这篇关于Apps脚本-具有正确GlyphType的AppendListItem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!