FlexSheet copy row

Posted by: digit-b4 on 16 July 2018, 9:30 pm EST

    • Post Options:
    • Link

    Posted 16 July 2018, 9:30 pm EST

    Hi,

    Is there a way to perform programatically a copy/paste into a new row a row from the

    Flexsheet while updating the formulas? Meaning copying all the properties of a row (values and styling) and updating the formula(s) if present to target the new row.

    I managed to create and copy the data from a row to a new row, but the styles are not kept the definedNames are not updated and the formulas not updated to reflect a row change.

  • Posted 17 July 2018, 9:20 pm EST

    Hi,

    To copy the styles, you may use the sheet’s getCellStyle() method to get the cell’s style and then use FlexSheet’s applyCellsStyle() method to set the style for the new cell.

    PS: getCellStyle() method return styles applied using applyCellsStyle() method.

    To update the formula according to new row you need to update it manually before pasting it into the new cell.

    Please refer to the following sample which implements the same:-

    https://stackblitz.com/edit/js-uhgegg?file=index.js

    ~

    Thanks,

    Manish Gupta

  • Posted 18 September 2018, 11:52 pm EST

    Hi Manish,

    Thank you for the sample. We’re in the process of adding an external control to clone a row and inserting it in the spreadsheet. The solution you provided works for updating the new row, however given the addition of the new row, we need to propagate this change to the rest of the formulas in the spreadsheet.

    To give a concrete example:

    a certain column defines a sub-total for a specific row. In a different cell we need to compute the whole total meaning that we need to sum up a cell-range, where the range needs to be updated to reflect the addition of a new row.

    Also we have noticed that for any locked cell (non-editable) the state is not preserved. Upon creating an excel with protected content, and a few editable cells, the whole spreadsheet is editable. Is there any native way to keep this behavior? Adding subscriptions to the cellEdit events and doing custom logic to prevent the user from editing protected cells leads to great performance bottlenecks in our case when the spreadsheet is over 20-30 rows.

    Do you have any pointers to how to achieve this?

    Kind regards,

    Mircea

  • Posted 19 September 2018, 5:21 pm EST

    Hi Mircea,

    You may use insertRows() method of FlexSheet to insert rows in the sheet, insertRows() method makes sure to update the formulas affected by the insertion.

    Please refer to the following sample: https://stackblitz.com/edit/js-mxsy4o?file=index.js

    However, insertRows() method only allows you to insert rows and not append them at the last so to insert rows at the last you still need to use collectionView.addNew() method as shown in the last sample.

    Regarding non-editable cells:

    To make only some specific cells editable/non-editable, handling the beginningEdit event and cancelling the event on specific condition is the only way possible.

    However, you may make the whole column/row non-editable by setting the isReadOnly property to true for Column/Row.

    Regards

    Sharad

Need extra support?

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

Learn More

Forum Channels