Spread WPF 18
Features / Print / Page Settings
In This Topic
    Page Settings
    In This Topic

    This topic page explains how you can configure the page settings to control the appearance of the printed page.

    Page Margins

    You can adjust the page margins to fit the worksheet contents on the page to be printed. Use the TopMarginBottomMarginLeftMarginRightMarginHeaderMargin, and FooterMargin properties of the IPageSetup interface to configure margins for a page.

    You can also center the worksheet horizontally or vertically on the page when it's printed using the CenterHorizontally and CenterVertically properties.

    The following example code sets the top and left margins of the page.

    Copy Code
    // Set TopMargin & LeftMargin of worksheet[0] to 250.
    spreadSheet1.Workbook.Worksheets[0].PageSetup.TopMargin = 250;
    spreadSheet1.Workbook.Worksheets[0].PageSetup.LeftMargin = 250;
    
    Copy Code
    ' Set TopMargin & LeftMargin of worksheet[0] to 250.
    spreadSheet1.Workbook.Worksheets(0).PageSetup.TopMargin = 250
    spreadSheet1.Workbook.Worksheets(0).PageSetup.LeftMargin = 250
    

    Page Orientation

    You can change the page orientation to landscape or portrait to orient it horizontally or vertically. By default, page orientation is portrait. Use the Orientation property of the IPageSetup interface to set the orientation for the page to Portrait or Landscape, as per your preferences.

    The following example code sets the orientation for pages.

    Copy Code
    // Set the page orientation to landscape.
    spreadSheet1.Workbook.ActiveSheet.PageSetup.Orientation = GrapeCity.Spreadsheet.Printing.PageOrientation.Landscape;
    
    Copy Code
    ' Set the page orientation to landscape.
    spreadSheet1.Workbook.ActiveSheet.PageSetup.Orientation = GrapeCity.Spreadsheet.Printing.PageOrientation.Landscape
    

    Page Order

    You can change the order in which worksheet pages are printed. Use the Order property of the IPageSetup interface to set the page order to DownThenOver or OverThenDown.

    The following example code shows how to set the print order to OverThenDown.

    Copy Code
    // Set the Page's Order to OverThenDown.
    spreadSheet1.Workbook.ActiveSheet.PageSetup.Order = GrapeCity.Spreadsheet.Printing.Order.OverThenDown;
    
    Copy Code
    ' Set the Page's Order to OverThenDown.
    spreadSheet1.Workbook.ActiveSheet.PageSetup.Order = GrapeCity.Spreadsheet.Printing.Order.OverThenDown
    

    Page Break

    You can use page breaks in a worksheet to break the data into separate pages for printing. It helps to print the data with the exact number that you want. Page breaks control where a page ends and where a new page starts. You can use the PageBreak property of the IRange interface to apply page breaks on rows and columns in a worksheet.

    The below code applies a verticle break in a worksheet.

    Copy Code
    // Apply vertical page break.         
    spreadSheet1.Workbook.ActiveSheet.Rows[2].PageBreak = PageBreak.Manual;
    
    Copy Code
    ' Apply vertical page break.         
    spreadSheet1.Workbook.ActiveSheet.Rows(2).PageBreak = PageBreak.Manual
    

    Paper Scaling

    You can scale the worksheet content to fit the page width by either shrinking or enlarging the content. Use the FitToPagesFitToPagesTall, and FitToPagesWide properties of the IPageSetUp interface to set the size of the paper that will be used for printing.

    The following example code sets the page scaling.

    Copy Code
    // Set paper scaling.
    spreadSheet1.Workbook.Worksheets[0].PageSetup.FitToPages = true;
    spreadSheet1.Workbook.Worksheets[0].PageSetup.FitToPagesTall = 1;
    spreadSheet1.Workbook.Worksheets[0].PageSetup.FitToPagesWide = 1;
    
    Copy Code
    ' Set paper scaling.
    spreadSheet1.Workbook.Worksheets(0).PageSetup.FitToPages = True
    spreadSheet1.Workbook.Worksheets(0).PageSetup.FitToPagesTall = 1
    spreadSheet1.Workbook.Worksheets(0).PageSetup.FitToPagesWide = 1
    

    Additionally, you can also adjust the zoom percentage of the worksheet for printing by using the Zoom property of the IPageSetUp interface.

    The following example code sets the zoom percentage for the page.

    Copy Code
    // Set the zoom percentage to 250.
    spreadSheet1.Workbook.Worksheets[0].PageSetup.Zoom = 250;
    
    Copy Code
    ' Set the zoom percentage to 250.
    spreadSheet1.Workbook.Worksheets(0).PageSetup.Zoom = 250
    

    Paper Size

    You can change the size of the printed paper by using the PaperSize property of IPageSetUp interface.

    The following example code sets the paper size.

    Copy Code
    // Set page size.
    spreadSheet1.Workbook.Worksheets[1].PageSetup.PaperSize = GrapeCity.Spreadsheet.Printing.PaperSize.PaperA3;
    
    Copy Code
    ' Set page size.
    spreadSheet1.Workbook.Worksheets(1).PageSetup.PaperSize = GrapeCity.Spreadsheet.Printing.PaperSize.PaperA3