I am trying to create a table in a Doc file using Google Appsscript. The last row should only consist of one cell:
but all I can get is this (last row aligned to the left).
I tried different things:
- Merging two cells with merge() leads to the second image again
- Creating two tables and trying to merge them leaves a gap between the rows.
- Changing the width of the last row changes the width of the entire first column
Help would be much appreciated. Thanks a lot!
var cells = [
['Cell 1', 'Cell 2'],
['Cell 1', 'Cell 2'],
['Cell 1', 'Cell 2'],
['Cell 1', 'Cell 2'],
["Only one Cell"]
];
var tableHeader = body.appendTable(cells);
CodePudding user response:
Issue and workaround:
- In my experience, I had had the
merge()
method for merging the cells cannot be used. I'm not sure whether this is a bug or the current specification. Now, when I tested the same situation again, it seems thatmerge()
cannot still be used. And also, I confirmed the same result with you. I would like to expect that this issue will be resolved in the future update.
But, fortunately, it has already been found that when Google Docs API is used, the table cells can be merged. So, in this answer, I would like to propose using Google Docs API for achieving your goal. When your showing script is modified, how about the following modification?