Xceed Workbooks for .NET v3.0 Documentation
Xceed.Workbooks.NET Assembly / Xceed.Workbooks.NET Namespace / PageLayout Class / FitToPageWidth Property
Example


In This Topic
    FitToPageWidth Property
    In This Topic
    Gets or sets how the content's width will be scaled when the Worksheet is printed.
    Syntax
    'Declaration
     
    
    Public Property FitToPageWidth As Short
    'Usage
     
    
    Dim instance As PageLayout
    Dim value As Short
     
    instance.FitToPageWidth = value
     
    value = instance.FitToPageWidth
    public short FitToPageWidth {get; set;}
    Remarks

    The value of this property corresponds to a number of pages.

    The default value is 0, which means that the content will not be scaled in any way, width-wise.

    If the value was set to 3, for example, the content's width would be scaled to fit 3 pages. The content's height, however, would not be affected; scaling the height would have to be done via the FitToPageHeight property. 

    Example
    public static void PageOrientationAndSetup()
    {
      using( var workbook = Workbook.Create(PageLayoutSample.PageLayoutSampleOutputDirectory + @"PageSetup.xlsx"))
        {
          //Gets the first worksheet; a workbook contains at least 1 worksheet.
          var worksheet = workbook.Worksheets[0];
    	  
          // Adds a title.
          worksheet.Cells["B1"].Value = "Page Setup";
          worksheet.Cells["B1"].Style.Font = new Font() {Bold = true, Size = 15.5d};
    	  
          // Sets the Landscape orientation.
          worksheet.PageLayout.Orientation = OrientationType.Landscape;
    	  
          // Adjusts the paper size.
          worksheet.PageLayout.PageSize = PaperSizeType.Executive;
    
          // Adjusts fit to width & fit to height settings. Note that if the value is not 0, the Scale property is overridden.
          worksheet.PageLayout.FitToPageWidth = 2;
          worksheet.PageLayout.FitToPageHeight = 3;
    	  
          // Saves the workbook to disk.
          workbook.Save();
          Console.WriteLine( "/tCreated: PageSetup.xlsx/n" );
        }
    }
    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also