addSpan slow

Posted by: ngocnguyen09910060 on 1 November 2022, 1:31 am EST

  • Posted 1 November 2022, 1:31 am EST

    Hi teams,

    On my application, i have 15000 rows and 20 columns:

    sheet.setRowCount(15000);
    sheet.setColumnCount(20);

    I want to merge 10 first columns for even rows. This is my source code:

    for (let i = 0; i < sheet.getRowCount(); i = i + 2) {
    	for (let j = 0; j < 10; j++) {
    		sheet.addSpan(i, j, 2, 1, GC.Spread.Sheets.SheetArea.viewport);
    	}
    }

    When i open my application on browser, it take about 36 seconds to render page with 15000 rows.

    But it take about 114 seconds to render page with 30000 rows.

    I think render time for page with 30000 rows is about 70 seconds. Please check my sample source code and tell me how to improve performance for addSpan method.

    SpreadJS_addSpan.zip

  • Posted 1 November 2022, 7:48 pm EST - Updated 1 November 2022, 7:53 pm EST

    Hi,

    At our machine(windows i7 16GB RAM windows 10) it takes 12-13 sec to complete the task which is expected because the number of cells it is changing is 10*15000 = 150000.

    Regards,

    Avinash

  • Posted 1 November 2022, 8:36 pm EST

    Hi avinash.pathak,

    My machine has the same configuration (Windows 10 Pro, i7, 16GB RAM, 1TB SSD).

    Anyway, please change my sample source code to

    sheet.setRowCount(30000);
    and give me the result.

  • Posted 1 November 2022, 9:09 pm EST - Updated 1 November 2022, 9:14 pm EST

    Hi,

    At my machine, it takes 46 sec to complete with 30000*10 cell cells.

    Regards,

    Avinash

  • Posted 1 November 2022, 10:48 pm EST

    Hi avinash.pathak,

    I understand that data increase twice, so the rendering time will increase twice too.

    For example:

    • 15000 row => the rendering time: 13s
    • 30000 row => the rendering should be 25-30s.

      Why does your machine take 46s to render ?
  • Posted 2 November 2022, 7:35 pm EST

    Hi,

    We have escalated this issue to the concerned team for further investigation. We will update you regarding this as we get any information from th team. The internal ID for this issue will be SJS-15380.

    Regards,

    Avinash

  • Posted 31 May 2023, 4:13 pm EST

    Hi,

    The team informed us that When adding a span to a worksheet, the spreadjs need to check if the span will intersect with the existing span.

    So,

    1st span, no need to check.

    2nd span, need to check 1st span

    3rd span, need to check 1st, 2nd span.

    4rd span, need to check 1,2,3rd span.

    n span, need to check 1~n-1 span.

    So, the checking time is not linner that is why it is taking time.

    Regards,

    Avinash

  • Posted 7 April 2024, 8:10 am EST

    hi,

    the team has added a new method addSpans that will resolve the performance by skipping the validation logic in case of adding spans in batch.

    however, i would like to know what is your use case for adding such a large number of spans in your spreadsheet? can you share an example of what you’re trying to create.

    also, in cases like this, it might be better to perform this logic once, save the spreadsheet as a template to sjs file format then load the file whenever you need it, it doesn’t have to perform the cell merge every time.

    issam

Need extra support?

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

Learn More

Forum Channels