How to merge cells programmatically in google docs spreadsheet

So what I see is that you can merge cells so that they span more than one column in the document table by selecting two or more cells and choosing "merge" from the document menu.

My question is, how do you do this programmatically? For example, if you

myTable.getChild (0) .asTableRow (). GetCell (1) .merge ()

it just concatenates cell (1) with cell (0) and all subsequent cells move one column to the left, rather than overlap the merged cell two columns apart.

Any help here?

+3


source to share


2 answers


Here's an explanation for your question:

merge()

Merges the element with the preceding sibling of the same type.

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

The current element is removed from the document.

      



Below is document .

0


source


Unfortunately, Google docs still doesn't offer this feature programmatically. Someone already asked this question back in 2013 and got what seems to be some useful workaround .

The documentation currently provides a uniform method to combine the contents of adjacent cells into 1 cell, but does not support the original width of the two source cells.



Another workaround that may be relevant to this issue is to create a spreadsheet in a Google spreadsheet and import it into a document. Google Sheets can provide a lot of freedom in the design of your "spreadsheet". This might be a good place to start.

0


source







All Articles