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

    You can print all or some of the pages for the sheet. Specify the pages to print by setting the PrintType, PageStart, and PageEnd properties of the PrintInfo object.

    You can calculate the number of printed pages for the sheet using the GetPrintPageCount method.

    Using the Properties Window

    1. At design time, in the Properties window, select the Spread component.
    2. Select the Sheets property.
    3. Click the button to display the SheetView Collection Editor.
    4. In the Members list, select the sheet for which to set the print the page range.
    5. In the properties list, double-click the PrintInfo property to display the settings for the PrintInfo class.
    6. Set the PrintType property to PageRange.
    7. Set the PageStart and PageEnd properties to designate the page range to print.
    8. Click OK to close the editor.

    Using a Shortcut

    1. Create a PrintInfo object.
    2. Set the PrintInfo object PrintType property to PrintType.PageRange.

      If you just want to print the current page, set the PrintType property to PrintType.CurrentPage, and go on to step 4.

    3. Set the PrintInfo object PageStart and PageEnd properties to designate the page range to print.
    4. Set the Sheet shortcut object PrintInfo property to the PrintInfo object you just created.

    Example

    This example code prints pages 5 through 10.

    C#
    Copy Code
    // Create PrintInfo object and set properties.
    FarPoint.Win.Spread.PrintInfo printset = new FarPoint.Win.Spread.PrintInfo();
    printset.PrintType = FarPoint.Win.Spread.PrintType.PageRange;
    printset.PageStart = 5;
    printset.PageEnd = 10;
    // Set the PrintInfo property for the first sheet.
    fpSpread1.Sheets[0].PrintInfo = printset;
    // Print the sheet.
    fpSpread1.PrintSheet(0);
    
    VB
    Copy Code
    ' Create PrintInfo object and set properties.
    Dim printset As New FarPoint.Win.Spread.PrintInfo()
    printset.PrintType = FarPoint.Win.Spread.PrintType.PageRange
    printset.PageStart = 5
    printset.PageEnd = 10
    ' Set the PrintInfo property for the first sheet.
    fpSpread1.Sheets(0).PrintInfo = printset
    ' Print the sheet.
    fpSpread1.PrintSheet(0)
    

    Using Code

    1. Create a PrintInfo object.
    2. Set the PrintInfo object PrintType property to PrintType.PageRange.

      If you just want to print the current page, set the PrintType property to PrintType.CurrentPage, and go on to step 4.

    3. Set the PrintInfo object PageStart and PageEnd properties to designate the page range to print.
    4. Set the SheetView object PrintInfo property to the PrintInfo object you just created.

    Example

    This example code prints pages 5 through 10.

    C#
    Copy Code
    // Create PrintInfo object and set properties.
    FarPoint.Win.Spread.PrintInfo printset = new FarPoint.Win.Spread.PrintInfo();
    printset.PrintType = FarPoint.Win.Spread.PrintType.PageRange;
    printset.PageStart = 5;
    printset.PageEnd = 10;
    // Create SheetView object and assign it to the first sheet.
    FarPoint.Win.Spread.SheetView SheetToPrint = new FarPoint.Win.Spread.SheetView();
    SheetToPrint.PrintInfo = printset;
    fpSpread1.Sheets[0] = SheetToPrint;
    // Print the sheet.
    fpSpread1.PrintSheet(0);
    
    VB
    Copy Code
    ' Create PrintInfo object and set properties.
    Dim printset As New FarPoint.Win.Spread.PrintInfo()
    printset.PrintType = FarPoint.Win.Spread.PrintType.PageRange
    printset.PageStart = 5
    printset.PageEnd = 10
    ' Create SheetView object and assign it to the first sheet.
    Dim SheetToPrint As New FarPoint.Win.Spread.SheetView()
    SheetToPrint.PrintInfo = printset
    fpSpread1.Sheets(0) = SheetToPrint
    ' Set the PrintInfo property for the first sheet.
    fpSpread1.Sheets(0).PrintInfo = printset
    ' Print the sheet.
    fpSpread1.PrintSheet(0)
    

    Using the Spread Designer

    1. Select the sheet tab for the sheet you want to print.
    2. From the Property window, choose PrintInfo.
    3. Set Print Type to PageRange.
    4. Set PageEnd and PageStart.
    5. From the File menu choose Apply and Exit to apply your changes to the component and exit Spread Designer.
    See Also