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