DocumentApp 脚本 - 合并单元格不起作用

DocumentApp Script - Merge cell not working

 cell.appendTable([["Hello"],["Hello","I","J"]])

输出到:

|Hello|
|Hello|I    |J     |

我想合并第一行。

在 scripts.google.com DocumentApp 中开发。 - 使用 Table 和单元格元素

如果您希望合并单元格,就像您在电子表格中所做的那样,那是不可能的。仅仅是因为在 Google 文档中这是不可能的(至少现在还不能)。因此 API 无法做到这一点(它只能做一些也可以手动完成的事情)。

尝试 merge() 函数:将元素与前面相同类型的兄弟元素合并。

Only elements of the same ElementType may be merged. Any child elements contained in the current element are moved to the preceding sibling element.

当前元素已从文档中删除。

 var body = DocumentApp.getActiveDocument().getBody();

 // Append two paragraphs to the document.
 var par1 = body.appendParagraph('Paragraph 1.');
 var par2 = body.appendParagraph('Paragraph 2.');

 // Merge the newly added paragraphs into a single paragraph.
 par2.merge();

Reference

找到答案。 Google 应用脚本尚不支持合并单元格功能。