You can't. Table Styles are frustratingly limited. If you use a Header or Footer row the Cell Style can only be applied to the entire row. You can define a cell Style for the ”amount” cell but you have to apply it manually.
Apply your "yyy" table style to all tables you want in your doc and just do it!
var myTables = app.activeDocument.stories.everyItem().tables.everyItem().getElements(); for ( var t = 0; t < myTables.length; t++ ) if ( myTables[t].appliedTableStyle.name == "yyy" ) myTables[t].columns.cells.contents += "\t";
"Un petit clic vaut mieux qu'une grande claque !"
Yeah, I´ve read about the limited options working with tables. Although we enjoy InDesign for more than 17 years there are some basic things doesn´t work. So for exemple auto fit cells. Basicly make tables the most of the problems. Pretty sad.
thank you Scott
Okay, I've assumed that I can solve it with a script. But I wanted to avoid it.
However thanks for the idea Obi-wan
The script just adds a tab at the end of the first cell of all tables with "yyy" table style applied!
That means that if you change the table style "yyy" to another style "xxx", you keep the effect (text apparently aligned on the left, but in fact, always centered)!!
… If you have already place the tab, just apply your table style! Nothing else to do!!!
Okay you wizzard, that was magicly fast.
But I think I´ll assign the style manually (only for the left table-head cell).
Obi-wan Kenobi wrote:
The script just adds a tab at the end of the first cell of all tables with "yyy" table style applied!…
cells.contents += "\t";
can be quite dangerous. Depending on the nature of contents and formatting that could damage a lot.
See the following cell with overset text:
After running your line of code:
Wheras if you are working "minimal invasive" with the last insertion point of the cell's Text object the old text is not touched:
cells.texts.insertionPoints[-1].contents = "\t";
Also: Your method will remove anchored objects or nested tables and therefore can change formatting of the remaining text.
Just a warning…
Thanks Uwe for this little tutorial! [I appreciate all comment that makes me learn more!!]
I didn't know you so "mystical" seeing you use "666" Devil sign [Halloween soon of course! ]. Jedis call it "Sith sign"!!
However, the result is not perfect!
What is missing is to avoid to process again a cell that already has a tab at its content end!!
I didn't find a good syntax to avoid that!
var myTables = app.activeDocument.stories.everyItem().tables.everyItem().getElements(); for ( var t = 0; t < myTables.length; t++ ) if ( myTables[t].appliedTableStyle.name == "yyy" ) myTables[t].columns.cells.texts.insertionPoints[-1].contents = "\t";
PS: In a first time, I've played inserting after the 2 code lines a Grep research but I don't find this really very interesting!
app.findGrepPreferences = app.changeGrepPreferences = null; app.findGrepPreferences.findWhat = "(\t)+$"; app.findGrepPreferences.appliedParagraphStyle = "Header C"; app.changeGrepPreferences.changeTo = "$1"; app.activeDocument.changeGrep(); app.findGrepPreferences = app.changeGrepPreferences = null;
Thank you guys!
This time I looked for a solution without scripting! But maybe it´s useful for others...