是否可以在Google Apps脚本中迭代ENUM的? [英] Is it possible to iterate over ENUM's in Google Apps Script?
问题描述
我想在Google文档的Google Apps脚本中获取所有可用的Font-family。 FontFamilies被定义为FontFamily ENUM。我可以迭代这个ENUM以获得本文档中所有可能的FontFamilies吗?
$ b $ p
更新:我已经找到了我自己的答案:
var fontfamilies = DocumentApp.FontFamily.values();
for(var i in fontfamilies){
Logger.log(fontfamilies [i]);
(我想让它显示为一个答案,我不能只编辑我原来的问题),Google Apps ENUM的确拥有values()属性/方法,就像在Java中一样。它将给出一个包含ENUM值的数组,这里是在FontFamily ENUM中定义的字体系列的名称。
以下是迭代这些值的示例代码:
var fontfamilies = DocumentApp.FontFamily.values();
for(var i in fontfamilies){
Logger.log(fontfamilies [i]);
}
I would like to get all available Font-families in a Google Apps Script for Google Docs. FontFamilies are defined as FontFamily ENUM. Can I iterate over this ENUM to get all the possible FontFamilies in this document?
UPDATE: I have found my own answer:
var fontfamilies = DocumentApp.FontFamily.values();
for(var i in fontfamilies){
Logger.log(fontfamilies[i]);
}
So to answer my own question (I guess to have it show as an answer I can't just edit my original question), Google Apps ENUM's do have a "values()" property / method just like in Java. It will give an array with the ENUM values, in this case the names of the font families defined in the FontFamily ENUM.
Here is an example code to iterate over these values:
var fontfamilies = DocumentApp.FontFamily.values();
for(var i in fontfamilies){
Logger.log(fontfamilies[i]);
}
这篇关于是否可以在Google Apps脚本中迭代ENUM的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!