Interface IVPageBreaks
A collection of vertical page breaks within the print area. Each vertical page break is represented by a VPageBreak object.
Inherited Members
Namespace: Syncfusion.XlsIO
Assembly: Syncfusion.XlsIO.NET.dll
Syntax
public interface IVPageBreaks : IEnumerable
Properties
Application
Used without an object qualifier, this property returns an IApplication object that represents the Excel IApplication.
Declaration
IApplication Application { get; }
Property Value
| Type |
|---|
| IApplication |
Examples
The following code illustrates how to access the IApplication property.
<pre><code class="lang-csharp">using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create a worksheet.
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
IWorksheet sheet = workbook.Worksheets[0];
//Property returns an Application object that represents the Excel application IApplication vPageBreakApplication = sheet.VPageBreaks.Application;
workbook.SaveAs("PageSetup.xlsx"); workbook.Close(); }
Count
Returns the number of objects in the collection. Read-only.
Declaration
int Count { get; }
Property Value
| Type |
|---|
| int |
Examples
The following code illustrates the use of Count property.
<pre><code class="lang-csharp">using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create a worksheet.
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
IWorksheet sheet = workbook.Worksheets[0];
//Number of objects in the collection int vPageBreakCount = sheet.VPageBreaks.Count;
workbook.SaveAs("PageSetup.xlsx"); workbook.Close(); }
this[int]
Returns a single IVPageBreak object from a collection. Read-only.
Declaration
IVPageBreak this[int Index] { get; }
Parameters
| Type | Name | Description |
|---|---|---|
| int | Index |
Property Value
| Type |
|---|
| IVPageBreak |
Remarks
To know more about page setting refer this link.
Examples
The following code illustrates how to get an IVPageBreak object from a collection.
<pre><code class="lang-csharp">using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create a worksheet.
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add PageBreaks sheet.Range["A1:S65"].Text = "PagePrint"; sheet.VPageBreaks.Add(sheet.Range["A3"]); sheet.VPageBreaks.Add(sheet.Range["G10"]); sheet.VPageBreaks.Add(sheet.Range["F24"]); sheet.VPageBreaks.Add(sheet.Range["C37"]);
//Get the Vertical page break location using index IRange vPageBreakLocation1 = sheet.VPageBreaks[0].Location; IRange vPageBreakLocation2 = sheet.VPageBreaks[1].Location; IRange vPageBreakLocation3 = sheet.VPageBreaks[2].Location; IRange vPageBreakLocation4 = sheet.VPageBreaks[3].Location;
workbook.SaveAs("PageSetup.xlsx"); workbook.Close(); }
Parent
Returns the parent object for the specified object.
Declaration
object Parent { get; }
Property Value
| Type |
|---|
| object |
Examples
The following code illustrates the use of Parent property.
<pre><code class="lang-csharp">using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create a worksheet.
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
IWorksheet sheet = workbook.Worksheets[0];
//Parent object for the specified object object vPageBreakParent = sheet.VPageBreaks.Parent;
workbook.SaveAs("PageSetup.xlsx"); workbook.Close(); }
Methods
Add(IRange)
Adds a vertical page break. Returns a IVPageBreak object.
Declaration
IVPageBreak Add(IRange location)
Parameters
| Type | Name | Description |
|---|---|---|
| IRange | location | Location of the break. |
Returns
| Type | Description |
|---|---|
| IVPageBreak | Newly added page break. |
Remarks
To know more about page setting refer this link.
Examples
The following code illustrates how to add a vertical page break.
<pre><code class="lang-csharp">//Create a worksheet.
ExcelEngine excelEngine = new ExcelEngine(); IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Excel2013; IWorkbook workbook = application.Workbooks.Create(1); IWorksheet sheet = workbook.Worksheets[0]; sheet.Range["A1:T100"].Text = "PagePrint";
//Set Vertical Page Breaks. sheet.VPageBreaks.Add(sheet.Range["A5"]); sheet.VPageBreaks.Add(sheet.Range["C18"]); sheet.VPageBreaks.Add(sheet.Range["H32"]);
workbook.SaveAs("PageSetup.xlsx"); workbook.Close();
Clear()
Clears vertical page breaks from VPageBreaks collection.
Declaration
void Clear()
Remarks
To know more about page setting refer this link.
Examples
The following code illustrates how to clear a vertical page break.
<pre><code class="lang-csharp">//Create a worksheet.
ExcelEngine excelEngine = new ExcelEngine(); IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Excel2013; IWorkbook workbook = application.Workbooks.Open("Sample.xlsx"); IWorksheet sheet = workbook.Worksheets[0];
//clear Vertical Page Breaks sheet.VPageBreaks.Clear();
workbook.SaveAs("PageSetup.xlsx"); workbook.Close();
GetPageBreak(int)
Returns page break at the specified column.
Declaration
IVPageBreak GetPageBreak(int iColumn)
Parameters
| Type | Name | Description |
|---|---|---|
| int | iColumn | One-based column index. |
Returns
| Type | Description |
|---|---|
| IVPageBreak | Page break with corresponding column or null if not found. |
Remarks
To know more about page setting refer this link.
Examples
The following code illustrates how to get page break with corresponding column.
<pre><code class="lang-csharp">//Create a worksheet.
ExcelEngine excelEngine = new ExcelEngine(); IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Excel2013; IWorkbook workbook = application.Workbooks.Open("Sample.xlsx"); IWorksheet sheet = workbook.Worksheets[0];
//Get Page break with corresponding column IVPageBreak vPageBrk = sheet.VPageBreaks.GetPageBreak(6); if(vPageBrk != null) { //Your code here }
workbook.SaveAs("PageSetup.xlsx"); workbook.Close();
Remove(IRange)
Removes a page break from the specified location.
Declaration
IVPageBreak Remove(IRange location)
Parameters
| Type | Name | Description |
|---|---|---|
| IRange | location | Range to remove the page break. |
Returns
| Type | Description |
|---|---|
| IVPageBreak | Page break in the range. |
Remarks
To know more about page setting refer this link.
Examples
The following code illustrates how to Remove a vertical page break.
<pre><code class="lang-csharp">//Create a worksheet.
ExcelEngine excelEngine = new ExcelEngine(); IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Excel2013; IWorkbook workbook = application.Workbooks.Open("Sample.xlsx"); IWorksheet sheet = workbook.Worksheets[0];
//Remove Vertical Page Breaks. sheet.VPageBreaks.Remove(sheet.Range["A5"]); sheet.VPageBreaks.Remove(sheet.Range["A18"]); sheet.VPageBreaks.Remove(sheet.Range["A32"]);
workbook.SaveAs("PageSetup.xlsx"); workbook.Close();