0

My script at https://github.com/berteh/SheetsToDocsMerge/blob/master/merge.gs is inserted in a google spreadsheet to use it as a "mail-merge" source that duplicates a google document (template given by its ID) and substitutes some placeholders between brackets "[variable-name]" with the corresponding cell content of the spreadsheet.

I want to be able to include images dynamically into the resulting document as weel. Providing either the URL of the image in the spreadsheet, or the image itself (using the =IMAGE(URL)), but find no way to

  1. detect if source cell content is an image and
  2. generate content in the output document that will result in the image being included.

Any idea how to do so? thanks! Berteh.

Berteh
  • 73
  • 8
  • 1
    Can you test for an image URI using regex? – Brian May 04 '17 at 12:08
  • 1
    Not entirely sure if there's direct functions from the docs that supports your use case. Try checking this [SO post](http://stackoverflow.com/questions/41020598/insert-image-into-spresheet-cell-from-drive-using-google-apps-script/41046369#41046369). There's [insertImage](https://developers.google.com/apps-script/reference/document/body#insertimagechildindex-image) for Apps Script Doc objects. – ReyAnthonyRenacia May 04 '17 at 16:14
  • I could test for an image URI, but I don't actually dive into the object of the generated document... and would for instance not have the parent object to use "insertImage" on, (or other function if that matters). Is there a way to include it in a "html"-like way? – Berteh Sep 06 '17 at 06:01

0 Answers0