Set Style for an array instead of cell by cell

Posted by: dave.welch on 4 November 2020, 3:35 am EST

  • Posted 4 November 2020, 3:35 am EST

    Hi,
    I want to set style for an array of cells.
    The below procedure sets style for a particular row, column
    activeSheet.setStyle(1,1,style,GC.Spread.Sheets.SheetArea.viewport);

    IS there any function to set the styles in array something like setArray or setArrayFormula

    setStyle is making the application load slow since there is more records on excel and setStyle is setting cell wise.

    Please suggest.

    Thanks,
  • Replied 4 November 2020, 7:05 pm EST

    Hi David,

    For batch updates, please make sure that you are using suspendPaint()/resumePaint() to improve performance.
    https://www.grapecity.com/spreadjs/docs/v13/online/UsingsuspendPaintandresumePaint.html

    There is no method available to set the same style on the whole range/array. But you may pass -1 as row/column index to set the style on the column/row when using the setStyle() method link:
    sheet.setStyle(-1, 1, style); // set style on 2nd column

    Also, if need to update a single property on the range then you may use the getRange() method to get the range and then use range methods such as backColor()/formatter() etc to update the style property as demonstrated in the following code snippet:
    sheet.getRange(rowIndex, colIndex, rowCount, colCount).backColor("pink");


    API Reference:
    • CellRange: https://www.grapecity.com/spreadjs/docs/v13/online/SpreadJS~GC.Spread.Sheets.CellRange.html

    Regards
    Sharad
Need extra support?

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

Learn More

Forum Channels