-
1. Re: [JS] Test fused cells (merge)
pkahrel Jan 16, 2014 1:26 PM (in response to Philippe Ruelle)Check columnSpan and/or rowSpan. From memory:
if (myCell.rowSpan > 0) {
// merged rows
}
and
if (myCell.columnSpan > 0) {
// merged columns
}
-
2. Re: [JS] Test fused cells (merge)
Philippe Ruelle Jan 16, 2014 1:41 PM (in response to pkahrel)That's great!
Super c'est ça!!!
-
3. Re: [JS] Test fused cells (merge)
Laubender Jan 16, 2014 1:43 PM (in response to Philippe Ruelle)@Philippe – test a cell for "rowSpan" and "columnSpan", together with its "name" string and "id" (unique for the table) you can determine if the cell in merged, where it starts and ends in horizontal and vertical orientation.
It also would help to get the number of rows and number of columns to get the basic "grid" right.
The id numbers are especially interesting. If cells are merged numbers will be missing.
Example:
A 4 x 3 table where the first cell is merged with the cell below.A loop through all cells by rows like that:
for(var n=0;n<myTable.rows.length;n++){ $.writeln(myTable.rows[n].cells.everyItem().id); $.writeln(myTable.rows[n].cells.everyItem().name); $.writeln(myTable.rows[n].cells.everyItem().rowSpan); $.writeln(myTable.rows[n].cells.everyItem().columnSpan); };will reveal:
Matrix of id-numbers:
0, 1, 2, 3
5, 6, 7
8, 9,10,11
cells.itemByID(0).rowSpan is 2.
cells.itemByID(4) does not exist.
Matrix of names:
0:0, 1:0, 2:0, 3:0
1:1, 2:1, 3:1
0:2, 1:2, 2:2, 3:2
There is no cell named "0:1"
Matrix of rowSpan:
2, 1, 1, 1
1, 1, 1
1, 1, 1, 1
Matrix of columnSpan:
1, 1, 1, 1
1, 1, 1
1, 1, 1, 1
//A table is selected: var myTable = app.selection[0]; howManyCellsOfTheTableGridAreMerged(myTable); //Simple function: function howManyCellsOfTheTableGridAreMerged(myTable){ var columnOrRowMerged = 0; var c = myTable.columns.length; var r = myTable.rows.length; var gridLength = c * r ; var myCellLength = myTable.cells.length; var diff = gridLength - myCellLength; for(var n=0;n<myTable.cells.length;n++){ if(myTable.cells[n].rowSpan > 1 || myTable.cells[n].columnSpan > 1){ ++columnOrRowMerged; }; }; return diff + columnOrRowMerged; };I used the term "table grid" to describe the "ideal" table where no cells are merged.
Tested this simple function on our example table, it will return: 2
(if you look at the ideal table grid, the 4 x 3 matrix: cells[0] is merged with cells[4] )
That should get you some ideas…
Uwe
-
4. Re: [JS] Test fused cells (merge)
Philippe Ruelle Jan 18, 2014 11:02 AM (in response to Laubender)Super merci Laubender .
-
5. Re: [JS] Test fused cells (merge)
Philippe Ruelle Jan 18, 2014 11:41 AM (in response to Philippe Ruelle)Another small question, I am in a painting, I want to have the style name is paragaphe or inserts the table and applied a different sytle.
this command:$.writeln (leTableau.parent.appliedParagraphStyle.name); // -> TextFrame$.writeln (leTableau.parent.constructor.name); // fait une erreur normal!Une autre petit question, je suis bien dans un tableau, je veux s'avoir le nom du style de paragaphe ou est insére le tableau et appliqué un autre sytle.
cet commande :
$.writeln (leTableau.parent.appliedParagraphStyle.name); // -> TextFrame$.writeln (leTableau.parent.constructor.name); // fait une erreur normal!Merci
-
6. Re: [JS] Test fused cells (merge)
[Ariel] Jan 18, 2014 12:15 PM (in response to Philippe Ruelle)You want storyOffset:
myTable.storyOffset
gives you the insertionPoint before the table in the story containing the table.
-
7. Re: [JS] Test fused cells (merge)
Philippe Ruelle Jan 18, 2014 12:24 PM (in response to [Ariel])Thank you and I control this réaplique another Style
leTableau.storyOffset.appliedParagraphStyle = 'centreP';
Merci et avec cet commande je réaplique un autre Style
leTableau.storyOffset.appliedParagraphStyle = 'centreP';


