Slow Performance

Posted by: nchalla on 4 January 2018, 2:41 pm EST

  • Posted 4 January 2018, 2:41 pm EST

    Hi,

    Reading formatting from the cells (used range) is taking a lot of time. For example, 2000 Rows X160 Columns sheet taking ~90 sec. Any idea on how to improve the performance?

    Thanks.
  • Replied 4 January 2018, 2:53 pm EST

    The sheet size is 2000 Rows X 66 Columns
  • Replied 4 January 2018, 10:30 pm EST

    Hello,

    Please make sure that you are applying the formatting between suspendPaint and resumePaint methods. This helps improving the performance. I used the code below to set formatting for same number of rows and columns and it takes only 9058 ms:


    $(document).ready(function () {
    var spread = new GC.Spread.Sheets.Workbook(document.getElementById('ss'));
    var sheet = spread.getActiveSheet();
    sheet.setRowCount(2000);
    sheet.setColumnCount(66);
    var rowCount = sheet.getRowCount();
    var colCount = sheet.getColumnCount();

    $('#styleButton').click(function () {

    var t0 = performance.now();
    spread.suspendPaint();
    sheet.getRange(0, 0, rowCount, colCount).vAlign(GC.Spread.Sheets.VerticalAlign.bottom);
    sheet.getRange(0, 0, rowCount, colCount).backColor("lightblue");
    sheet.getRange(0, 0, rowCount, colCount).textDecoration(GC.Spread.Sheets.TextDecorationType.overline | GC.Spread.Sheets.TextDecorationType.underline);
    spread.resumePaint();
    var t1 = performance.now();

    alert("Execution time: " + (t1 - t0) + " milliseconds.");
    });


    });


    Please provide me the sample code to replicate the issue in case the issue still persists.

    Thanks,
    Deepak Sharma
  • Replied 5 January 2018, 12:09 am EST

    Hey Deepak,

    I'm talking about the Spread.Services performance not about the Spread.sheets.

    Thanks.
  • Replied 7 January 2018, 10:56 pm EST

    Hello,

    Sorry for the confusion!
    Could you please provide me your sample application/code to see how exactly are you applying the formatting to cells?

    Thanks,
    Deepak Sharma
  • Replied 25 January 2018, 6:56 pm EST

    Deepak,

    I'm not applying the format I'm reading them. below is the code snippet.

    var count = range.Cells.Count;

    for(var i = 0; i < count; ++i) {
    DataCell cell = new DataCell();
    IRange obj = usedRange.Cells[i];

    cell.RowIndex = obj.Row;
    cell.ColIndex = obj.Column;
    if(obj.Font.Bold) cell.IsBold = 1;
    if(obj.Font.Italic) cell.IsItalic = 1;
    if(obj.Font.Underline == UnderlineType.Single || obj.Font.Underline == UnderlineType.SingleAccounting) {
    cell.UnderLineStyle = 1;
    }
    else if(obj.Font.Underline == UnderlineType.Double || obj.Font.Underline == UnderlineType.DoubleAccounting) {
    cell.UnderLineStyle = 2;
    }
    if(obj.WrapText) cell.IsTextWrapped = 1;
    if(obj.Locked) cell.IsLocked = 1;
    cell.Formula = obj.Formula;
    cell.FontName = obj.Font.Name;
    cell.FontSize = obj.Font.Size;
    cell.HAlign = obj.HorizontalAlignment.ToString();
    cell.VAlign = obj.VerticalAlignment.ToString();
    //cell.Background = obj.Interior.Color.ToString();

    sheetsFormat.Add(cell);
    }


    And the range is 2000X60 cells.
  • Marked as Answer

    Replied 29 January 2018, 1:23 am EST

    Hello,

    Above code snippet does not tell what style is applied to the cells. I would really appreciate if you could provide me your sample application to debug this issue further. Or provide me the Excel file you are trying to read with the above code snippet.

    Thanks,
    Deepak Sharma

Need extra support?

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

Learn More

Forum Channels