Spread Windows Forms 17
Spread Windows Forms 17.0 Product Documentation / Developer's Guide / Printing / Specifying What to Print / Printing an Entire Sheet
In This Topic
    Printing an Entire Sheet
    In This Topic

    You can print spreadsheets using the Spread component in the following two ways:

    Using the PrintSheet() Method

    You can use this method to print a particular sheet or multiple sheets using the PrintInfo settings for each sheet. Each sheet can have its own PrintInfo object, but you can call the PrintSheet method once to print one or all of the sheets. If the sheet parameter is set to -1, all the sheets in the Spread component will print, with each sheet (with its individual PrintInfo settings) as a separate print job. The PrintDocument event occurs while printing a sheet.

    The default setting prints in black and white and automatically determines the best order in which you can print the pages. With the default settings, the following items can be printed using the printer’s current orientation setting:

    To customize these settings, refer to Understanding the Printing Options and Customizing the Printed Page Header or Footer. To allow Spread to determine the best print settings, refer to Optimizing the Printing Using Rules.

    You can call the PrintSheet() method with different sheet parameters one after the other but calling this method on the same sheet without waiting for the initial print to conclude could produce incorrect results. Before calling the next print for a given sheet, you need to wait for the previous one to be finished. You can do this by catching the PrintMessageBox event and querying the BeginPrinting parameter to see if it is False.

    Using Code

    Use the PrintSheet method in the FpSpread class to print the specified sheet.

    Example

    This example code prints the second sheet in the component using the PrintSheet() method.

    C#
    Copy Code
    fpSpread1.PrintSheet(1);
    
    VB
    Copy Code
    fpSpread1.PrintSheet(1)
    

    Using the SafePrint() Method

    The SafePrint() method provides users with the flexibility to execute print jobs in a single thread, rather than creating a separate thread. Since it allows printing in the stream synchronously in the same thread, the UI becomes unresponsive till the print operation is complete.

    Using this method, you can print spreadsheets in a console application.

    Using Code

    Use the SafePrint method in the FpSpread class to print the spreadsheet in a console application.

    Example

    This example code prints the second sheet in the console application using the SafePrint() method.

    C#
    Copy Code
    fpSpread1.SafePrint(fpSpread1,0);
    
    VB
    Copy Code
    fpSpread1.SafePrint(fpSpread1,0)
    

    You can also use the Spread Designer in order to set properties for printing, and you can also print directly from the Spread Designer. For more information, refer to Printing a Sheet from Spread Designer.

    See Also