Skip to content
Inserting content f...
 
Notifications
Clear all

Inserting content from one Google Doc to another using the Google Docs API

19 Posts
5 Users
0 Reactions
12 Views
Zbulo
(@zbulo)
Posts: 13
Active Member
Topic starter
 

Hello Makers,

I'm attempting to insert a table into a Google Doc. Since the Google Docs API is a bit beyond my current skill set, my approach is to first create the table within an empty Google Doc using HTML.

I'm trying to figure out how to:

  1. Identify the specific location within the second multi-page document where the table should be inserted.
  2. Make the actual API call to insert the content from the first Doc.

Are there any experts on this topic available? I understand this might lean more towards Google Docs than callin.io, but apologies.

 
Posted : 30/06/2022 2:47 pm
Richard_Johannes
(@richard_johannes)
Posts: 21
Eminent Member
 

Hi,
I've worked extensively with Google Docs, but I must admit I haven't inserted a table yet.
Typically, the process you're describing seems quite logical. Consider creating a template using variables like {{var1}}, {{name}}, and {{price}}. You can then utilize the "Create Document from Template" feature to populate these variables.

Does this approach work for your needs?

Best,
Richard

 
Posted : 30/06/2022 2:58 pm
Zbulo
(@zbulo)
Posts: 13
Active Member
Topic starter
 

Thanks Richard, I’m not sure I understood this correctly.

To construct the table rows, I am iterating through multiple Airtable records. I then aggregate the HTML rows and insert them into the table that is part of the “Create Document from Template” step.

I am encountering an issue with the second step, specifically in pinpointing the exact location within the document to insert the table generated in the first step. I've reached an impasse with the Google Docs API.

 
Posted : 30/06/2022 3:17 pm
Richard_Johannes
(@richard_johannes)
Posts: 21
Eminent Member
 

Okay, my apologies!

:smiley:

I understand what you're doing now, but the screenshot only shows the first step, which was successful.

Does the problem occur after the point shown in the screenshot?

 
Posted : 30/06/2022 3:31 pm
Zbulo
(@zbulo)
Posts: 13
Active Member
Topic starter
 

Precisely, the moment I fail to implement it.

 
Posted : 30/06/2022 3:50 pm
Richard_Johannes
(@richard_johannes)
Posts: 21
Eminent Member
 

Understood. Could you describe how the second document is structured or what its contents are? You mentioned it has multiple pages; does it contain a variable? How would you manually identify the table's location within that document?

Is there a specific element we can search for?

 
Posted : 30/06/2022 4:05 pm
Zbulo
(@zbulo)
Posts: 13
Active Member
Topic starter
 

It's a general contract-style document populated with variables. I can incorporate any orientation point that's easily identifiable within the workflow. For instance, a chapter heading with a specific number, title, or symbol. Open to any suggestions.

:slight_smile:

 
Posted : 01/07/2022 8:17 am
Richard_Johannes
(@richard_johannes)
Posts: 21
Eminent Member
 

I am very sorry! :slight_smile: I don't quite understand without seeing it. :confused: Why don't you use {{table}} and place it there? What is the reason you need to create two documents and then "merge" them?

 
Posted : 01/07/2022 3:27 pm
Zbulo
(@zbulo)
Posts: 13
Active Member
Topic starter
 

No worries Richard, this is tricky stuff.

:wink:

My expertise is too limited to utilize the Google Docs API for table insertion.

Furthermore, it's not possible to insert a formatted table through a variable.

HTML conversion is only effective when creating a new document, not when working from a template.

 
Posted : 01/07/2022 4:04 pm
Richard_Johannes
(@richard_johannes)
Posts: 21
Eminent Member
 

Ah, I see. And does the table consistently maintain the same structure, or does the number of columns and rows vary?

 
Posted : 01/07/2022 4:21 pm
Zbulo
(@zbulo)
Posts: 13
Active Member
Topic starter
 

The number of rows is variable and subject to change.

 
Posted : 02/07/2022 2:29 pm
Richard_Johannes
(@richard_johannes)
Posts: 21
Eminent Member
 

However, do the columns remain unchanged? I've reviewed the Google Docs documentation, and it appears possible to have a table within the document and subsequently add, remove, or update rows.

 
Posted : 02/07/2022 2:58 pm
Zbulo
(@zbulo)
Posts: 13
Active Member
Topic starter
 

Yes, columns are static, but the API is quite complex for me to use, and I'm encountering numerous errors that I can't seem to debug. In a separate discussion, someone suggested a clever workaround: reversing the content order, which seems to resolve many of the pixel and placement problems.

 
Posted : 03/07/2022 5:12 am
sean
 sean
(@sean)
Posts: 2
New Member
 

While working on a similar project, I found it very difficult to modify an existing Google Doc after creating one from a template.

A potential approach though could be, instead of modifying a document, to create a new (v2) of the document using the steps above.

 
Posted : 05/07/2022 11:00 pm
D-EFFCON
(@d-effcon)
Posts: 3
New Member
 

Hello! I've handled this scenario several times.

After your text aggregator module, you should remove the 'Create a Document' module.

Instead, integrate a 'Set a Variable' module from the Tools pack. Assign the variable name Table HTML and use your generated HTML as its value.

Next, within your second Google Doc (outside of callin.io), place a highly unique text string where you want the table to appear. For example, use something like <<|TABLEINSERT|>>.

Return to callin.io and, following your 'Set a Variable' module, utilize the 'Download a Document' module.

Download the document in HTML format, as shown in the screenshot.

Immediately after that module, use the 'Create a Document' module.

Within this module, configure it as follows:

And that's it!

 
Posted : 06/07/2022 5:43 am
Page 1 / 2
Share: