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
Return to the list for Specifying What to Print.
Using the Properties Window
- At design time, in the Properties window, select the Spread component.
- Select the Sheets property.
- Click the button to display the SheetView Collection Editor.
- In the Members list, select the sheet for which to set the print the cell range.
- In the properties list, double-click the PrintInfo property to display the settings for the PrintInfo class.
- Set the PrintType property to PageRange.
- Set the ColStart, RowStart, ColEnd, and RowEnd properties to designate the cell range to print.
- Click OK to close the editor.
Using a Shortcut
- Create a PrintInfo object.
- Set the PrintInfo object PrintType property to PrintType.CellRange.
- Set the PrintInfo object ColStart, RowStart, ColEnd, and RowEnd properties to designate the cell range to print.
- Set the Sheet shortcut 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; // 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
- Create a PrintInfo object.
- Set the PrintInfo object PrintType property to PrintType.CellRange.
- Set the PrintInfo object ColStart, RowStart, ColEnd, and RowEnd properties to designate the cell range to print.
- 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
- Select the sheet tab for the sheet you want to print.
- Select the Page Layout option.
- Select the PrintTitles icon, choose General.
The Sheet Print Options dialog appears.
- Click the Output tab.
- From the Output Type drop-down list box, choose Cell Range.
- Click OK to close the Sheet Print Options dialog.
- From the File menu choose Apply and Exit to apply your changes to the component and exit Spread Designer.
- To specify the range of cells,
- To print the range of cells, follow the instructions in Printing an Entire Sheet.