# Adding a Page Break to a Worksheet

## Content



You can easily add page breaks in rows and columns for files in OpenXML (.xlsx) format using the [PageBreak](/componentone/api/wpf/online-excel/dotnet-framework-api/C1.WPF.Excel.4.6.2/C1.WPF.Excel.XLColumn.PageBreak.html) and [PageBreak](/componentone/api/wpf/online-excel/dotnet-framework-api/C1.WPF.Excel.4.6.2/C1.WPF.Excel.XLRow.PageBreak.html) properties.

1.  Add a reference to C1.WPF.Excel.dll or C1.Silverlight.Excel.dll and create a **C1XLBook**.
    
    ```csharp
    // Create a new workbook to be saved
     C1XLBook book = new C1XLBook();
    ```
    
2.  Add some text values and page breaks using the following code:
    
    ```csharp
    book.Sheets[0][2, 3].Value = "page1";
    book.Sheets[0].Rows[2].PageBreak = true;
    book.Sheets[0][0, 1].Value = "test1";
    book.Sheets[0][0, 2].Value = "test2";
    book.Sheets[0].Columns[1].PageBreak = true;
    book.Sheets[0][3, 3].Value = "page2";
    ```
    
3.  Save and open the .xlsx file.
    
    ```csharp
    // Save and open the file
    book.Save(@"C:\test.xlsx");
    System.Diagnostics.Process.Start(@"C:\test.xlsx");
    ```
    
4.  In Excel, select the **Page Layout** tab, and select the **Print** checkbox under **Gridlines**. The worksheet should look similar to the following:
    
    ![Page Break](https://cdn.mescius.io/document-site-files/images/4e8fb55a-cee4-4e5b-a6f1-f4ba4ccbfde1/c1excel_graphics/image11_9.png)