Javascript target footer row

Viewing 2 reply threads
  • Author
    Posts
    • #100239
      James Welsh
      Member

      What I want to do is using
      // based on https://creativepro.com/tackling-tables-through-scripting.php
      // by Theunis De Jong

      Target the tables in a document and set hte topEdgeStrokeColor and topEdgeStrokeWeight of the nth footer row. I can’t just use the ros[-1] to style the last row to “look” like a footer because we use real footers to deal with tables that continue from the bottom one page to the next page.

      This is what I’m trying (I’ve tried other objects too). For the life of me I can find the correct target in the document object model. Tried to use this as well… https://jongware.mit.edu/idcs6js/pc_Table.html

      function processTable(table)
      {
      table.footerRows[0].cells.properties = {topEdgeStrokeColor: “CBOC Blue”};
      }

    • #100247

      It seems, that you cannot target footer rows directly?! Maybe there is an easier solution, but the following lines are working:

      main();
      
      function main() {
        var allTables = app.activeDocument.stories.everyItem().tables.everyItem().getElements();
        for (var i = 0; i < allTables.length; i++) {
          var curTable = allTables[i];
          var numberOfFooterRows = curTable.footerRowCount;
          var fRows = curTable.rows.itemByRange(-numberOfFooterRows, -1).getElements();
          var firstFooterRow = fRows[0];
          firstFooterRow.properties = {topEdgeStrokeColor: "CBOC Blue"};
        }
      }
      

      Kai

    • #100332
      Peter Kahrel
      Participant

      Hi Kai,

      > you cannot target footer rows directly?!

      Well, in a way you can:

      The nth footer row in a table:

      myTable.rows [myTable.headerRowCount + myTable.bodyRowCount + n-1]

      Peter

Viewing 2 reply threads
  • You must be logged in to reply to this topic.
>