This is a migrated thread and some comments may be shown as answers.

Merge operation works to slow

2 Answers 87 Views
SpreadProcessing
This is a migrated thread and some comments may be shown as answers.
Ars
Top achievements
Rank 1
Ars asked on 22 Nov 2015, 07:24 PM

Hi, 

I`m playing with Excel export task using SpreadProcessing.

I`ve notice that when i`m using merge for cellSelection - time needed to write to workbook increases dramatically. 

I made simple test -  cycle with 10000 inserts operations and merges of two cells (horizontal merge).

The results for cycle:

- with merge takes 00:00:06.3593555

- without merge takes 00:00:00.1815065

 My code:

var workbook = CreateWorkbook();
 workbook.History.IsEnabled = false;
workbook.SuspendLayoutUpdate();           
var worksheet = workbook.ActiveWorksheet;          
for (int i = 0; i < 10000; i++)
{
    CellIndex cellIndex = new CellIndex(i, 0);
    worksheet.Cells[cellIndex].SetValue("Data " + i);
    worksheet.Cells[cellIndex].SetHorizontalAlignment(RadHorizontalAlignment.Left);
    worksheet.Cells[i, 0, i, 2].MergeAcross();
}
workbook.ResumeLayoutUpdate();
workbook.History.IsEnabled = true;

Although, I made test with merge from 0 to 8 column. Result - 00:00:15.4579052.

Is there any workaround of such perfomance issue? 

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Nikolay Demirev
Telerik team
answered on 23 Nov 2015, 09:17 AM
Hi Ars,

Merging of cells copies the formatting values from the top left cell of the merged area to the whole merged area. These properties are 19 cell properties. For merging one cell range, each property value is retrieved and then set to the entire range. That mean for the merging of 10000 ranges minimum 380000 read and write operations are performed on the internal structures.

If you just set the cell values only 10000 write operations are performed on the internal structures. That is why merging of cells takes so long.

We are currently working on a new library which is meant only for export scenarios. And it is extremely fast. It will be released with the Q1 2016 release.

Regards,
Nikolay Demirev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Ars
Top achievements
Rank 1
answered on 24 Nov 2015, 09:05 AM

Hi, Nikolay Demirev

 thank you for fast reply.

I'll look forward to the Q1 2016 release. 

 For others, for now I create my report with EPPlus on the server sider of my app. It works very fast. 

Tags
SpreadProcessing
Asked by
Ars
Top achievements
Rank 1
Answers by
Nikolay Demirev
Telerik team
Ars
Top achievements
Rank 1
Share this question
or