I am using the google slides API to automatically update a presentation which has some pretty detailed tables. I have a table with several cells, and within each cell I have 3 different Lines with different formatting. For example, the top line has a bigger font, the second line is smaller and green, etc. As this presentation should update automatically everyday with my inputed data, I really need to set up requests based off of the TextRun lengths rather than fixed start and end indexes (these start and end indexes will change everyday as the text will update, so I cant manually edit the index everyday)
How can I either replace the text only within a TextRun or replace the text on a line by line or paragraph basis?
I am adding an image here. You can see that in the first line I have one large bold number that needs to be updated, and in the second line I have 3 items that need to be updated. 1. Y/Y 2. Q/Q 3. M/M I want to be able to do this without requiring every text to be the same size.
Here is the batch update request I have set up right now. I just cant figure out how I can get the range to always be within a textRun, rather than for the entire cell.
reqs = [
{
"deleteText": {
"objectId": "g2f8579c174_1_6",
"cellLocation": {
"rowIndex": 1,
"columnIndex": 1,
},
"textRange": {
"type": "ALL",
}
}
},
{
"insertText": {
"objectId": "g2f8579c174_1_6",
"cellLocation": {
"rowIndex": 1,
"columnIndex": 1
},
"text": "texttexttext",
"insertionIndex": 0
}
}
]
I would do a read of the presentation (either presentations.get or presentations.pages.get), find the runs and indices you want to update, then create a batchUpdate request to update those runs as you need. You can use InsertTextRequest to add your new content followed by DeleteTextRequest to get rid of the old content. It should preserve styling automatically.