NativeExcel for .Net Developer's Reference

IPageBreaks.AddMethod

Adds a page break.

[Visual Basic]
FunctionAdd(_
ByValBeforeAsObject_
)AsIPageBreak
[C#]
IPageBreakAdd(
objectBefore
);
[C++]
IPageBreak*Add(
Object*Before
);
[JScript]
functionAdd(
ObjectBefore
):IPageBreak;

Parameters

Before
Object. The location for the pagebreak. Can be either an IRange interface or String which represents a range.

Example

This example adds a horizontal page break above cell G15 and adds a vertical page break to the left of this cell.

[C#]
book.Worksheets[1].HPageBreaks.Add("G15");
book.Worksheets[1].VPageBreaks.Add("G15");
[VisualBasic]
book.Worksheets(1).HPageBreaks.Add("G15")
book.Worksheets(1).VPageBreaks.Add("G15")
[C++]
book->Worksheets->Item[1]->HPageBreaks->Add(S"G15");
book->Worksheets->Item[1]->VPageBreaks->Add(S"G15");
This example is the same as the previous.
[C#]
IRange range = book.Worksheets[1].Range["G15"];   
book.Worksheets[1].HPageBreaks.Add(range);
book.Worksheets[1].VPageBreaks.Add(range);
[VisualBasic]
Dim range As IRange = book.Worksheets(1).Range("G15")   
book.Worksheets(1).HPageBreaks.Add(range)
book.Worksheets(1).VPageBreaks.Add(range)
[C++]
IRange* range = book->Worksheets->Item[1]->Range->Item[S"G15"];   
book->Worksheets->Item[1]->HPageBreaks->Add(range);
book->Worksheets->Item[1]->VPageBreaks->Add(range);

See Also

IPageBreaks Interface | NativeExcel Namespace | Location Property | IWorksheet.HPageBreaks | IWorksheet.VPageBreaks | IPageBreak Interface