Render spreadsheets by page breaks

When printing spreadsheets with a lot of data sheets are automatically broken into pages to fit the paper size and keep printed content readable. To preview the page breaks in Excel navigate to View and click Page Break Preview as it shown on the screenshot.

Page break preview in Excel

In case you print the workbook by clicking at File > Print and there would be two pages in the print preview.

Printing spreadsheet in Excel

To perform the same action programmatically with GroupDocs.Viewer set SpreadsheetOptions to SpreadsheetOptions.ForRenderingByPageBreaks() and call View method. Let’s take page-breaks.xlsx and render it to PDF by running the following code.

using (Viewer viewer = new Viewer("page-breaks.xlsx"))
    PdfViewOptions viewOptions = new PdfViewOptions();
    viewOptions.SpreadsheetOptions = SpreadsheetOptions.ForRenderingByPageBreaks();

    // Enable rendering gird lines and headings to check that proper areas are rendered
    viewOptions.SpreadsheetOptions.RenderGridLines = true;
    viewOptions.SpreadsheetOptions.RenderHeadings = true;


We’ll got one PDF file with two pages that are corresponds to pages highlighted by Excel on the first screenshot.

PDF rendered by page breaks

The same applies when rendering to HTML, JPEG, and PNG formats.

More resources

View Excel Files Online

Along with full-featured .NET library we provide simple but powerful free online Apps. View Excel XLS, XLSX, and XLSB files online with GroupDocs Viewer App.

GitHub Examples

You may easily run the code above and see the feature in action in our GitHub examples: