Live SpreadsheetGear API Samples
Page Setup and Printing Samples Manual Page Breaks
Manage manual page breaks from the IWorksheet.HPageBreaks and VPageBreaks collections.
// Create a new workbook and reference to "Sheet1".
SpreadsheetGear.IWorkbook workbook = SpreadsheetGear.Factory.GetWorkbook();
SpreadsheetGear.IWorksheet worksheet = workbook.Worksheets["Sheet1"];
SpreadsheetGear.IRange cells = worksheet.Cells;
// Populate sheet with some values.
cells["A1:H100"].Formula = "=ROW()";
// Add a manual horizontal page break before row 6.
worksheet.HPageBreaks.Add(cells["6:6"]);
// Add another manual horizontal page break before row 30.
worksheet.HPageBreaks.Add(cells["30:30"]);
// Add a manual vertical page break before column .
worksheet.VPageBreaks.Add(cells["C:C"]);
// Enable "Page Break Preview" mode (note: SpreadsheetGear only supports this
// option in the file format. The WorkbookView controls do not yet support
// rendering this mode).
worksheet.WindowInfo.View = SpreadsheetGear.WindowView.PageBreakPreview;
Run This Sample
Download File
Download an Excel Open XML Workbook (*.xlsx) file with the results of this sample.
Related Samples
Page Setup and Printing Samples