Interface IPageSetupBase
Base interface for all page setups.
Namespace: Syncfusion.XlsIO.Interfaces
Assembly: Syncfusion.XlsIO.Base.dll
Syntax
public interface IPageSetupBase : IParentApplication
Properties
AlignHFWithPageMargins
Gets / sets the header and footer margins are aligned with page margins.
Declaration
bool AlignHFWithPageMargins { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
To know more about page settings refer this link.
Examples
The following code illustrates the use of AlignHFWithPageMargins property.
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];
sheet.Range["A1:T100"].Text = "PagePrint";
sheet.Range["A1:D20"].CellStyle.FillBackground = ExcelKnownColors.Aqua;
sheet.Range["F1:R40"].CellStyle.FillBackground = ExcelKnownColors.Light_orange;
sheet.Range["A54:T80"].CellStyle.FillBackground = ExcelKnownColors.Light_blue;
sheet.Range["E1:T30"].CellStyle.Font.Color = ExcelKnownColors.Brown;
sheet.Range["A1:C50"].CellStyle.Font.Color = ExcelKnownColors.Green;
sheet.Range["A54:T90"].CellStyle.Font.Color = ExcelKnownColors.Red;
//True to sets the header and footer margins are aligned with page margins
sheet.PageSetup.AlignHFWithPageMargins = true;
sheet.PageSetup.LeftMargin = 1.25;
sheet.PageSetup.RightMargin = 1.25;
sheet.PageSetup.CenterFooter = "Center Footer";
sheet.PageSetup.CenterHeader = "Center Header";
sheet.PageSetup.LeftFooter = "&D";
sheet.PageSetup.LeftHeader = "&D";
sheet.PageSetup.RightFooter = "&T";
sheet.PageSetup.RightHeader = "&T";
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
AutoFirstPageNumber
Indicates whether FirstPageNumber is set to Auto or not.
Declaration
bool AutoFirstPageNumber { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
To know more about page settings refer this link.
Examples
The following code illustrates the use of AutoFirstPageNumber property.
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];
sheet.Range["A1:T100"].Text = "PagePrint";
sheet.Range["A1:D20"].CellStyle.FillBackground = ExcelKnownColors.Aqua;
sheet.Range["F1:R40"].CellStyle.FillBackground = ExcelKnownColors.Light_orange;
sheet.Range["A54:T80"].CellStyle.FillBackground = ExcelKnownColors.Light_blue;
sheet.Range["E1:T30"].CellStyle.Font.Color = ExcelKnownColors.Brown;
sheet.Range["A1:C50"].CellStyle.Font.Color = ExcelKnownColors.Green;
sheet.Range["A54:T90"].CellStyle.Font.Color = ExcelKnownColors.Red;
//True to set FirstPageNumber as Auto
sheet.PageSetup.AutoFirstPageNumber = true;
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
BackgoundImage
Gets / sets background image.
Declaration
Bitmap BackgoundImage { get; set; }
Property Value
Type | Description |
---|---|
System.Drawing.Bitmap |
Remarks
Except UWP, Xamarin and ASP.NET Core platforms the BackgoundImage property must be System.Drawing.Bitmap. For UWP, Xamarin and ASP.NET Core platforms the BackgoundImage property is System.Drawing.Image. To know more about page settings refer this link.
Examples
The following code illustrates the use of BackgoundImage property.
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];
sheet.Range["A1:J94"].Text = "PagePrint";
//sets background image
sheet.PageSetup.BackgoundImage = (System.Drawing.Bitmap)System.Drawing.Image.FromFile("D:/WorkSpace/WF-40376-APIs_in_page_settings/Output_Files/nature2.jpg");
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
BlackAndWhite
True if elements of the document will be printed in black and white. Read / write Boolean.
Declaration
bool BlackAndWhite { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
To know more about page settings refer this link.
Examples
The following code illustrates the use of BlackAndWhite property.
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];
sheet.Range["A1:T100"].Text = "PagePrint";
sheet.Range["A1:D20"].CellStyle.FillBackground = ExcelKnownColors.Aqua;
sheet.Range["F1:R40"].CellStyle.FillBackground = ExcelKnownColors.Light_orange;
sheet.Range["A54:T80"].CellStyle.FillBackground = ExcelKnownColors.Light_blue;
sheet.Range["E1:T30"].CellStyle.Font.Color = ExcelKnownColors.Brown;
sheet.Range["A1:C50"].CellStyle.Font.Color = ExcelKnownColors.Green;
sheet.Range["A54:T90"].CellStyle.Font.Color = ExcelKnownColors.Red;
//True to document will be printed in black and white.
sheet.PageSetup.BlackAndWhite = true;
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
BottomMargin
Gets or sets the size of the bottom margin, in inches. Default value of bottom margin is 0.75. Read / write Double.
Declaration
double BottomMargin { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
Remarks
To know more about page settings property refer this link.
Examples
The following code illustrates the use of BottomMargin property.
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];
sheet.Range["A1:T100"].Text = "PagePrint";
//sets the size of the bottom margin
sheet.PageSetup.BottomMargin = 0.75;
sheet.PageSetup.FooterMargin = 0.4;
sheet.PageSetup.HeaderMargin = 0.4;
sheet.PageSetup.LeftMargin = 0.75;
sheet.PageSetup.RightMargin = 0.75;
sheet.PageSetup.TopMargin = 0.75;
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
CenterFooter
Gets or sets the center part of the footer. Read / write String.
Declaration
string CenterFooter { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
&L Left aligns the characters that follow. &C Centers the characters that follow. &R Right aligns the characters that follow. &E Turns double-underline printing on or off. &X Turns superscript printing on or off. &Y Turns subscript printing on or off. &B Turns bold printing on or off. &I Turns italic printing on or off. &U Turns underline printing on or off. &S Turns strikethrough printing on or off. &D Prints the current date. &T Prints the current time. &F Prints the name of the document. &A Prints the name of the workbook tab. &P Prints the page number. &P+number Prints the page number plus the specified number. &P-number Prints the page number minus the specified number. && Prints a single ampersand. & "fontname" Prints the characters that follow in the specified font. Be sure to include the double quotation marks. &nn Prints the characters that follow in the specified font size. Use a two-digit number to specify a size in points. &N Prints the total number of pages in the document. To know more about page setting refer this link.
Examples
The following code illustrates the use of CenterFooter property.
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];
sheet.Range["A1:T100"].Text = "PagePrint";
//Sets the center part of the footer
sheet.PageSetup.CenterFooter = "Center Footer &G";
sheet.PageSetup.CenterFooterImage = System.Drawing.Image.FromFile("sample1.jpg");
sheet.PageSetup.CenterHeader = "Center Header &G";
sheet.PageSetup.CenterHeaderImage = System.Drawing.Image.FromFile("sample2.jpg");
sheet.PageSetup.LeftFooter = "Left Footer &G";
sheet.PageSetup.LeftFooterImage = System.Drawing.Image.FromFile("sample3.jpg");
sheet.PageSetup.LeftHeader = "Left Header &G";
sheet.PageSetup.LeftHeaderImage = System.Drawing.Image.FromFile("sample4.jpg");
sheet.PageSetup.RightFooter = "Right Footer &G";
sheet.PageSetup.RightFooterImage = System.Drawing.Image.FromFile("sample5.jpg");
sheet.PageSetup.RightHeader = "Right Header &G";
sheet.PageSetup.RightHeaderImage = System.Drawing.Image.FromFile("sample6.jpg");
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
CenterFooterImage
Gets / sets image for center part of the footer.
Declaration
Image CenterFooterImage { get; set; }
Property Value
Type | Description |
---|---|
System.Drawing.Image |
Remarks
&L Left aligns the characters that follow. &C Centers the characters that follow. &R Right aligns the characters that follow. &E Turns double-underline printing on or off. &X Turns superscript printing on or off. &Y Turns subscript printing on or off. &B Turns bold printing on or off. &I Turns italic printing on or off. &U Turns underline printing on or off. &S Turns strikethrough printing on or off. &D Prints the current date. &T Prints the current time. &F Prints the name of the document. &A Prints the name of the workbook tab. &P Prints the page number. &P+number Prints the page number plus the specified number. &P-number Prints the page number minus the specified number. && Prints a single ampersand. & "fontname" Prints the characters that follow in the specified font. Be sure to include the double quotation marks. &nn Prints the characters that follow in the specified font size. Use a two-digit number to specify a size in points. &N Prints the total number of pages in the document. To know more about page settings refer this link.
Examples
The following code illustrates the use of CenterFooterImage property.
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];
sheet.Range["A1:T100"].Text = "PagePrint";
//Set image for center part of the footer
sheet.PageSetup.CenterFooterImage = System.Drawing.Image.FromFile("sample1.jpg");
sheet.PageSetup.CenterFooter = "Center Footer &G";
sheet.PageSetup.CenterHeader = "Center Header &G";
sheet.PageSetup.CenterHeaderImage = System.Drawing.Image.FromFile("sample2.jpg");
sheet.PageSetup.LeftFooter = "Left Footer &G";
sheet.PageSetup.LeftFooterImage = System.Drawing.Image.FromFile("sample3.jpg");
sheet.PageSetup.LeftHeader = "Left Header &G";
sheet.PageSetup.LeftHeaderImage = System.Drawing.Image.FromFile("sample4.jpg");
sheet.PageSetup.RightFooter = "Right Footer &G";
sheet.PageSetup.RightFooterImage = System.Drawing.Image.FromFile("sample5.jpg");
sheet.PageSetup.RightHeader = "Right Header &G";
sheet.PageSetup.RightHeaderImage = System.Drawing.Image.FromFile("sample6.jpg");
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
CenterHeader
Gets or sets the center part of the header. Read / write String.
Declaration
string CenterHeader { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
&L Left aligns the characters that follow. &C Centers the characters that follow. &R Right aligns the characters that follow. &E Turns double-underline printing on or off. &X Turns superscript printing on or off. &Y Turns subscript printing on or off. &B Turns bold printing on or off. &I Turns italic printing on or off. &U Turns underline printing on or off. &S Turns strikethrough printing on or off. &D Prints the current date. &T Prints the current time. &F Prints the name of the document. &A Prints the name of the workbook tab. &P Prints the page number. &P+number Prints the page number plus the specified number. &P-number Prints the page number minus the specified number. && Prints a single ampersand. & "fontname" Prints the characters that follow in the specified font. Be sure to include the double quotation marks. &nn Prints the characters that follow in the specified font size. Use a two-digit number to specify a size in points. &N Prints the total number of pages in the document. To know more about page settings refer this link.
Examples
The following code illustrates the use of CenterHeader property.
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];
sheet.Range["A1:T100"].Text = "PagePrint";
//Sets the center part of the header
sheet.PageSetup.CenterHeader = "Center Header &G";
sheet.PageSetup.CenterHeaderImage = System.Drawing.Image.FromFile("sample2.jpg");
sheet.PageSetup.CenterFooter = "Center Footer &G";
sheet.PageSetup.CenterFooterImage = System.Drawing.Image.FromFile("sample1.jpg");
sheet.PageSetup.LeftFooter = "Left Footer &G";
sheet.PageSetup.LeftFooterImage = System.Drawing.Image.FromFile("sample3.jpg");
sheet.PageSetup.LeftHeader = "Left Header &G";
sheet.PageSetup.LeftHeaderImage = System.Drawing.Image.FromFile("sample4.jpg");
sheet.PageSetup.RightFooter = "Right Footer &G";
sheet.PageSetup.RightFooterImage = System.Drawing.Image.FromFile("sample5.jpg");
sheet.PageSetup.RightHeader = "Right Header &G";
sheet.PageSetup.RightHeaderImage = System.Drawing.Image.FromFile("sample6.jpg");
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
CenterHeaderImage
Gets / set image for center part of the header.
Declaration
Image CenterHeaderImage { get; set; }
Property Value
Type | Description |
---|---|
System.Drawing.Image |
Remarks
&L Left aligns the characters that follow. &C Centers the characters that follow. &R Right aligns the characters that follow. &E Turns double-underline printing on or off. &X Turns superscript printing on or off. &Y Turns subscript printing on or off. &B Turns bold printing on or off. &I Turns italic printing on or off. &U Turns underline printing on or off. &S Turns strikethrough printing on or off. &D Prints the current date. &T Prints the current time. &F Prints the name of the document. &A Prints the name of the workbook tab. &P Prints the page number. &P+number Prints the page number plus the specified number. &P-number Prints the page number minus the specified number. && Prints a single ampersand. & "fontname" Prints the characters that follow in the specified font. Be sure to include the double quotation marks. &nn Prints the characters that follow in the specified font size. Use a two-digit number to specify a size in points. &N Prints the total number of pages in the document. To know more about page settings refer this link.
Examples
The following code illustrates the use of CenterHeaderImage property.
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];
sheet.Range["A1:T100"].Text = "PagePrint";
//Set image for center part of the header
sheet.PageSetup.CenterHeaderImage = System.Drawing.Image.FromFile("sample2.jpg");
sheet.PageSetup.CenterHeader = "Center Header &G";
sheet.PageSetup.CenterFooter = "Center Footer &G";
sheet.PageSetup.CenterFooterImage = System.Drawing.Image.FromFile("sample1.jpg");
sheet.PageSetup.LeftFooter = "Left Footer &G";
sheet.PageSetup.LeftFooterImage = System.Drawing.Image.FromFile("sample3.jpg");
sheet.PageSetup.LeftHeader = "Left Header &G";
sheet.PageSetup.LeftHeaderImage = System.Drawing.Image.FromFile("sample4.jpg");
sheet.PageSetup.RightFooter = "Right Footer &G";
sheet.PageSetup.RightFooterImage = System.Drawing.Image.FromFile("sample5.jpg");
sheet.PageSetup.RightHeader = "Right Header &G";
sheet.PageSetup.RightHeaderImage = System.Drawing.Image.FromFile("sample6.jpg");
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
CenterHorizontally
True if the sheet is centered horizontally on the page when it is printed. Read / write Boolean.
Declaration
bool CenterHorizontally { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
To know more about page settings refer this link.
Examples
The following code illustrates the use of CenterHorizontally property.
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];
sheet.Range["A1:T100"].Text = "PagePrint";
sheet.Range["A1:D20"].CellStyle.FillBackground = ExcelKnownColors.Aqua;
sheet.Range["F1:R40"].CellStyle.FillBackground = ExcelKnownColors.Light_orange;
sheet.Range["A54:T80"].CellStyle.FillBackground = ExcelKnownColors.Light_blue;
sheet.Range["E1:T30"].CellStyle.Font.Color = ExcelKnownColors.Brown;
sheet.Range["A1:C50"].CellStyle.Font.Color = ExcelKnownColors.Green;
sheet.Range["A54:T90"].CellStyle.Font.Color = ExcelKnownColors.Red;
//True to print the sheet is centered horizontally
sheet.PageSetup.CenterHorizontally = true;
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
CenterVertically
True if the sheet is centered vertically on the page when it is printed. Read / write Boolean.
Declaration
bool CenterVertically { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
To know more about page settings refer this link.
Examples
The following code illustrates the use of CenterVertically property.
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];
sheet.Range["A1:T100"].Text = "PagePrint";
sheet.Range["A1:D20"].CellStyle.FillBackground = ExcelKnownColors.Aqua;
sheet.Range["F1:R40"].CellStyle.FillBackground = ExcelKnownColors.Light_orange;
sheet.Range["A54:T80"].CellStyle.FillBackground = ExcelKnownColors.Light_blue;
sheet.Range["E1:T30"].CellStyle.Font.Color = ExcelKnownColors.Brown;
sheet.Range["A1:C50"].CellStyle.Font.Color = ExcelKnownColors.Green;
sheet.Range["A54:T90"].CellStyle.Font.Color = ExcelKnownColors.Red;
//True to print the sheet is centered vertically
sheet.PageSetup.CenterVertically = true;
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
Copies
Number of copies to print.
Declaration
int Copies { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Remarks
To know more about page settings refer this link.
Examples
The following code illustrates the use of Copies property.
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];
sheet.Range["A1:T100"].Text = "PagePrint";
sheet.Range["A1:D20"].CellStyle.FillBackground = ExcelKnownColors.Aqua;
sheet.Range["F1:R40"].CellStyle.FillBackground = ExcelKnownColors.Light_orange;
sheet.Range["A54:T80"].CellStyle.FillBackground = ExcelKnownColors.Light_blue;
sheet.Range["E1:T30"].CellStyle.Font.Color = ExcelKnownColors.Brown;
sheet.Range["A1:C50"].CellStyle.Font.Color = ExcelKnownColors.Green;
sheet.Range["A54:T90"].CellStyle.Font.Color = ExcelKnownColors.Red;
//Number of Copies to be printed
sheet.PageSetup.Copies = 3;
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
DifferentFirstPageHF
Gets / sets the header and footer of the FirstPage is different with other pages.
Declaration
bool DifferentFirstPageHF { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
To know more about page settings refer this link.
Examples
The following code illustrates the use of DifferentFirstPageHF property.
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];
sheet.Range["A1:T100"].Text = "PagePrint";
sheet.Range["A1:D20"].CellStyle.FillBackground = ExcelKnownColors.Aqua;
sheet.Range["F1:R40"].CellStyle.FillBackground = ExcelKnownColors.Light_orange;
sheet.Range["A54:T80"].CellStyle.FillBackground = ExcelKnownColors.Light_blue;
sheet.Range["E1:T30"].CellStyle.Font.Color = ExcelKnownColors.Brown;
sheet.Range["A1:C50"].CellStyle.Font.Color = ExcelKnownColors.Green;
sheet.Range["A54:T90"].CellStyle.Font.Color = ExcelKnownColors.Red;
//True to sets the header and footer of the first page is different with other pages
sheet.PageSetup.DifferentFirstPageHF = true;
sheet.PageSetup.CenterFooter = "Center Footer";
sheet.PageSetup.CenterHeader = "Center Header";
sheet.PageSetup.FirstPage.LeftFooter = "&T";
sheet.PageSetup.FirstPage.LeftHeader = "&D";
sheet.PageSetup.FirstPage.RightFooter = "&P";
sheet.PageSetup.FirstPage.RightHeader = "&D";
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
DifferentOddAndEvenPagesHF
Gets / sets the header and footer odd pages are differed with even page.
Declaration
bool DifferentOddAndEvenPagesHF { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
To know more about page settings refer this link.
Examples
The following code illustrates the use of DifferentOddAndEvenPagesHF property.
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];
sheet.Range["A1:T100"].Text = "PagePrint";
sheet.Range["A1:D20"].CellStyle.FillBackground = ExcelKnownColors.Aqua;
sheet.Range["F1:R40"].CellStyle.FillBackground = ExcelKnownColors.Light_orange;
sheet.Range["A54:T80"].CellStyle.FillBackground = ExcelKnownColors.Light_blue;
sheet.Range["E1:T30"].CellStyle.Font.Color = ExcelKnownColors.Brown;
sheet.Range["A1:C50"].CellStyle.Font.Color = ExcelKnownColors.Green;
sheet.Range["A54:T90"].CellStyle.Font.Color = ExcelKnownColors.Red;
//True to sets the header and footer odd pages are differed with even page
sheet.PageSetup.DifferentOddAndEvenPagesHF = true;
sheet.PageSetup.CenterFooter = "Center Footer";
sheet.PageSetup.CenterHeader = "Center Header";
sheet.PageSetup.EvenPage.LeftFooter = "&T";
sheet.PageSetup.EvenPage.LeftHeader = "&D";
sheet.PageSetup.EvenPage.RightFooter = "&P";
sheet.PageSetup.EvenPage.RightHeader = "&D";
sheet.PageSetup.HFScaleWithDoc = false;
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
Draft
True if the sheet will be printed without graphics. Read / write Boolean.
Declaration
bool Draft { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
To know more about page settings refer this link.
Examples
The following code illustrates the use of Draft property.
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];
sheet.Range["A1:T100"].Text = "PagePrint";
sheet.Range["A1:D20"].CellStyle.FillBackground = ExcelKnownColors.Aqua;
sheet.Range["F1:R40"].CellStyle.FillBackground = ExcelKnownColors.Light_orange;
sheet.Range["A54:T80"].CellStyle.FillBackground = ExcelKnownColors.Light_blue;
sheet.Range["E1:T30"].CellStyle.Font.Color = ExcelKnownColors.Brown;
sheet.Range["A1:C50"].CellStyle.Font.Color = ExcelKnownColors.Green;
sheet.Range["A54:T90"].CellStyle.Font.Color = ExcelKnownColors.Red;
//True to sheet will be printed without graphics
sheet.PageSetup.Draft = true;
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
EvenPage
Gets values for even page. The EvenPage have a values from the properties of IPage. If the input workbook have a even page, we can get the header and footer values from the Evenpage Property. Otherwise the EvenPage property values are null or empty.
Declaration
IPage EvenPage { get; }
Property Value
Type | Description |
---|---|
IPage |
Remarks
To know more about page settings refer this link.
Examples
The following code illustrates the use of EvenPage 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];
//Set value of EvenPage header and footer
sheet.PageSetup.DifferentOddAndEvenPagesHF = true;
sheet.PageSetup.EvenPage.CenterFooter = "Center Footer";
sheet.PageSetup.EvenPage.CenterHeader = "Center Header";
sheet.PageSetup.EvenPage.LeftFooter = "&T";
sheet.PageSetup.EvenPage.LeftHeader = "&D";
sheet.PageSetup.EvenPage.RightFooter = "&P";
sheet.PageSetup.EvenPage.RightHeader = "&D";
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
FirstPage
Gets values for first page. The FirstPage have a values from the properties of IPage. If the input workbook have a first page, we can get the header and footer values from the FirstProperty. Otherwise the FirstPage property values are null or empty.
Declaration
IPage FirstPage { get; }
Property Value
Type | Description |
---|---|
IPage |
Remarks
To know more about page settings refer this link.
Examples
The following code illustrates the use of FirstPage 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];
//Set the vales of FirstPage header and footer
sheet.PageSetup.DifferentFirstPageHF = true;
sheet.PageSetup.FirstPage.CenterFooter = "Center Footer";
sheet.PageSetup.FirstPage.CenterHeader = "Center Header";
sheet.PageSetup.FirstPage.LeftFooter = "&T";
sheet.PageSetup.FirstPage.LeftHeader = "&D";
sheet.PageSetup.FirstPage.RightFooter = "&P";
sheet.PageSetup.FirstPage.RightHeader = "&D";
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
FirstPageNumber
Gets or sets the first page number that will be used when this sheet is printed. If xlAutomatic, Microsoft Excel chooses the first page number. The default is xlAutomatic. Read / write Long.
Declaration
short FirstPageNumber { get; set; }
Property Value
Type | Description |
---|---|
System.Int16 |
Remarks
To know more about page settings refer this link.
Examples
The following code illustrates the use of FirstPageNumber property.
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];
sheet.Range["A1:T100"].Text = "PagePrint";
sheet.Range["A1:D20"].CellStyle.FillBackground = ExcelKnownColors.Aqua;
sheet.Range["F1:R40"].CellStyle.FillBackground = ExcelKnownColors.Light_orange;
sheet.Range["A54:T80"].CellStyle.FillBackground = ExcelKnownColors.Light_blue;
sheet.Range["E1:T30"].CellStyle.Font.Color = ExcelKnownColors.Brown;
sheet.Range["A1:C50"].CellStyle.Font.Color = ExcelKnownColors.Green;
sheet.Range["A54:T90"].CellStyle.Font.Color = ExcelKnownColors.Red;
//Set the first page number to be printed
sheet.PageSetup.FirstPageNumber = 1;
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
FooterMargin
Gets or sets the distance from the bottom of the page to the footer, in inches. Read / write Double. Default value of FooterMargin is 0.3.
Declaration
double FooterMargin { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
Remarks
To know more about page settings refer this link.
Examples
The following code illustrates the use of FooterMargin property.
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];
sheet.Range["A1:T100"].Text = "PagePrint";
//Sets the distance from the bottom of the page to the footer
sheet.PageSetup.FooterMargin = 0.4;
sheet.PageSetup.BottomMargin = 0.75;
sheet.PageSetup.HeaderMargin = 0.4;
sheet.PageSetup.LeftMargin = 0.75;
sheet.PageSetup.RightMargin = 0.75;
sheet.PageSetup.TopMargin = 0.75;
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
HeaderMargin
Gets or sets the distance from the top of the page to the header, in inches. Read / write Double. The Default value of HeaderMargin is 0.3.
Declaration
double HeaderMargin { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
Remarks
To know more about page settings refer this link.
Examples
The following code illustrates the use of HeaderMargin property.
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];
sheet.Range["A1:T100"].Text = "PagePrint";
//Sets the distance from the top of the page to the header
sheet.PageSetup.HeaderMargin = 0.4;
sheet.PageSetup.BottomMargin = 0.75;
sheet.PageSetup.FooterMargin = 0.4;
sheet.PageSetup.LeftMargin = 0.75;
sheet.PageSetup.RightMargin = 0.75;
sheet.PageSetup.TopMargin = 0.75;
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
HFScaleWithDoc
Gets / sets the header and footer are scaled with document scaling. The default value of HFScaleWithDoc property is true.
Declaration
bool HFScaleWithDoc { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
To know more about page settings refer this link.
Examples
The following code illustrates the use of HFScaleWithDoc property.
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];
sheet.Range["A1:T100"].Text = "PagePrint";
sheet.Range["A1:D20"].CellStyle.FillBackground = ExcelKnownColors.Aqua;
sheet.Range["F1:R40"].CellStyle.FillBackground = ExcelKnownColors.Light_orange;
sheet.Range["A54:T80"].CellStyle.FillBackground = ExcelKnownColors.Light_blue;
sheet.Range["E1:T30"].CellStyle.Font.Color = ExcelKnownColors.Brown;
sheet.Range["A1:C50"].CellStyle.Font.Color = ExcelKnownColors.Green;
sheet.Range["A54:T90"].CellStyle.Font.Color = ExcelKnownColors.Red;
//sets the header and footer are scaled with document scaling
sheet.PageSetup.HFScaleWithDoc = true;
sheet.PageSetup.IsFitToPage = true;
sheet.PageSetup.CenterFooter = "Center Footer";
sheet.PageSetup.CenterHeader = "Center Header";
sheet.PageSetup.LeftFooter = "&T";
sheet.PageSetup.LeftHeader = "&D";
sheet.PageSetup.RightFooter = "&P";
sheet.PageSetup.RightHeader = "&D";
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
LeftFooter
Gets or sets the left part of the footer. Read / write String.
Declaration
string LeftFooter { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
&L Left aligns the characters that follow. &C Centers the characters that follow. &R Right aligns the characters that follow. &E Turns double-underline printing on or off. &X Turns superscript printing on or off. &Y Turns subscript printing on or off. &B Turns bold printing on or off. &I Turns italic printing on or off. &U Turns underline printing on or off. &S Turns strikethrough printing on or off. &D Prints the current date. &T Prints the current time. &F Prints the name of the document. &A Prints the name of the workbook tab. &P Prints the page number. &P+number Prints the page number plus the specified number. &P-number Prints the page number minus the specified number. && Prints a single ampersand. & "fontname" Prints the characters that follow in the specified font. Be sure to include the double quotation marks. &nn Prints the characters that follow in the specified font size. Use a two-digit number to specify a size in points. &N Prints the total number of pages in the document. To know more about page settings refer this link.
Examples
The following code illustrates the use of LeftFooter property.
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];
sheet.Range["A1:T100"].Text = "PagePrint";
//Sets the left part of the footer
sheet.PageSetup.LeftFooter = "Left Footer &G";
sheet.PageSetup.LeftFooterImage = System.Drawing.Image.FromFile("sample3.jpg");
sheet.PageSetup.CenterFooter = "Center Footer &G";
sheet.PageSetup.CenterFooterImage = System.Drawing.Image.FromFile("sample1.jpg");
sheet.PageSetup.CenterHeader = "Center Header &G";
sheet.PageSetup.CenterHeaderImage = System.Drawing.Image.FromFile("sample2.jpg");
sheet.PageSetup.LeftHeader = "Left Header &G";
sheet.PageSetup.LeftHeaderImage = System.Drawing.Image.FromFile("sample4.jpg");
sheet.PageSetup.RightFooter = "Right Footer &G";
sheet.PageSetup.RightFooterImage = System.Drawing.Image.FromFile("sample5.jpg");
sheet.PageSetup.RightHeader = "Right Header &G";
sheet.PageSetup.RightHeaderImage = System.Drawing.Image.FromFile("sample6.jpg");
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
LeftFooterImage
Gets / sets image for left part of the footer.
Declaration
Image LeftFooterImage { get; set; }
Property Value
Type | Description |
---|---|
System.Drawing.Image |
Remarks
&L Left aligns the characters that follow. &C Centers the characters that follow. &R Right aligns the characters that follow. &E Turns double-underline printing on or off. &X Turns superscript printing on or off. &Y Turns subscript printing on or off. &B Turns bold printing on or off. &I Turns italic printing on or off. &U Turns underline printing on or off. &S Turns strikethrough printing on or off. &D Prints the current date. &T Prints the current time. &F Prints the name of the document. &A Prints the name of the workbook tab. &P Prints the page number. &P+number Prints the page number plus the specified number. &P-number Prints the page number minus the specified number. && Prints a single ampersand. & "fontname" Prints the characters that follow in the specified font. Be sure to include the double quotation marks. &nn Prints the characters that follow in the specified font size. Use a two-digit number to specify a size in points. &N Prints the total number of pages in the document. To know more about page settings refer this link.
Examples
The following code illustrates the use of LeftFooterImage property.
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];
sheet.Range["A1:T100"].Text = "PagePrint";
//Set image for left part of the footer
sheet.PageSetup.LeftFooterImage = System.Drawing.Image.FromFile("sample3.jpg");
sheet.PageSetup.LeftFooter = "Left Footer &G";
sheet.PageSetup.CenterFooter = "Center Footer &G";
sheet.PageSetup.CenterFooterImage = System.Drawing.Image.FromFile("sample1.jpg");
sheet.PageSetup.CenterHeader = "Center Header &G";
sheet.PageSetup.CenterHeaderImage = System.Drawing.Image.FromFile("sample2.jpg");
sheet.PageSetup.LeftHeader = "Left Header &G";
sheet.PageSetup.LeftHeaderImage = System.Drawing.Image.FromFile("sample4.jpg");
sheet.PageSetup.RightFooter = "Right Footer &G";
sheet.PageSetup.RightFooterImage = System.Drawing.Image.FromFile("sample5.jpg");
sheet.PageSetup.RightHeader = "Right Header &G";
sheet.PageSetup.RightHeaderImage = System.Drawing.Image.FromFile("sample6.jpg");
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
LeftHeader
Gets or sets the left part of the header. Read / write String.
Declaration
string LeftHeader { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
&L Left aligns the characters that follow. &C Centers the characters that follow. &R Right aligns the characters that follow. &E Turns double-underline printing on or off. &X Turns superscript printing on or off. &Y Turns subscript printing on or off. &B Turns bold printing on or off. &I Turns italic printing on or off. &U Turns underline printing on or off. &S Turns strikethrough printing on or off. &D Prints the current date. &T Prints the current time. &F Prints the name of the document. &A Prints the name of the workbook tab. &P Prints the page number. &P+number Prints the page number plus the specified number. &P-number Prints the page number minus the specified number. && Prints a single ampersand. & "fontname" Prints the characters that follow in the specified font. Be sure to include the double quotation marks. &nn Prints the characters that follow in the specified font size. Use a two-digit number to specify a size in points. &N Prints the total number of pages in the document. To know more about page settings refer this link.
Examples
The following code illustrates the use of LeftHeader property.
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];
sheet.Range["A1:T100"].Text = "PagePrint";
//Sets the left part of the header
sheet.PageSetup.LeftHeader = "Left Header &G";
sheet.PageSetup.LeftHeaderImage = System.Drawing.Image.FromFile("sample4.jpg");
sheet.PageSetup.CenterFooter = "Center Footer &G";
sheet.PageSetup.CenterFooterImage = System.Drawing.Image.FromFile("sample1.jpg");
sheet.PageSetup.CenterHeader = "Center Header &G";
sheet.PageSetup.CenterHeaderImage = System.Drawing.Image.FromFile("sample2.jpg");
sheet.PageSetup.LeftFooter = "Left Footer &G";
sheet.PageSetup.LeftFooterImage = System.Drawing.Image.FromFile("sample3.jpg");
sheet.PageSetup.RightFooter = "Right Footer &G";
sheet.PageSetup.RightFooterImage = System.Drawing.Image.FromFile("sample5.jpg");
sheet.PageSetup.RightHeader = "Right Header &G";
sheet.PageSetup.RightHeaderImage = System.Drawing.Image.FromFile("sample6.jpg");
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
LeftHeaderImage
Gets / sets image for left part of the header.
Declaration
Image LeftHeaderImage { get; set; }
Property Value
Type | Description |
---|---|
System.Drawing.Image |
Remarks
&L Left aligns the characters that follow. &C Centers the characters that follow. &R Right aligns the characters that follow. &E Turns double-underline printing on or off. &X Turns superscript printing on or off. &Y Turns subscript printing on or off. &B Turns bold printing on or off. &I Turns italic printing on or off. &U Turns underline printing on or off. &S Turns strikethrough printing on or off. &D Prints the current date. &T Prints the current time. &F Prints the name of the document. &A Prints the name of the workbook tab. &P Prints the page number. &P+number Prints the page number plus the specified number. &P-number Prints the page number minus the specified number. && Prints a single ampersand. & "fontname" Prints the characters that follow in the specified font. Be sure to include the double quotation marks. &nn Prints the characters that follow in the specified font size. Use a two-digit number to specify a size in points. &N Prints the total number of pages in the document. To know more about page settings property refer this link.
Examples
The following code illustrates the use of LeftHeaderImage property.
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];
sheet.Range["A1:T100"].Text = "PagePrint";
//Set image for left part of the header
sheet.PageSetup.LeftHeaderImage = System.Drawing.Image.FromFile("sample4.jpg");
sheet.PageSetup.LeftHeader = "Left Header &G";
sheet.PageSetup.CenterFooter = "Center Footer &G";
sheet.PageSetup.CenterFooterImage = System.Drawing.Image.FromFile("sample1.jpg");
sheet.PageSetup.CenterHeader = "Center Header &G";
sheet.PageSetup.CenterHeaderImage = System.Drawing.Image.FromFile("sample2.jpg");
sheet.PageSetup.LeftFooter = "Left Footer &G";
sheet.PageSetup.LeftFooterImage = System.Drawing.Image.FromFile("sample3.jpg");
sheet.PageSetup.RightFooter = "Right Footer &G";
sheet.PageSetup.RightFooterImage = System.Drawing.Image.FromFile("sample5.jpg");
sheet.PageSetup.RightHeader = "Right Header &G";
sheet.PageSetup.RightHeaderImage = System.Drawing.Image.FromFile("sample6.jpg");
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
LeftMargin
Gets or sets the size of the left margin, in inches. Read / write Double. Default value of left margin is 0.7.
Declaration
double LeftMargin { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
Remarks
To know more about page settings refer this link.
Examples
The following code illustrates the use of LeftMargin property.
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];
sheet.Range["A1:T100"].Text = "PagePrint";
//Sets the value for the left margin
sheet.PageSetup.LeftMargin = 0.75;
sheet.PageSetup.BottomMargin = 0.75;
sheet.PageSetup.FooterMargin = 0.4;
sheet.PageSetup.HeaderMargin = 0.4;
sheet.PageSetup.RightMargin = 0.75;
sheet.PageSetup.TopMargin = 0.75;
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
Order
Gets or sets the order that Microsoft Excel uses to number pages when printing a large worksheet. Read / write ExcelOrder.
Declaration
ExcelOrder Order { get; set; }
Property Value
Type | Description |
---|---|
ExcelOrder |
Remarks
To know more about page settings refer this link.
Examples
The following code illustrates the use of Order property.
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];
sheet.Range["A1:J94"].Text = "PagePrint";
sheet.Range["K48:M54"].Text = "page";
//Sets the order of the worksheets to be printed
sheet.PageSetup.Order = ExcelOrder.DownThenOver;
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
Orientation
Portrait or landscape printing mode. Read / write ExcelPageOrientation.
Declaration
ExcelPageOrientation Orientation { get; set; }
Property Value
Type | Description |
---|---|
ExcelPageOrientation |
Remarks
To know more about page settings refer this link.
Examples
The following code illustrates the use of Orientation property.
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];
sheet.Range["A1:J94"].Text = "PagePrint";
sheet.Range["K48:M54"].Text = "page";
//Sets a Portrait or landscape printing mode
sheet.PageSetup.Orientation = ExcelPageOrientation.Portrait;
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
PaperSize
Gets or sets the size of the paper. Read / write ExcelPaperSize. Default value for size of paper is PaperA4.
Declaration
ExcelPaperSize PaperSize { get; set; }
Property Value
Type | Description |
---|---|
ExcelPaperSize |
Remarks
To know more about page settings refer this link.
Examples
The following code illustrates the use of PaperSize property.
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];
sheet.Range["A1:J94"].Text = "PagePrint";
sheet.Range["K48:M54"].Text = "page";
//Sets the size of the paper
sheet.PageSetup.PaperSize = ExcelPaperSize.A2Paper;
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
PrintComments
Gets or sets the way of comments are printed with the sheet. Read / write ExcelPrintLocation. We must include cell comments and print with the sheet.
Declaration
ExcelPrintLocation PrintComments { get; set; }
Property Value
Type | Description |
---|---|
ExcelPrintLocation |
Remarks
To know more about page settings refer this link.
Examples
The following code illustrates the use of PrintComments property.
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];
sheet.Range["A1:J94"].Text = "PagePrint";
sheet.Range["K48:M54"].Text = "page";
sheet.Range["A1"].AddComment().Text = "Sample Comments"; //Comment must be added
sheet.Range["A1"].Comment.IsVisible = true; //It is also must for PrintInPlace
//Sets the way of comments are printed with the sheet
sheet.PageSetup.PrintComments = ExcelPrintLocation.PrintSheetEnd;
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
PrintErrors
Gets or returns an ExcelPrintErrors constant specifying the type of print error displayed. This feature allows users to suppress the display of error values when printing a worksheet. Read / write ExcelPrintErrors.
Declaration
ExcelPrintErrors PrintErrors { get; set; }
Property Value
Type | Description |
---|---|
ExcelPrintErrors |
Remarks
To know more about page settings refer this link.
Examples
The following code illustrates the use of PrintErrors property.
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];
sheet.Range["A1:J94"].Text = "PagePrint";
sheet.Range["K48:M54"].Text = "page";
sheet.Range["L1"].Number = 230;
sheet.Range["L2"].Number = 3722;
sheet.Range["L3"].Number = 987;
sheet.Range["L4"].Number = 5678;
sheet.Range["L5"].Formula = "ASIN(L1:L4)"; //Sets the sample formula with error value
sheet.Range["K5"].Text = "Cell Error";
//Specifying the type of print error to be displayed
sheet.PageSetup.PrintErrors = ExcelPrintErrors.PrintErrorsNA;
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
PrintNotes
True if cell notes are printed as end notes with the sheet. Applies only to worksheets. Read / write Boolean.
Declaration
bool PrintNotes { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
To know more about page settings refer this link.
Examples
The following code illustrates the use of PrintNotes property.
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];
sheet.Range["A1:J94"].Text = "PagePrint";
sheet.Range["K48:M54"].Text = "page";
//True if cell notes are printed as end notes with the sheet
sheet.PageSetup.PrintNotes = true;
sheet.Range["A1"].AddComment().Text = "Sample Comments";
sheet.Range["A1"].Comment.IsVisible = true;
sheet.PageSetup.PrintComments = ExcelPrintLocation.PrintSheetEnd; //Notes are printed as end notes with the sheet
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
PrintQuality
Gets or sets the print quality in the dpi. Read / write ushort.
Declaration
int PrintQuality { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Remarks
To know more about page settings refer this link.
Examples
The following code illustrates the use of PrintQuality property.
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];
sheet.Range["A1:T100"].Text = "PagePrint";
sheet.Range["A1:D20"].CellStyle.FillBackground = ExcelKnownColors.Aqua;
sheet.Range["F1:R40"].CellStyle.FillBackground = ExcelKnownColors.Light_orange;
sheet.Range["A54:T80"].CellStyle.FillBackground = ExcelKnownColors.Light_blue;
sheet.Range["E1:T30"].CellStyle.Font.Color = ExcelKnownColors.Brown;
sheet.Range["A1:C50"].CellStyle.Font.Color = ExcelKnownColors.Green;
sheet.Range["A54:T90"].CellStyle.Font.Color = ExcelKnownColors.Red;
//Set the print quality in the dpi
sheet.PageSetup.PrintQuality = 600;
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
RightFooter
Gets or sets the right part of the footer. Read / write String.
Declaration
string RightFooter { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
&L Left aligns the characters that follow. &C Centers the characters that follow. &R Right aligns the characters that follow. &E Turns double-underline printing on or off. &X Turns superscript printing on or off. &Y Turns subscript printing on or off. &B Turns bold printing on or off. &I Turns italic printing on or off. &U Turns underline printing on or off. &S Turns strikethrough printing on or off. &D Prints the current date. &T Prints the current time. &F Prints the name of the document. &A Prints the name of the workbook tab. &P Prints the page number. &P+number Prints the page number plus the specified number. &P-number Prints the page number minus the specified number. && Prints a single ampersand. & "fontname" Prints the characters that follow in the specified font. Be sure to include the double quotation marks. &nn Prints the characters that follow in the specified font size. Use a two-digit number to specify a size in points. &N Prints the total number of pages in the document. To know more about page settings refer this link.
Examples
The following code illustrates the use of RightFooter property.
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];
sheet.Range["A1:T100"].Text = "PagePrint";
//Sets the right part of the footer
sheet.PageSetup.RightFooter = "Right Footer &G";
sheet.PageSetup.RightFooterImage = System.Drawing.Image.FromFile("sample5.jpg");
sheet.PageSetup.CenterFooter = "Center Footer &G";
sheet.PageSetup.CenterFooterImage = System.Drawing.Image.FromFile("sample1.jpg");
sheet.PageSetup.CenterHeader = "Center Header &G";
sheet.PageSetup.CenterHeaderImage = System.Drawing.Image.FromFile("sample2.jpg");
sheet.PageSetup.LeftFooter = "Left Footer &G";
sheet.PageSetup.LeftFooterImage = System.Drawing.Image.FromFile("sample3.jpg");
sheet.PageSetup.LeftHeader = "Left Header &G";
sheet.PageSetup.LeftHeaderImage = System.Drawing.Image.FromFile("sample4.jpg");
sheet.PageSetup.RightHeader = "Right Header &G";
sheet.PageSetup.RightHeaderImage = System.Drawing.Image.FromFile("sample6.jpg");
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
RightFooterImage
Gets / sets image for right part of the footer.
Declaration
Image RightFooterImage { get; set; }
Property Value
Type | Description |
---|---|
System.Drawing.Image |
Remarks
&L Left aligns the characters that follow. &C Centers the characters that follow. &R Right aligns the characters that follow. &E Turns double-underline printing on or off. &X Turns superscript printing on or off. &Y Turns subscript printing on or off. &B Turns bold printing on or off. &I Turns italic printing on or off. &U Turns underline printing on or off. &S Turns strikethrough printing on or off. &D Prints the current date. &T Prints the current time. &F Prints the name of the document. &A Prints the name of the workbook tab. &P Prints the page number. &P+number Prints the page number plus the specified number. &P-number Prints the page number minus the specified number. && Prints a single ampersand. & "fontname" Prints the characters that follow in the specified font. Be sure to include the double quotation marks. &nn Prints the characters that follow in the specified font size. Use a two-digit number to specify a size in points. &N Prints the total number of pages in the document. To know more about page settings refer this link.
Examples
The following code illustrates the use of RightFooterImage property.
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];
sheet.Range["A1:T100"].Text = "PagePrint";
//Set image for right part of the footer
sheet.PageSetup.RightFooterImage = System.Drawing.Image.FromFile("sample5.jpg");
sheet.PageSetup.RightFooter = "Right Footer &G";
sheet.PageSetup.CenterFooter = "Center Footer &G";
sheet.PageSetup.CenterFooterImage = System.Drawing.Image.FromFile("sample1.jpg");
sheet.PageSetup.CenterHeader = "Center Header &G";
sheet.PageSetup.CenterHeaderImage = System.Drawing.Image.FromFile("sample2.jpg");
sheet.PageSetup.LeftFooter = "Left Footer &G";
sheet.PageSetup.LeftFooterImage = System.Drawing.Image.FromFile("sample3.jpg");
sheet.PageSetup.LeftHeader = "Left Header &G";
sheet.PageSetup.LeftHeaderImage = System.Drawing.Image.FromFile("sample4.jpg");
sheet.PageSetup.RightHeader = "Right Header &G";
sheet.PageSetup.RightHeaderImage = System.Drawing.Image.FromFile("sample6.jpg");
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
RightHeader
Gets or sets the right part of the header. Read / write String.
Declaration
string RightHeader { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
&L Left aligns the characters that follow. &C Centers the characters that follow. &R Right aligns the characters that follow. &E Turns double-underline printing on or off. &X Turns superscript printing on or off. &Y Turns subscript printing on or off. &B Turns bold printing on or off. &I Turns italic printing on or off. &U Turns underline printing on or off. &S Turns strikethrough printing on or off. &D Prints the current date. &T Prints the current time. &F Prints the name of the document. &A Prints the name of the workbook tab. &P Prints the page number. &P+number Prints the page number plus the specified number. &P-number Prints the page number minus the specified number. && Prints a single ampersand. & "fontname" Prints the characters that follow in the specified font. Be sure to include the double quotation marks. &nn Prints the characters that follow in the specified font size. Use a two-digit number to specify a size in points. &N Prints the total number of pages in the document. To know more about page settings refer this link.
Examples
The following code illustrates the use of RightHeader property.
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];
sheet.Range["A1:T100"].Text = "PagePrint";
//Sets the right part of the header
sheet.PageSetup.RightHeader = "Right Header &G";
sheet.PageSetup.RightHeaderImage = System.Drawing.Image.FromFile("sample6.jpg");
sheet.PageSetup.CenterFooter = "Center Footer &G";
sheet.PageSetup.CenterFooterImage = System.Drawing.Image.FromFile("sample1.jpg");
sheet.PageSetup.CenterHeader = "Center Header &G";
sheet.PageSetup.CenterHeaderImage = System.Drawing.Image.FromFile("sample2.jpg");
sheet.PageSetup.LeftFooter = "Left Footer &G";
sheet.PageSetup.LeftFooterImage = System.Drawing.Image.FromFile("sample3.jpg");
sheet.PageSetup.LeftHeader = "Left Header &G";
sheet.PageSetup.LeftHeaderImage = System.Drawing.Image.FromFile("sample4.jpg");
sheet.PageSetup.RightFooter = "Right Footer &G";
sheet.PageSetup.RightFooterImage = System.Drawing.Image.FromFile("sample5.jpg");
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
RightHeaderImage
Gets / sets image for right part of the header.
Declaration
Image RightHeaderImage { get; set; }
Property Value
Type | Description |
---|---|
System.Drawing.Image |
Remarks
&L Left aligns the characters that follow. &C Centers the characters that follow. &R Right aligns the characters that follow. &E Turns double-underline printing on or off. &X Turns superscript printing on or off. &Y Turns subscript printing on or off. &B Turns bold printing on or off. &I Turns italic printing on or off. &U Turns underline printing on or off. &S Turns strikethrough printing on or off. &D Prints the current date. &T Prints the current time. &F Prints the name of the document. &A Prints the name of the workbook tab. &P Prints the page number. &P+number Prints the page number plus the specified number. &P-number Prints the page number minus the specified number. && Prints a single ampersand. & "fontname" Prints the characters that follow in the specified font. Be sure to include the double quotation marks. &nn Prints the characters that follow in the specified font size. Use a two-digit number to specify a size in points. &N Prints the total number of pages in the document. To know more about page settings refer this link.
Examples
The following code illustrates the use of RightHeaderImage property.
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];
sheet.Range["A1:T100"].Text = "PagePrint";
//Set image for right part of the header
sheet.PageSetup.RightHeaderImage = System.Drawing.Image.FromFile("sample6.jpg");
sheet.PageSetup.RightHeader = "Right Header &G";
sheet.PageSetup.CenterFooter = "Center Footer &G";
sheet.PageSetup.CenterFooterImage = System.Drawing.Image.FromFile("sample1.jpg");
sheet.PageSetup.CenterHeader = "Center Header &G";
sheet.PageSetup.CenterHeaderImage = System.Drawing.Image.FromFile("sample2.jpg");
sheet.PageSetup.LeftFooter = "Left Footer &G";
sheet.PageSetup.LeftFooterImage = System.Drawing.Image.FromFile("sample3.jpg");
sheet.PageSetup.LeftHeader = "Left Header &G";
sheet.PageSetup.LeftHeaderImage = System.Drawing.Image.FromFile("sample4.jpg");
sheet.PageSetup.RightFooter = "Right Footer &G";
sheet.PageSetup.RightFooterImage = System.Drawing.Image.FromFile("sample5.jpg");
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
RightMargin
Gets or sets the size of the right margin, in inches. Read / write Double. Default value of right margin is 0.7.
Declaration
double RightMargin { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
Remarks
To know more about page settings refer this link.
Examples
The following code illustrates the use of RightMargin property.
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];
sheet.Range["A1:T100"].Text = "PagePrint";
//Sets the value for the right margin
sheet.PageSetup.RightMargin = 0.75;
sheet.PageSetup.BottomMargin = 0.75;
sheet.PageSetup.FooterMargin = 0.4;
sheet.PageSetup.HeaderMargin = 0.4;
sheet.PageSetup.LeftMargin = 0.75;
sheet.PageSetup.TopMargin = 0.75;
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
TopMargin
Gets or sets the size of the top margin, in inches. Read / write Double. Default value of top margin is 0.75.
Declaration
double TopMargin { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
Remarks
To know more about page settings refer this link.
Examples
The following code illustrates the use of TopMargin property.
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];
sheet.Range["A1:T100"].Text = "PagePrint";
//Sets the value of the top margin
sheet.PageSetup.TopMargin = 0.75;
sheet.PageSetup.BottomMargin = 0.75;
sheet.PageSetup.FooterMargin = 0.4;
sheet.PageSetup.HeaderMargin = 0.4;
sheet.PageSetup.LeftMargin = 0.75;
sheet.PageSetup.RightMargin = 0.75;
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}
Zoom
Gets or sets a percentage (between 10 and 400 percent) by which Microsoft Excel will scale the worksheet for printing. Applies only to worksheets. Read / write ushort.
Declaration
int Zoom { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Remarks
To know more about page settings refer this link.
Examples
The following code illustrates the use of Zoom property.
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];
sheet.Range["A1:T100"].Text = "PagePrint";
sheet.Range["A1:D20"].CellStyle.FillBackground = ExcelKnownColors.Aqua;
sheet.Range["F1:R40"].CellStyle.FillBackground = ExcelKnownColors.Light_orange;
sheet.Range["A54:T80"].CellStyle.FillBackground = ExcelKnownColors.Light_blue;
sheet.Range["E1:T30"].CellStyle.Font.Color = ExcelKnownColors.Brown;
sheet.Range["A1:C50"].CellStyle.Font.Color = ExcelKnownColors.Green;
sheet.Range["A54:T90"].CellStyle.Font.Color = ExcelKnownColors.Red;
//Set a percentage to be zoom in print
sheet.PageSetup.Zoom = 200;
workbook.SaveAs("PageSetup.xlsx");
workbook.Close();
}