• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Table Row Merging in InDesign

New Here ,
Jul 10, 2021 Jul 10, 2021

Copy link to clipboard

Copied

Hi Guys,

 

I need to create a new row with merge cell and apply footer row style

Plaese help.

 

var table = app.selection[0].parentStory.tables[0] ;
var newRow= table.rows.add( LocationOptions.AT_END).bottomEdgeStrokeWeight = 0;

var l=(table.rows.length)-1;

newRow.table.rows[l].cells.merge(table.rows[l].cells[0]);

TOPICS
Scripting

Views

106

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 10, 2021 Jul 10, 2021

Copy link to clipboard

Copied

Hi arunbitbtech, here's some help:

app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Add Table Footer");

function main() {

    if (app.selection.length == 0) {
        alert('Please make a selection and run script again.');

    } else if (!app.selection[0].parentStory.tables[0].isValid) {
        alert('No table found in selection.');

    } else {

        var table = app.selection[0].parentStory.tables[0];

        // add new row
        var newRow = table.rows.add(LocationOptions.AT_END);
        newRow.bottomEdgeStrokeWeight = 0;

        // convert to footer row
        newRow.rowType = RowTypes.FOOTER_ROW;

        // merge all cells
        newRow.getElements()[0].merge();

        // set cell style of row's first cell
        setCellStyle(app.activeDocument, newRow.cells.item(0), 'My footer cell style');

    }


    function setCellStyle(doc, _cells, styleName) {
        // check if cell style exists before applying it
        if (doc.cellStyles.itemByName(styleName).isValid) {
            _cells.appliedCellStyle = doc.cellStyles.itemByName(styleName);
            _cells.clearCellStyleOverrides(true);
        } else {
            alert('Cell Style "' + styleName + '" not found.');
        }
    }

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 11, 2021 Jul 11, 2021

Copy link to clipboard

Copied

LATEST

The problem is that

var newRow = table.rows.add( LocationOptions.AT_END).bottomEdgeStrokeWeight = 0;

does not return a row, but 0. You should do it as in m1b's example: add a row, then set its various properties.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines