API for applying styles on selected cells

Posted by: datta on 15 May 2019, 8:14 pm EST

    • Post Options:
    • Link

    Posted 15 May 2019, 8:14 pm EST

    Hi is there any API available for applying styles like bold italic etc on currently selected cells? I saw two functions

    activeSheet.selectionBackColor(“Accent 6”);

    activeSheet.selectionBorderColor(“Accent 1”)

    Could not see similar apis for other styles like bold italic etc. Is there any apis available for this?

  • Posted 16 May 2019, 5:26 pm EST

    Hi,

    selectionbackColor()/selectionBorderColor() methods were available in spread v9 but in current version spread v12, these are not supported anymore. In current version, you need to get range and apply the style like:

    // get current selection
    var sel = activeSheet.getSelections()[0];
    // get range
    var cellRange = activeSheet.getRange(sel.row, sel.col, sel.rowCount, sel.colCount);
    // apply back color
    cellRange.backColor("green");
    // apply font, bold text
    cellRange.font("'bold normal 15px normal'");
    

    Please refer to the following samples demosntrating the same:

    https://www.grapecity.com/demos/spread/JS/TutorialSample/#/demos/font

    https://www.grapecity.com/demos/spread/JS/TutorialSample/#/demos/style

    Please let us know if are using spread v9 instead.

    Regards

Need extra support?

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

Learn More

Forum Channels