本文介绍了谷歌脚本InlineDrawing类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将InlineDrawing插入到表格单元格中。

根据文档,您可以将InlineDrawing添加到段落。



so

  tr = table.appendTableRow(); 

var tc1 = tr.appendTableCell();

var tc1.appendParagraph(如何在这里适合新的InlineDrawing?);

如何获取inlineDrawing的新实例?如何使用这个对象?
我找不到任何关于此的在线参考。



感谢您的帮助。 rel =nofollow> https://gist.github.com/bennettscience/cd51762de17c860d6930 )

  / /不要忘记你的全局变量。 
//搜索页面元素。段落是顶层的,这就是我从这些开始的原因。
if(type == DocumentApp.ElementType.PARAGRAPH){

//在段落中寻找子元素。内联图纸是儿童。
if(element.asParagraph()。getNumChildren()!= 0&& element.asParagraph()。getChild(0).getType()== DocumentApp.ElementType.INLINE_DRAWING){

//无论出于何种原因,图纸在InlineDrawing类中都没有自己的方法。这一位拷贝并将其添加到文档的底部。
var drawing = element.asParagraph()。copy();
body.appendParagraph(drawing);
}
}


I'm trying to insert InlineDrawing into table cell.

According to documentation you can add InlineDrawing to Paragraph.

so

tr = table.appendTableRow();

var tc1 = tr.appendTableCell();

var tc1.appendParagraph( how to fit new InlineDrawing here? ); 

How to get new instance of inlineDrawing ? How to work with this object ? I can't find any online reference about this.

Thank you for your help.

解决方案

Here you go: (credit: https://gist.github.com/bennettscience/cd51762de17c860d6930)

// Don't forget your global variables up top.
// Search through the page elements. Paragraphs are top-level, which is why I start with those.
if( type == DocumentApp.ElementType.PARAGRAPH ){

  // Look for child elements within the paragraph. Inline Drawings are children.
  if(element.asParagraph().getNumChildren() !=0 && element.asParagraph().getChild(0).getType() == DocumentApp.ElementType.INLINE_DRAWING) {

    // For whatever reason, drawings don't have their own methods in the InlineDrawing class. This bit copies and adds it to the bottom of the doc.
    var drawing = element.asParagraph().copy();
    body.appendParagraph(drawing);
  }
}

这篇关于谷歌脚本InlineDrawing类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 06:26