# Adding a Page Break

Learn how to add and manage page breaks in your spreadsheet for optimized printing.

## Content



Spread allows you to add a force page break before a specified column or row by using the [SetRowPageBreak](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.SheetView.SetRowPageBreak.html) and the [SetColumnPageBreak](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.SheetView.SetColumnPageBreak.html) methods. A column page break occurs to the left of the specified column and a row page break occurs above the specified row.

You can also retrieve the number of the next column or row in the sheet where a page break occurs. To find the page breaks that are already set, use the [GetRowPageBreak](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.SheetView.GetRowPageBreak.html) method to return the number of row page breaks and use the [GetColumnPageBreak](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.SheetView.GetColumnPageBreak.html) method to return the number of column page breaks.

Along with that, Spread allows you to manage the visibility of page breaks in worksheet while rendering. The [DisplayPageBreaks](/spreadnet/api/latest/online-win/GrapeCity.Spreadsheet/GrapeCity.Spreadsheet.IWorksheet.DisplayPageBreaks.html) property of the [IWorksheet](/spreadnet/api/latest/online-win/GrapeCity.Spreadsheet/GrapeCity.Spreadsheet.IWorksheet.html) interface indicates whether the page break will be displayed in the worksheet or not. The default value of this boolean type property is false. You must enable it to display the page breaks in the worksheet at runtime.

Moreover, the displayed page breaks in worksheet while printing in Spread is similar to the page breaks displayed by Excel while previewing a worksheet for printing.

The displaying of page break in worksheet only works when the **LegacyBehaviors.Style** is excluded from [LegacyBehaviors](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.LegacyBehaviors.html) enum.


> !type=note
>
> You can calculate the number of printed pages for the worksheet using the [GetPrintPageCount](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.FpSpread.GetPrintPageCount.html) method.

The below image displays the page breaks in worksheet.

![](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/showpagebreaks.png)

The following code is used to add and display page breaks in worksheet.

```csharp
FarPoint.Win.Spread.PrintInfo pi = new FarPoint.Win.Spread.PrintInfo();
pi.UseMax = false;
fpSpread1.Sheets[0].PrintInfo = pi;
fpSpread1.Sheets[0].SetRowPageBreak(2, true);
IWorksheet sheet = fpSpread1.AsWorkbook().ActiveSheet;
// Enable ExcelCompatiblePrinting
fpSpread1.Features.ExcelCompatiblePrinting = true;
// Enable DisplayPageBreaks
sheet.DisplayPageBreaks = true;
sheet.PageSetup.Zoom = 100;
// Get row page breaks
private void Getrowpagebreak_Click(object sender, EventArgs e)
{
  listbox1.Items.Clear(); // Clear listBox1 before adding new items
  int[] i;
  i = fpSpread1.GetRowPageBreaks(0);
  foreach (object o in i)
           {
               listbox1.Items.Add(o); 
           }
}
```

```vbnet
Dim pi As FarPoint.Win.Spread.PrintInfo = New FarPoint.Win.Spread.PrintInfo()
pi.UseMax = False
FpSpread1.Sheets(0).PrintInfo = pi
FpSpread1.Sheets(0).SetRowPageBreak(2, True) 
Dim sheet As IWorksheet = FpSpread1.AsWorkbook().ActiveSheet 
' Enable ExcelCompatiblePrinting
FpSpread1.Features.ExcelCompatiblePrinting = True
' Enable DisplayPageBreaks
sheet.DisplayPageBreaks = True
sheet.PageSetup.Zoom = 100
' Get row page breaks
Private Sub GetRowPageBreak_Click(sender As Object, e As EventArgs)
  listbox1.Items.Clear()
  Dim i As Integer() = FpSpread1.GetRowPageBreaks(0)
  For Each o As Integer In i
         listbox1.Items.Add(o)
  Next
End Sub
```

## See Also

[Understanding the Printing Options](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-printing/spwin-printcustomize/spwin-printoptions)

[Customizing the Print Job Settings](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-printing/spwin-printcustomize/spwin-printsettings)

[Customizing the Printed Page Layout](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-printing/spwin-printcustomize/spwin-printlayout)

[Customizing the Printed Page Header or Footer](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-printing/spwin-printcustomize/spwin-printheadfoot)

[Customizing the Print Preview Dialog](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-printing/spwin-printcustomize/CustomizingthePrintPreviewDialog)

[Repeating Rows or Columns on Printed Pages](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-printing/spwin-printcustomize/spwin-printrepeatrange)

[Adding a Watermark to a Printed Page](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-printing/spwin-printcustomize/spwin-printwatermark)