Skip to main content
Inspiring
August 22, 2014
Answered

Financial table alignment

  • August 22, 2014
  • 1 reply
  • 1071 views

Hi,

I am working in financial tables. i need script for the below requirement. Any one please suggest.

For all tables from second column onwards ""Tbody_rightalign" paragraph style. and all parenthesis values should be "Tbody_bracket" style, but these changes to be omitted in first rows because column head having separate style.

Grey should be Tbody_rightalign, paragraph style.

Pink color should be Tbody_bracket, paragraph style.

Any one help me pls. i am having 150+ tables.

Thanks,

Velu


This topic has been closed for replies.
Correct answer Sajeev Sridharan

Try this,

var myTable = app.activeDocument.stories.everyItem().tables.everyItem().getElements(); 

for(t=0; t<myTable.length; t++) 

{

    myTable.select();

    app.selection[0].rows[1].columns[1].cells[1].select();

    app.selection[0].parent.cells[-1].select(SelectionOptions.ADD_TO);

    app.findGrepPreferences = app.changeGrepPreferences = null;

    app.findGrepPreferences.findWhat = ".+";

    found = app.selection[0].findGrep (true);

    for (i = 0; i < found.length; i++)

    {

        if(found.contents.toString().match(')'))

        {

            found.texts[0].appliedParagraphStyle = "Tbody_bracket";

        }

        else

        {

            found.texts[0].appliedParagraphStyle = "Tbody_rightalign";

        }

    }

}

Vandy

1 reply

Sajeev SridharanCorrect answer
Legend
August 23, 2014

Try this,

var myTable = app.activeDocument.stories.everyItem().tables.everyItem().getElements(); 

for(t=0; t<myTable.length; t++) 

{

    myTable.select();

    app.selection[0].rows[1].columns[1].cells[1].select();

    app.selection[0].parent.cells[-1].select(SelectionOptions.ADD_TO);

    app.findGrepPreferences = app.changeGrepPreferences = null;

    app.findGrepPreferences.findWhat = ".+";

    found = app.selection[0].findGrep (true);

    for (i = 0; i < found.length; i++)

    {

        if(found.contents.toString().match(')'))

        {

            found.texts[0].appliedParagraphStyle = "Tbody_bracket";

        }

        else

        {

            found.texts[0].appliedParagraphStyle = "Tbody_rightalign";

        }

    }

}

Vandy

VeluVKAuthor
Inspiring
August 25, 2014

Hi Vandy,

Thanks for the script. It works perfectly.

I need one more requirement.

Tables For all parenthesis underline values should be "Tbody_rule1" paragraph style. And without bracket underline words are "Tbody_rule1" Paragraph Style"

Regards,

Velu