0 Replies Latest reply on Sep 19, 2008 2:42 PM by (Adam_Bauer)

    while loop and if statements in tables

      Greetings

      I have an Excel spread sheet placed into an InDesign CS2 document, I wish to check the data in a specific cell of each row, if it is blank I wish to adjust the style in another cell. Also for every row in the table I wish to change the text in a third cell.

      This script works up to row number 22 in the table at which point the if statement fails to return correctly. Although the line of code " myTbl.columns[2].cells[j].contents = "some Value";
      " continues to work fine.

      The same failure occurs if I separate the two actions into separate while statements. The failure occurs in the same place if I decrement the value of j from the end of the table rather than increment from the beginning. Changing the data set from another Excel document does not have any affect.

      Is there an explanation why the if statement might fail at that point in the table?

      var tblRowLen = myTbl.rows.length // Get the length of the rows array
      var j = 0;
      while (j < tblRowLen){

      if(myTbl.columns[1].cells[j].contents == ""){
      myTbl.columns[0].cells[j].texts[0].applyStyle(pStyles.item( 'HN CalDay' ), false );
      }

      myTbl.columns[2].cells[j].contents = "some Value";

      j++;
      }

      Thanks Adam ;-)