Performance Problem with larger excel file [horizentalAlignment,NumberFormat] takes too much time

I am having problem with creation of excel file has 20K rows and its taking around 6 minutes to complete the processing.
I have investigated and found that the following two methods are taking too much time

Function Name Inclusive Samples Exclusive Samples Inclusive Samples % Exclusive Samples %
Syncfusion.XlsIO.Implementation.ExtendedFormatWrapper.set_NumberFormat
84,806 16 35.27 0.01
Syncfusion.XlsIO.Implementation.ExtendedFormatWrapper.set_HorizontalAlignment
82,146 9 34.17 0.00

can anyone guide me on this issue.

Thank you

4 Replies

SS Sridhar Sukumar Syncfusion Team October 27, 2017 10:30 AM UTC

Hi Khalid,   
  
Thank you for contacting Syncfusion support.  
  
We suggest you make use of MigrantRange to improve performance and less memory consumption. Kindly refer below code snippet to achieve the same.  
  
Code Example:    
            IMigrantRange range = worksheet.MigrantRange;  
            for (int row = 1; row <= 20000; row++)  
            {  
                for (int column = 1; column <= 50; column++)  
                {  
                    // Writing values.  
                    range.ResetRowColumn(row, column);  
                    IStyle style = range.CellStyle;  
                    style.BeginUpdate();  
                    style.NumberFormat = "@"; 
                    style.HorizontalAlignment = ExcelHAlign.HAlignCenter; 
                    IFont font = style.Font;  
                    font.BeginUpdate();  
                    font.FontName = "Calibri";  
                    font.Size = 8;  
                    font.Bold = true;  
                    font.EndUpdate();  
                    style.EndUpdate();  
                }  
            }  
  
Kindly refer below documentation to know more about improving performance.  
  
  
We have also prepared sample as per your requirement and the sample can be downloaded from the following link.   
   
Sample Link:  
 
Regards, 
Sridhar. 



KM Khalid Mehmood October 27, 2017 11:04 AM UTC

Dear Sridhar,

Thank you for the code sample, I will apply the suggested changes and will update you.


Thank you




SS Sridhar Sukumar Syncfusion Team October 30, 2017 06:37 AM UTC

Hi Khalid,   
  
We are waiting to hear from you. 
 
Regards, 
Sridhar.   



KM Khalid Mehmood October 30, 2017 12:49 PM UTC

Dear Sridhar,

I have forwarded the suggested solution to the development team, I will surely update you in this regard. Thank you for your response and support.


Regards,

Khalid


Loader.
Up arrow icon