Inserting new rows in a table loses the cell styling

Posted by: christine on 22 December 2021, 9:50 am EST

  • Posted 22 December 2021, 9:50 am EST

    I have a table that I dynamically add data to, I use addRows to makes the sheet longer then insertRows to add extra rows to the table and then use setArray to add in the new data. The resulting table maintains the original formulas but loses the original styling. Am I missing something??

    Snippet of code from my application:

    
            const activeTable = sheet.tables.findByName('TABLE NAME'); 
            const dataRange = activeTable.dataRange();
            const rowCount = dataRange.rowCount;
            const tableLength = table.value.length; // table.value is an array of the extra data I am trying to add
    	sheet.addRows(sheet.getRowCount(), tableLength - rowCount + 1);
            activeTable.insertRows(0, tableLength - rowCount, true);
            sheet.setArray(dataRange.row, dataRange.col, table.value, false);
    
    
  • Posted 23 December 2021, 6:06 am EST

    Hi,

    Tables indexes are also zero-based. We have tested your code and the problem arises because you have passed the wrong parameters inside the addRows and insertRows method.

    Please refer to the attached sample that we have created for you and let us know if we are missing something in order to replicate the issue.

    Sample: https://jscodemine.grapecity.com/share/DHsJEVV5i0iVrdnYcaUg9g/

    Thanks.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels