

# get row data, then loop through & process each form letterĭata = get_data(SOURCE) # get data from data source 'Pichai said in his keynote that users love their new phones.' 'Android phone at the Consumer Electronics Show. 'body': 'Google, headquartered in Mountain View, unveiled the new ' # recipient data (supplied by 'text' or 'sheets' data source)

# fill-in your data to merge into document template variables Raise ValueError(f"ERROR: unsupported source , """Gets mail merge data from chosen data source. SHEETS = build('sheets', 'v4', credentials=creds) Jeff Erson', 'Googler', 'Google NYC', '76 9th Ave\n'ĭRIVE = build('drive', 'v2', credentials=creds)ĭOCS = build('docs', 'v1', credentials=creds) Lara Brown', 'Googler', 'Google NYC', '111 8th Ave\n' SOURCE = 'text' # Choose one of the data SOURCESĬOLUMNS = SCOPES = ( # iterable or space-delimited string SHEETS_FILE_ID = "11pPEzi1vCMNbdpqaQx4N43rKmxvZlgEHE9GqpYoEsWw" # Fill-in IDs of your Docs template & any Sheets data sourceĭOCS_FILE_ID = "195j9eDD3ccgjQRttHhJPymLJUCOUjs-jmwTrekvdjFE" AnĮxample of a merged letter looks something like this:įrom googleapiclient.discovery import buildįrom googleapiclient.errors import HttpError TheĬommand-line application works like this:Īll of the new merged letters also show up in the user's Google Drive. Try the app with our sample data, then adapt to your data and use case.

(or yours) by setting the SHEETS_FILE_ID variable.
#Google doc merge cell commande update
Google Sheet, update the SOURCE variable to 'sheets' and point it to our It defaults to plain text, meaning the sample data in the TEXT_SOURCE_DATA variable. Next, choose either plain text or Google Sheets as your data source by setting This style of variable placeholder naming is similar to what you'll find in The example uses names enclosed in double bracesīecause text like that is extremely unlikely to appear in document content. The form of the variables in the template is arbitrary. With placeholders to be merged with real data from a source such as a That the app will merge with desired data. Replace the contact information in the Doc with template placeholder variables.
#Google doc merge cell commande code
