Copy link to clipboard
Copied
hello forum,
i am using Indesign 5.5, having problem to merge table cells through scripting.
i want to merge multiple cells in a table.
i have merge first three merge coorectly, but my script not able to merge forth merge.
i am using,
var myDocument=app.activeDocument;
var myTextFrame=myDocument.spreads.item(0).textFrames.item("Spread0TxtFrame0");
var table =myTextFrame.tables.firstItem();
var t = table.rows.length;
var f = table.rows.length - (t-start row count) // **start row count is intiger indicates merge start row
var fn=table.rows.length - (t-end row count)
table.columns[1].cells
when i does pass the value for first three merge it works but when i use for forth merge indxing is change for value of rows.what i am passing into f and fn.
example:-
var t = table.rows.length;
var f = table.rows.length - (t-0);
var fn=table.rows.length - (t-5);
table.columns[0].cells
var t = table.rows.length;
var f = table.rows.length - (t-0);
var fn=table.rows.length - (t-0);
table.columns[2].cells
var t = table.rows.length;
var f = table.rows.length - (t-1);
var fn=table.rows.length - (t-1);
table.columns[1].cells
var t = table.rows.length;
var f = table.rows.length - (t-3);
var fn=table.rows.length - (t-3);
table.columns[1].cells
i get
an extra row merges with forth one..
seperately all four merge works but when i fire script with all it merge wrong cells in forth merge.
please correct me where i am wrong in script.
your answer will be apriciated.
Thanks
Ajay
1 Correct answer
How many rows does this table have in the first place? The most likely problem is that because of the previous merges the number of rows left is such that there aren't enough rows left for f to be formed properly.
I may be off base here because I can't see the screen captures you tried to post.
Dave
Copy link to clipboard
Copied
How many rows does this table have in the first place? The most likely problem is that because of the previous merges the number of rows left is such that there aren't enough rows left for f to be formed properly.
I may be off base here because I can't see the screen captures you tried to post.
Dave
Copy link to clipboard
Copied
hello dev,
i have 6 rows and 4 columns no footer no header,
and i did merge
1st mergecell:- from row1 column1 to row6 column1
here is the syntax:-
var t = table.rows.length;
var f = table.rows.length - (t-0);
var fn=table.rows.length - (t-5);
table.columns[0].cells
2nd mergecell:- from row1 column3 to row1 column4
syntax:-
var t = table.rows.length;
var f = table.rows.length - (t-0);
var fn=table.rows.length - (t-0);
table.columns[2].cells
3rd mergecell:- from row2 column2 to row2 column3
syntax:-
var t = table.rows.length;
var f = table.rows.length - (t-1);
var fn=table.rows.length - (t-1);
table.columns[1].cells
4rt mergecell:- from row4 column2 to row4 column4
i use
var t = table.rows.length;
var f = table.rows.length - (t-3);
var fn=table.rows.length - (t-3); // problem is here it takes (t-2) instead of (t-3)
table.columns[1].cells
** all value having 0 indexing
Copy link to clipboard
Copied
hello dave,,
i am waiting for your response, please find the attachment tables and take a overview on situation.
Copy link to clipboard
Copied
Your posted script has syntax errors so I couldn't find what you were doing wrong because the script won't run as posted. Can you post a version that actually exhibits the problem you're trying to solve.
But, from what has gone before, you're probably overlooking the fact that your script is changing the number of rows as it does each step so what you think of as static values are actually changing during the course of the script.
Dave
Copy link to clipboard
Copied
dear dev i have upload three images of tables
1- main_tab means what is my actual table
2- want_tab- which i need to convert my table
3-after_script_tab- this is the converted table after using my scripting
Copy link to clipboard
Copied
Hi,
Notice before merge 4 that your
table.columns[3].rows.length IS NOT EQUAL to table.columns[3].cells.length;
(6 != 5)
I suggest to set your merge horizontally
(i.e using: table.rows
______________________
edited: wrong suggestion!!!
since you are editing a table vertically first -
its rows[0].cells.length == 4 and the rest of rows.cells.length ==3
With your particular goal:
move merge 1 to the end of steps
Jarek
Copy link to clipboard
Copied
hello jarek,,
you are right for my perticular case
but my script comes out from code sequentially merge1 to merge 4
how could i apply 1st merge in end
i am talking about various tables and their merges
thanks
ajay
Copy link to clipboard
Copied
hi,
dear i just want to know how will i find or get the return value of any variable in java script through indesign object model??
ex- "var tab= table.rows.length;"
i just want to know the return value in variable "tab" while debug the script.
Copy link to clipboard
Copied
hi,
dear i want to know how will i find or get the return value of any variable in java script through indesign object model??
ex- "var tab= table.rows.length;"
i just want to know the return value in variable "tab" while debug the script.

