Feature to copy only visible rows from spreadjs sheet

Posted by: insensitive on 8 September 2017, 10:03 am EST

    • Post Options:
    • Link

    Posted 8 September 2017, 10:03 am EST

    Hello

    If I copy range of multiple rows from spreadjs sheet to Excel or notepad, hidden rows also gets copied. I want that only visible rows gets copied.

    I already understand this feature can not be provided by spreadjs. I need some guidance on what is the best way I implement this functionality on top of library.

    If you mention some built in utilities that I can reuse, it will be helpful.

    Thank you

  • Posted 8 September 2017, 10:03 am EST

    Hi,

    You can use getRowVisible to get which rows are visible and hidden.

    You can use getCsv to get a delimited string from a cell range (specify “\r\n” for row delimiter and “\t” for column delimiter to get tab-delimited text).

    Using those methods together, you can implement logic which gets the tab-delimited text from the visible rows of a cell range. To put that text on the system clipboard will require some browser-specific script or using some tricks in the script to make the browser copy the text from a hidden input field. Here is a helpful blog about implementing copy/paste support in javascript.

    Regards,

    -Sean

  • Posted 8 September 2017, 10:03 am EST

    Hi,

    Currently, In excel when we do copy+Paste, it wouldnt copy the hidden rows.

    Please confirm if there is any plan to implement the same in spreadJS.

    Thanks,

    Rahul

  • Posted 8 September 2017, 10:03 am EST

    Hi,

    I have submitted an enhancement request for this feature (#193940) and we will consider adding it in an upcoming release.

    I agree with you that it is a very useful feature.

    If the developers have some additional suggestions for working around this issue, I will post here.

    Regards,

    -Sean

  • Posted 8 September 2017, 10:03 am EST

    is there any way to not copy hiddn cell when copy+pasting

  • Posted 28 September 2017, 11:22 am EST

    Thanks for creating an enhancement request. Just wanted to let you know we are waiting for this feature as well.

  • Posted 10 October 2017, 11:12 am EST

    Hello,

    You can use the code as follows to create a custom function and return the array containing the visible rows only:

    function GetVisibleCells()

    {

    this.name = “GETVISIBLECELLS”;

    this.minArgs = 1;

    this.maxArgs = 255;

    }

    GetVisibleCells.prototype = new GC.Spread.CalcEngine.Functions.Function();

    GetVisibleCells.prototype.evaluate = function ()

    {

    var spread = GC.Spread.Sheets.findControl(“ss”);

    var sheet = spread.getSheetFromName(arguments[0].source.getName());

    var calcArray = ;

    for (var i = 1; i < arguments.length; i++)

    {

    var selRow = arguments[i].getRow(), selRowCount = arguments[i].getRowCount();

    var selCol = arguments[i].getColumn(), selColCount = arguments[i].getColumnCount();

    for (var row = selRow; row < selRow + selRowCount; row++)

    {

    if (sheet.getRowHeight(row) > 0)

    {

    for (var col = selCol; col < selCol + selColCount; col++)

    {

    if (sheet.getColumnWidth(col) > 0)

    { calcArray.push(sheet.getValue(row, col)); }

    }

    }

    }

    } return new GC.Spread.CalcEngine.CalcArray([calcArray]);

    }

    GetVisibleCells.prototype.isContextSensitive = function ()

    {

    return true;

    }

    GetVisibleCells.prototype.acceptsReference = function ()

    {

    return true;

    }

    Please refer to the attached sample application to have a clear understanding of the code and it’s implementation.

    Thanks,

    Deepak Sharma

    GetVisibleSelection.zip

Need extra support?

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

Learn More

Forum Channels