8 Replies Latest reply on Aug 26, 2014 12:54 AM by VeluVK

    Financial table alignment

    VeluVK Level 1

      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.

       

      table.JPG

       

      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


        • 1. Re: Financial table alignment
          Sajeev Sridharan Level 4

          Try this,

           

          var myTable = app.activeDocument.stories.everyItem().tables.everyItem().getElements();  
          for(t=0; t<myTable.length; t++)  
          { 
              myTable[t].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[i].contents.toString().match(')'))
                  {
                      found[i].texts[0].appliedParagraphStyle = "Tbody_bracket";
                  }
                  else
                  {
                      found[i].texts[0].appliedParagraphStyle = "Tbody_rightalign";
                  }
              }
          }
          

           

           

          Vandy

          • 2. Re: Financial table alignment
            VeluVK Level 1

            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

            • 3. Re: Financial table alignment
              VeluVK Level 1

              Hi Vandy,

               

              Thanks a lot for the script. Much appreciated. It works perfectly. It is very very useful.

               

              I need one more requirement.

               

              In Tables, For all parenthesis underline values should be "Tbody_rule1(bracket)" paragraph style, without bracket underline words should be "Tbody_rule1(nobracket)" Paragraph Style"

               

              All these and the previous "Financial table alignment" script can merge into a single script is better for me.

              Test.JPG

              For example:

               

              All grey shaded underlined words should be a "Tbody_rule1(nobracket)"

              All pink shaded parenthesis underlined words should be a "Tbody_rule1(bracket)"

               

               

              Regards,

              Velu

              • 4. Re: Re: Financial table alignment
                Sajeev Sridharan Level 4

                Try this,

                 

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

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

                {  

                   myTable[t].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[i].contents.toString().match(')') && found[i].underline == true) 

                        { 

                            found[i].texts[0].appliedParagraphStyle = "Tbody_rule1(bracket)"

                        } 

                        if(!found[i].contents.toString().match(')') && found[i].underline == true) 

                        { 

                            found[i].texts[0].appliedParagraphStyle = "Tbody_rule1(nobracket)"

                        } 

                        else 

                        { 

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

                        } 

                    } 

                }


                Vandy

                • 5. Re: Financial table alignment
                  VeluVK Level 1

                  Hi Vandy,

                   

                  The script working fine (except the below condition), In Merged script missed the below condition. can you please include this condition?

                   

                  if(found[i].contents.toString().match(')') && !found[i].underline == true) 

                  {

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



                  Values within parenthesis & no underline words should be  "Tbody_bracket" Paragraph style (as per first script)




                  Regards,

                  Velu

                  • 6. Re: Re: Financial table alignment
                    Sajeev Sridharan Level 4
                    var myTable = app.activeDocument.stories.everyItem().tables.everyItem().getElements();   
                    for(t=0; t<myTable.length; t++)   
                    {  
                       myTable[t].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[i].contents.toString().match(')') && found[i].underline == true) 
                            { 
                                found[i].texts[0].appliedParagraphStyle = "Tbody_rule1(bracket)"; 
                            } 
                            else if(found[i].contents.toString().match(')') && found[i].underline == false) 
                            { 
                                found[i].texts[0].appliedParagraphStyle = "Tbody_bracket"; 
                            } 
                            else if(!found[i].contents.toString().match(')') && found[i].underline == true) 
                            { 
                                found[i].texts[0].appliedParagraphStyle = "Tbody_rule1(nobracket)"; 
                            } 
                            else 
                            { 
                                found[i].texts[0].appliedParagraphStyle = "Tbody_rightalign"; 
                            } 
                        } 
                    }
                    

                     

                    Vandy

                    • 7. Re: Financial table alignment
                      VeluVK Level 1

                      Hi Vandy,

                       

                      Thank you so much, It working Perfect.

                       

                       

                      Regards,

                      Velu

                      • 8. Re: Financial table alignment
                        VeluVK Level 1

                        Hi Vandy,

                         

                        For all tables second column onwards, need to distribute column width into "6p" width. Suggest pls.

                         

                         

                        Regards,

                        Velu