Spread WPF 18
Features / Print / Print Dialogs
In This Topic
    Print Dialogs
    In This Topic

    Spread for WPF allows you to manage the display of the Print dialog that appears before initiating a print operation. 

    Display Print Dialog

    You can choose whether to show the Print dialog before printing. You can set the last parameter of the Print method of the GcSpreadSheet class to true to show the Print dialog.

    Refer to the following example code to display the Print dialog.

    Copy Code
    // To display the Print dialog. 
    GrapeCity.Wpf.SpreadSheet.Printing.PrintSettings printSetting = new GrapeCity.Wpf.SpreadSheet.Printing.PrintSettings();
    spreadSheet1.Print(-1, printSetting, true);
    
    Copy Code
    ' To display the Print dialog. 
    Dim printSetting As GrapeCity.Wpf.SpreadSheet.Printing.PrintSettings = New GrapeCity.Wpf.SpreadSheet.Printing.PrintSettings()
    spreadSheet1.Print(-1, printSetting, True)
    

    Display Print Preview

    Before you start the printing process, you can use the print preview dialog to ensure that your data is accurately displayed. It is usually recommended to print preview the pages because it helps you to avoid unexpected results by addressing issues (such as alignment, formatting, and so on). Additionally, this practice can save a significant amount of paper during the printing process.

    You can use the ShowDialog method of the IDialog interface to view the preview of worksheet pages before printing.

    Refer to the following example code to view the print preview.

    Copy Code
    // To view the print preview.
    IDialog dialog = BuiltInDialogs.PrintPreview(spreadSheet1, -1);  //-1 to show for all sheets
    dialog.ShowDialog();
    
    Copy Code
    ' To view the print preview.
    Dim dialog As IDialog = BuiltInDialogs.PrintPreview(spreadSheet1, -1)  '-1 to show for all sheets
    dialog.ShowDialog()