FlexSheet - Automatically add rows when pasting data

Posted by: holly.anderson on 16 October 2017, 1:14 am EST

    • Post Options:
    • Link

    Posted 16 October 2017, 1:14 am EST

    Hello,

    Is there any way to add extra rows if pasted data exceeds the size of the spreadsheet? For example, if there are only 5 rows in the spreadsheet, and the user attempts to paste 10 rows of data, I’d like for 5 additional rows to be added so that the entire data can be pasted successfully. I tried adding a handler to the pasting event, but I don’t know how to detect the number of pasted rows.

    Thanks,

    Holly

  • Posted 16 October 2017, 5:20 pm EST

    You can use the CellRangeEventArgs that is passed a parameter to the OnPastedEvent . The CellRangeEventArgs contains the Range Property which can be used to establish the Rows that are to be pasted.

    Let me know if you are still facing issues.

    Thanks,

    Abhishek

  • Posted 17 October 2017, 12:01 am EST

    Hi Abhishek,

    I tried using the pasting and pasted events in the attached sample, but the rowSpan and columnSpan is 1, even when I paste multiple rows/cols. Am I looking at the wrong properties? I want to detect the number of rows that the user is attempting to paste, so that I can add more rows if necessary.

    Holly

    FlexSheetDemo_Paste.zip

  • Posted 17 October 2017, 5:32 pm EST

    Hi Holly,

    I would suggest you to use the _copiedRanges property, this will return you the CopiedRow Range , If you check the Top Row and Bottom Row properties each of the Range Objects , this will help you establish that rows that user is trying to Copy.

    sheet.pasted.addHandler(function (s, e) {

    var Ranges=s._copiedRanges

            });
    
  • Posted 18 October 2017, 12:49 am EST

    What if the user is pasting data from an external excel file?

  • Posted 22 October 2017, 8:16 pm EST

    Hi Holly,

    With the latest build 5.20172.359, you need to allowAddNew property to true and this will add the new row as per need.

    For reference, please refer to the attached sample.

    ~Manish

    FlexSheet.zip

Need extra support?

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

Learn More

Forum Channels