Merging cells in a row...

I'd like to be able to turn the first table into the second. I see that there is a cell merge, but I can't seem to figure out the syntax.
Thanks in advance for your help.

I'd like to be able to turn the first table into the second. I see that there is a cell merge, but I can't seem to figure out the syntax.
Thanks in advance for your help.
rowCellCount is simply either rows.cells.length or rows.columns.length -- without trying, I think the first gives the actual count of cells in a row (merged or not), and the second the original number of columns.
To merge, use http://jongware.mit.edu/idcs5js/pc_Cell.html#merge like this:
table = app.selection[0];
if (table.hasOwnProperty("baseline")) table = table.parent;
if (table instanceof Cell) table = table.parent;
if (table instanceof Column) table = table.parent;
if (table instanceof Row) table = table.parent;
if (table instanceof Table)
{
table.rows[0].cells[0].merge (table.rows[0].cells[1]);
}
.. the first 6 lines are to make sure the script knows where it is. This way, it will work with the text cursor inside a cell (every text object has a "baseline" property; I think it's a trick I learned from Dave Saunders), or with a cell, column, row, or the entire table selected. After locating the table, it's just a matter of following the description of "Cells: Merge".
Oh wait, now I have a table, 3 cells per row and the first 2 cells merged, to test my first assertion on. Running this
alert (table.rows[0].cells.length);
alert (table.rows[0].columns.length);
alert (table.rows[1].cells.length);
alert (table.rows[1].columns.length);
alerts "2", "3", "3" and "3", just as I thought.
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.