ASP.Net SpreadProcessing

4 posts, 1 answers
  1. Sandra Walters
    Sandra Walters avatar
    29 posts
    Member since:
    Dec 2005

    Posted 29 Aug 2015 Link to this post

    I want to set the paper type and ScaleFactor of worksheet but the code below for papertype and scalefactor does not compile.  I would like some help with this.

    WorksheetPageSetup pageSetup = wb.ActiveWorksheet.WorksheetPageSetup;

    pageSetup.Margins = new PageMargins(25.00, 25.00, 25.00, 25.00);

    pageSetup.PaperType = PaperType.Letter;

    pageSetup.ScaleFactor = new Size(0.9, 0.9);

  2. Tanya
    Admin
    Tanya avatar
    405 posts

    Posted 01 Sep 2015 Link to this post

    Hello Sandra,

    There is a typo in the snippet - the enumeration with the PaperType values is called PaperTypes

    Another reason to experience similar issue could be a missing namespace. For your convenience I am pasting the same snippet with added the namespaces of the used classes:
    Telerik.Windows.Documents.Spreadsheet.Model.Printing.WorksheetPageSetup pageSetup = this.radSpreadsheet.Workbook.ActiveWorksheet.WorksheetPageSetup;
    pageSetup.Margins = new Telerik.Windows.Documents.Spreadsheet.Model.Printing.PageMargins(25.00, 25.00, 25.00, 25.00);
    pageSetup.PaperType = Telerik.Windows.Documents.Model.PaperTypes.Letter;
    pageSetup.ScaleFactor = new System.Windows.Size(0.9, 0.9);

    Hope this helps.

    Regards,
    Tanya
    Telerik
  3. Sandra Walters
    Sandra Walters avatar
    29 posts
    Member since:
    Dec 2005

    Posted 01 Sep 2015 in reply to Tanya Link to this post

    Thanks very much for the clarification on PaperTypes.  I am still seeing an error with the Scaling Factor.

    pageSetup.ScaleFactor = new System.Windows.Size(0.9, 0.9);

     the type or namespace name "Size" does not exist in the namespace "System.Windows".  I am not given an opportunity to 'resolve' and I tried adding a specific reference to System.Windows.

     

     

  4. Answer
    Tanya
    Admin
    Tanya avatar
    405 posts

    Posted 04 Sep 2015 Link to this post

    Hi Sandra,

    This error occurs as a result of a missing reference. In order to use the Size class from the System.Windows namespace you need to add a reference to the WindowsBase assembly in your project.

    Regards,
    Tanya
    Telerik
Back to Top