Interface IVPageBreaks
A collection of vertical page breaks within the print area. Each vertical page break is represented by a VPageBreak object.
Namespace: Syncfusion.XlsIO
Assembly: Syncfusion.XlsIO.Portable.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.
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 |
---|
System.Int32 |
Examples
The following code illustrates the use of Count property.
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();
}
Item[Int32]
Returns a single IVPageBreak object from a collection. Read-only.
Declaration
IVPageBreak this[int Index] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | 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.
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 |
---|
System.Object |
Examples
The following code illustrates the use of Parent property.
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 | IRange 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.
//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.
//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(Int32)
Returns page break at the specified column.
Declaration
IVPageBreak GetPageBreak(int iColumn)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | 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.
//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 IRange.
Declaration
IVPageBreak Remove(IRange location)
Parameters
Type | Name | Description |
---|---|---|
IRange | location | IRange 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.
//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();