Search code examples
google-apps-scriptgoogle-sheetsdocumentgoogle-docs-api

google apps script open new document


hi want to create a google document and add to the value of the variable which is. Why can't I pass it to a document with this function?

var doc=DocumentApp.create("Wynik"); 
doc.getBody().appendParagraph(arr[wasitfound]);

error code: "Exception: The parameters (number[]) don't match the method signature for DocumentApp.Body.appendParagraph."


Solution

  • Check the documentation for appendParagraph.

    It accepts a string but you are passing an array.

    Example:

    var str = "Hello";
    doc.getBody().appendParagraph(str)
    

    or use join:

    doc.getBody().appendParagraph(arr[wasitfound].join())