I’m having trouble with the Google Docs API when trying to copy tables from one document to another. It works fine for regular tables, but I’m running into issues with tables that have headers.
Here’s what I tried:
{
"updateTableRowStyle": {
"tableStartLocation": {
"segmentId": "",
"index": 100
},
"rowIndices": [0],
"tableRowStyle": {
"minRowHeight": {
"unit": "PT"
},
"tableHeader": true
},
"fields": "minRowHeight,tableHeader"
}
}
But I get this error:
updateTableRowStyle: Unallowed field: tableHeader
I’ve tried different combinations of fields and parameters, but nothing seems to work for setting the table header. Is this a limitation of the API? Or am I doing something wrong? Any help would be great!
I’ve encountered a similar issue when working with the Google Docs API and table headers. Unfortunately, it appears that setting the table header property through the API is indeed a limitation at present. The ‘tableHeader’ field isn’t supported in the updateTableRowStyle request.
As a workaround, I’ve had success applying specific formatting to the first row to mimic a header visually. You can use updateTableRowStyle to adjust things like background color, font weight, and text alignment for the first row. It’s not ideal, but it can achieve a similar visual effect to a true header row.
If you absolutely need the functionality of a proper table header, you might consider creating a feature request through Google’s issue tracker. They do sometimes add new capabilities based on user feedback.
I feel your pain on this one. I’ve banged my head against the wall with Google Docs API and table headers too. It’s frustrating that such a basic feature isn’t properly supported.
One trick I’ve used is to pre-format the table in a template doc, then copy the whole thing over. The header styling carries across, even if you can’t set it programmatically. It’s a bit of a hack, but it works.
Another option is to use Apps Script instead of the API directly. It has some extra table manipulation capabilities that aren’t exposed in the REST API. Might be worth exploring if you’re hitting a wall with the regular API.
Don’t hold your breath for Google to fix this anytime soon though. They’re notoriously slow at addressing API limitations. Best to find a workaround for now and hope for improvements down the line.
hey, i’ve run into this too. super annoying! the api’s pretty limited with headers. u could try faking it by styling the first row differently. like make it bold or change the background. not perfect but it works ok. maybe google will add proper header support someday LOL