Spread Windows Forms 17
Spread Windows Forms 17.0 Product Documentation / Developer's Guide / Printing / Specifying What to Print / Printing a Range of Cells on a Sheet
In This Topic
    Printing a Range of Cells on a Sheet
    In This Topic

    You may not want to print the entire sheet but only a specified range of cells on a sheet. You can specify that only a range of cells within a sheet prints, rather than the entire sheet. After specifying the range of cells with the PrintInfo object, use the PrintSheet method as described in Printing an Entire Sheet.

    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 cell 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 ColStart, RowStart, ColEnd, and RowEnd properties to designate the cell range to print.
    8. Click OK to close the editor.

    Using a Shortcut

    Example

    This example code prints cells B2 through D4.

    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.CellRange;
    printset.ColStart = 1;
    printset.ColEnd = 3;
    printset.RowStart = 1;
    printset.RowEnd = 3;
    // 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.CellRange
    printset.ColStart = 1
    printset.ColEnd = 3
    printset.RowStart = 1
    printset.RowEnd = 3
    ' 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.CellRange.
    3. Set the PrintInfo object ColStart, RowStart, ColEnd, and RowEnd properties to designate the cell range to print.
    4. Set the SheetView object PrintInfo property to the PrintInfo object you just created.

    Example

    This example code prints cells B2 through D4.

    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.CellRange;
    printset.ColStart = 1;
    printset.ColEnd = 3;
    printset.RowStart = 1;
    printset.RowEnd = 3;
    // 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.CellRange
    printset.ColStart = 1
    printset.ColEnd = 3
    printset.RowStart = 1
    printset.RowEnd = 3
    ' 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. Select the Page Layout option.
    3. Select the PrintTitles icon, choose General.

      The Sheet Print Options dialog appears.

    4. Click the Output tab.
    5. From the Output Type drop-down list box, choose Cell Range.
    6. Click OK to close the Sheet Print Options dialog.
    7. From the File menu choose Apply and Exit to apply your changes to the component and exit Spread Designer.
    8. To specify the range of cells,
    9. To print the range of cells, follow the instructions in Printing an Entire Sheet.
    See Also