SpreadJS 13
GC.Spread.Sheets Namespace / CalcEngine type / rangesToFormula Method
The cell range in the sheet.
The base row index of the formula.
The base column index of the formula.
Whether the range reference is relative or absolute.
Whether to use the r1c1 reference style.
In This Topic
    rangesToFormula Method
    In This Topic
    Converts the specified cell range to a formula string.
    Syntax
    var value; // Type: string
    value = GC.Spread.Sheets.CalcEngine.rangesToFormula(ranges, baseRow, baseCol, rangeReferenceRelative, useR1C1);
    function rangesToFormula( 
       ranges : undefined,
       (optional) baseRow : number,
       (optional) baseCol : number,
       (optional) rangeReferenceRelative : RangeReferenceRelative,
       (optional) useR1C1 : boolean
    ) : string;

    Parameters

    ranges
    The cell range in the sheet.
    baseRow
    The base row index of the formula.
    baseCol
    The base column index of the formula.
    rangeReferenceRelative
    Whether the range reference is relative or absolute.
    useR1C1
    Whether to use the r1c1 reference style.

    Return Value

    The formula string that refers to the specified cell range.
    Example
    spread = new GC.Spread.Sheets.Workbook(document.getElementById('ss'), { sheetCount: 1 });
    sheet = spread.getSheet(0);
    // Setting Value
    sheet.setValue(0, 0, 1, 3);
    sheet.setValue(1, 0, 50, 3);
    sheet.setValue(2, 0, 100, 3);
    sheet.setValue(3, 0, 2, 3);
    sheet.setValue(4, 0, 60, 3);
    sheet.setValue(5, 0, 90, 3);
    sheet.setValue(6, 0, 3, 3);
    sheet.setValue(7, 0, 40, 3);
    sheet.clearSelection();
    // Adding selections
    sheet.addSelection(0, 0, 3, 1);
    sheet.addSelection(5, 0, 2, 1);
    var ranges = sheet.getSelections();
    // getting range string
    var rangesStr = GC.Spread.Sheets.CalcEngine.rangesToFormula(ranges);
    // creating formula using selected ranges
    var formula = "Sum(" + rangesStr + ")";
    // setting formula in Sheet's cell
    sheet.setFormula(5, 5, formula, GC.Spread.Sheets.SheetArea.viewport);
    Remarks

    See Also

    Reference

    CalcEngine type