Setting bold/italic for entire spread sheet taking huge time

Posted by: soumen.choudhury on 29 November 2018, 7:59 pm EST

    • Post Options:
    • Link

    Posted 29 November 2018, 7:59 pm EST

    Setting bold for entire spread sheet taking huge time. 100*100 took almost 3 mins, which is huge for end user.

    We are using below code to do the job. Is there any way to set bold for entire spread sheet in an efficient way? Although I don’t want to update the entire style of the spread sheet as the individual cell may have their own style. I only want to set text as bold without affecting cells current style.

    Please find attached example, which we used for our testing

    for (var col = 0; col < sheet.getColumnCount(); col++) {

    for (var row = 0; row < sheet.getRowCount(); row++) {

    sheet.setStyle(row, col, style);

    }

    }

    SpreadJS11_BasicSheet.zip

  • Posted 30 November 2018, 4:41 pm EST

    Have you tried suspendPaint() and resumePaint() on the spread?

    http://help.grapecity.com/spread/SpreadSheets11/webframe.html#SpreadJS~GC.Spread.Sheets.Workbook~suspendPaint.html

    It happens often that repaint is not efficient.

    Quickly tested your example and it work.

    
        makebold = function() {
            style = new GC.Spread.Sheets.Style();
            style.font = "bold 15px Arial";
            
            var startTime = new Date();
            spread.suspendPaint();
            for (var col = 0; col < sheet.getColumnCount(); col++) {
                for (var row = 0; row < sheet.getRowCount(); row++) {
                   sheet.setStyle(row, col, style);
                }
            }
            spread.resumePaint();
            var endTime = new Date();
            alert("That took " + ((endTime - startTime)/1000) + " seconds!");
        };
    
    
  • Posted 2 December 2018, 2:19 am EST

    Thanks Adrien. That solution worked.

Need extra support?

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

Learn More

Forum Channels