1
votes

I want to insert an embedded Google Sheets table into a Google Doc via the Google Doc API. I had hoped that I could do this via an EmbeddedObject. The definition of EmbeddedObject includes a field for LinkedContentReference, but despite the generic name, a LinkedContentReference object seems to refer only to a Sheets chart.

Is there a way to embed a Sheets table in a Google Doc via API?

I did notice that Google Sheets offers a Table Chart as a chart type. This may be an effective workaround.

1

1 Answers

0
votes

You need to insert the sheet table as an inline image

An InlineObject contains an EmbeddedObject such as an image.

  • Now, when you publish a Google Sheets, you have the option to publish it as pdf, but not image. This mean that you would need to perform an additional step of converting the pdf into a supported image format.

  • Alternatively you can obtain (and save on your Drive) the Sheet as a thumbNail by performing a Files: get request on the Sheet and setting fields to thumbnailLink. Mind that the thumbNail contians the whole sheet view - not only the data range.

Important:

When performing a documents.batchUpdate request InsertInlineImageRequest, you need to specify the uri in the format

https://docs.google.com/uc?export=view&id=PASTE_HERE_YOUR_ID