Copy link to clipboard
Copied
Hi guys,
I'm trying to save some time by using a script that'll work on tables but I'm facing a problem on 1 line.
I would like to Center the text of the first column, without using any paraphStyle.
Here is part of it.
table.cells.everyItem().clearCellStyleOverrides(true);
table.appliedTableStyle = "Main Table";
table.cells.everyItem().leftInset = table.cells.everyItem().rightInset = "1.411 mm";
table.cells.everyItem().topInset = table.cells.everyItem().bottomInset = "1.411 mm";
table.cells.everyItem().verticalJustification = VerticalJustification.CENTER_ALIGN;
table.columns[0].width = "10";
table.columns[1].width = "76";
//table.columns[0].cells.everyItem()... (what about here ??) ... Justification.CENTER_ALIGN;
table.cells.everyItem().autoGrow = true;
table.cells.everyItem().minimumHeight = "1.058 mm";
My challenge here is to fill the gap at the line
//table.columns[0].cells.everyItem()... (what about here ??) ... Justification.CENTER_ALIGN;
Any help will be appreciated 😉
Copy link to clipboard
Copied
Are you missing texts[0] ?
Be careful with everyItem() . Could crash your script or InDesign itself if some conditions are not met.
Take for example this line, that should remove the last row of every table in the document:
app.documents[0].stories.everyItem().tables.everyItem().rows[-1].remove();
That would crash InDesign if it happens that there is a table with only one header row and one single body row.
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
To target all cells in the first column of a table, it's:
table.columns[0].cells.everyItem().texts[0].justification = Justification.CENTER_ALIGN;
Copy link to clipboard
Copied
Thank you guys, I was definitely missing something …
I thought I needed to get around it with Texts/ appliedStyles and so on. It turns out to be far simpler.
Thanks a lot ^^ works as a charm !