We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Improve memory & performance while print & export the Spreadsheet?

Platform: WPF |
Control: SfSpreadsheet |
Published Date: September 20, 2018 |
Last Revised Date: September 20, 2018

We can improve the performance and memory consumption while exporting to PDF document, the cell “G4” is calculated which contains another calculated formula that depends on another calculated formula and so on. Due to these recursive operations, stack value throws an exception while exporting the document to PDF.

This problem can be resolved in sample level by setting the maximum size of stack while exporting the workbook with new thread.

C#

 

You must set the AllowShortCircuitIFs and MaximumRecursiveCalls properties in threading while printing or exporting to PDF.

C#

private static void PrintFromPdfViewer()

{

    spreadsheetControl.ActiveSheet.Workbook.Worksheets[0].EnableSheetCalculations();

    spreadsheetControl.ActiveSheet.Workbook.Worksheets[0].CalcEngine.AllowShortCircuitIFs = true;

    spreadsheetControl.ActiveSheet.Workbook.Worksheets[0].CalcEngine.MaximumRecursiveCalls = 10000;

 

    ExcelToPdfConverter converter = new ExcelToPdfConverter(spreadsheetControl.Workbook);

    //Intialize the PdfDocument  

    PdfDocument pdfDoc = new PdfDocument();

 

    //Intialize the ExcelToPdfConverter Settings  

    ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings();

    settings.LayoutOptions = LayoutOptions.NoScaling;

 

    //Assign the PdfDocument to the templateDocument property of ExcelToPdfConverterSettings  

    settings.TemplateDocument = pdfDoc;

    settings.DisplayGridLines = GridLinesDisplayStyle.Invisible;

 

    //Convert Excel Document into PDF document  

    pdfDoc = converter.Convert(settings);

 

    //Save the PDF file  

    pdfDoc.Save(pdfstream);

}

 

Sample Link - WPF

 

2X faster development

The ultimate WPF UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile