问题
I am trying to update tables in Google Documents with the new API. Tables are linked from a Google Sheet.
I tried the API explorer in google cloud. I am able to extract the document in json format and then filter out the tables. But within the table json structure, I do not find anything that I can update, I do not find anything that links the table to a spreadsheet. It is plain text (from the cells in the spreadsheet).
Here I am sharing one table from the json, with 2 rows and 1 column with "Written English" and "Verbal English" as cell value.
"table": {
"rows": 2,
"columns": 1,
"tableRows": [
{
"startIndex": 77,
"endIndex": 95,
"tableCells": [
{
"startIndex": 78,
"endIndex": 95,
"content": [
{
"startIndex": 79,
"endIndex": 95,
"paragraph": {
"elements": [
{
"startIndex": 79,
"endIndex": 94,
"textRun": {
"content": "Written English",
"textStyle": {
"underline": true,
"foregroundColor": {
"color": {
"rgbColor": {
"red": 0.06666667,
"green": 0.33333334,
"blue": 0.8
}
}
},
"fontSize": {
"magnitude": 24,
"unit": "PT"
},
"weightedFontFamily": {
"fontFamily": "Arial",
"weight": 400
}
}
}
},
{
"startIndex": 94,
"endIndex": 95,
"textRun": {
"content": "\n",
"textStyle": {
"foregroundColor": {
"color": {
"rgbColor": {
"red": 0.8784314,
"green": 0.16078432,
"blue": 0.42352942
}
}
},
"fontSize": {
"magnitude": 24,
"unit": "PT"
},
"weightedFontFamily": {
"fontFamily": "Arial",
"weight": 400
}
}
}
}
],
"paragraphStyle": {
"namedStyleType": "NORMAL_TEXT",
"lineSpacing": 115,
"direction": "LEFT_TO_RIGHT",
"spacingMode": "COLLAPSE_LISTS",
"spaceAbove": {
"unit": "PT"
},
"avoidWidowAndOrphan": false
}
}
}
],
"tableCellStyle": {
"rowSpan": 1,
"columnSpan": 1,
"backgroundColor": {
"color": {
"rgbColor": {
"red": 1,
"green": 1,
"blue": 1
}
}
},
"borderLeft": {
"color": {
"color": {
"rgbColor": {
"red": 1,
"green": 1,
"blue": 1
}
}
},
"width": {
"magnitude": 0.75,
"unit": "PT"
},
"dashStyle": "SOLID"
},
"borderRight": {
"color": {
"color": {
"rgbColor": {
"red": 1,
"green": 1,
"blue": 1
}
}
},
"width": {
"magnitude": 0.75,
"unit": "PT"
},
"dashStyle": "SOLID"
},
"borderTop": {
"color": {
"color": {
"rgbColor": {
"red": 1,
"green": 1,
"blue": 1
}
}
},
"width": {
"magnitude": 0.75,
"unit": "PT"
},
"dashStyle": "SOLID"
},
"borderBottom": {
"color": {
"color": {
"rgbColor": {
"red": 1,
"green": 1,
"blue": 1
}
}
},
"width": {
"magnitude": 0.75,
"unit": "PT"
},
"dashStyle": "SOLID"
},
"paddingLeft": {
"magnitude": 2,
"unit": "PT"
},
"paddingRight": {
"magnitude": 2,
"unit": "PT"
},
"paddingTop": {
"magnitude": 2,
"unit": "PT"
},
"paddingBottom": {
"magnitude": 2,
"unit": "PT"
},
"contentAlignment": "BOTTOM"
}
}
],
"tableRowStyle": {
"minRowHeight": {
"magnitude": 15,
"unit": "PT"
}
}
},
{
"startIndex": 95,
"endIndex": 112,
"tableCells": [
{
"startIndex": 96,
"endIndex": 112,
"content": [
{
"startIndex": 97,
"endIndex": 112,
"paragraph": {
"elements": [
{
"startIndex": 97,
"endIndex": 111,
"textRun": {
"content": "Verbal English",
"textStyle": {
"underline": true,
"foregroundColor": {
"color": {
"rgbColor": {
"red": 0.06666667,
"green": 0.33333334,
"blue": 0.8
}
}
},
"fontSize": {
"magnitude": 14,
"unit": "PT"
},
"weightedFontFamily": {
"fontFamily": "Raleway",
"weight": 400
}
}
}
},
{
"startIndex": 111,
"endIndex": 112,
"textRun": {
"content": "\n",
"textStyle": {
"foregroundColor": {
"color": {
"rgbColor": {
"red": 0.8784314,
"green": 0.16078432,
"blue": 0.42352942
}
}
},
"fontSize": {
"magnitude": 14,
"unit": "PT"
},
"weightedFontFamily": {
"fontFamily": "Arial",
"weight": 400
}
}
}
}
],
"paragraphStyle": {
"namedStyleType": "NORMAL_TEXT",
"lineSpacing": 115,
"direction": "LEFT_TO_RIGHT",
"spacingMode": "COLLAPSE_LISTS",
"spaceAbove": {
"unit": "PT"
},
"avoidWidowAndOrphan": false
}
}
}
],
"tableCellStyle": {
"rowSpan": 1,
"columnSpan": 1,
"backgroundColor": {
},
"borderLeft": {
"color": {
"color": {
"rgbColor": {
"red": 1,
"green": 1,
"blue": 1
}
}
},
"width": {
"magnitude": 0.75,
"unit": "PT"
},
"dashStyle": "SOLID"
},
"borderRight": {
"color": {
"color": {
"rgbColor": {
"red": 1,
"green": 1,
"blue": 1
}
}
},
"width": {
"magnitude": 0.75,
"unit": "PT"
},
"dashStyle": "SOLID"
},
"borderTop": {
"color": {
"color": {
"rgbColor": {
"red": 1,
"green": 1,
"blue": 1
}
}
},
"width": {
"magnitude": 0.75,
"unit": "PT"
},
"dashStyle": "SOLID"
},
"borderBottom": {
"color": {
"color": {
"rgbColor": {
"red": 1,
"green": 1,
"blue": 1
}
}
},
"width": {
"magnitude": 0.75,
"unit": "PT"
},
"dashStyle": "SOLID"
},
"paddingLeft": {
"magnitude": 2,
"unit": "PT"
},
"paddingRight": {
"magnitude": 2,
"unit": "PT"
},
"paddingTop": {
"magnitude": 2,
"unit": "PT"
},
"paddingBottom": {
"magnitude": 2,
"unit": "PT"
},
"contentAlignment": "BOTTOM"
}
}
],
"tableRowStyle": {
"minRowHeight": {
"magnitude": 15,
"unit": "PT"
}
}
}
],
"tableStyle": {
"tableColumnProperties": [
{
"widthType": "FIXED_WIDTH",
"width": {
"magnitude": 363,
"unit": "PT"
}
}
]
}
}
In short, I am trying to programmatically do what "UPDATE" button does on a linked table in Google Docs.
Looking forward to any help. Thanks.
回答1:
The issue is created here in the issuetracker. Star(on the top left) the issue to help Google priorotize the issue!
来源:https://stackoverflow.com/questions/54772429/google-docs-api-update-linked-tables