Print File With Spreadsheet

5 posts, 0 answers
  1. José Mauro
    José Mauro avatar
    1 posts
    Member since:
    Oct 2014

    Posted 23 Oct 2014 Link to this post

    Hi Telerik Team,

    I have a sheet and should print it directly in default printer. I'm using RadSpreadsheet, but does is not working.  I follow the documentation shown: Basicly, I do:

    RadSpreadsheet radSpreadSheet = new RadSpreadsheet();
    radSpreadSheet.Workbook = myWorkbook;
    radSpreadSheet.ActiveSheet = myWorkbook.Worksheets[0];
    PrintWhatSettings printWhatSettings = new PrintWhatSettings(ExportWhat.ActiveSheet, false);

    The above code doesn't prints the file.

    What I'm doing wrong?

    PS: I'm evaluating the components for a new project (The trial version).

  2. Deyan
    Deyan avatar
    158 posts

    Posted 27 Oct 2014 Link to this post

    Hello José Mauro,

    Thank you for choosing Telerik's RadSpreadsheet control for WPF.

    As you may see in this printing documentation article the Print method has two overloads:
    • If you want a PrintDialog to be shown, you should be using the following method - Print(PrintWhatSettings printWhatSettings, string printDescription = null). This way the user of the application will manually choose the printer and the specific printer settings.
    • If you want to print silently without showing a print dialog you should use the following method - Print(PrintWhatSettings printWhatSettings, PrintDialog printDialog, string printDescription = null). This way you can initialize the PrintDialog instance from code behind. Using WPF's printing API you may choose the specific printer and its printing settings .

    I hope this helps. If you have any other questions or concerns do not hesitate to contact us again.

    the Telerik team

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

  3. Dan Ove
    Dan Ove avatar
    9 posts
    Member since:
    Feb 2012

    Posted 20 May 2015 in reply to Deyan Link to this post

    Hi I have the same problem as José Mauro.
    I have found out that if I use an local RadSpreadsheet radSpreadSheet = new RadSpreadsheet() it doesn't work. But if I add the RadSpreadsheet somewhere in my XAML it does.
    The funny part is if I set RadSpreadsheet Visibility to hidden or collapsed, it does not print, and I dont get any error what so ever. It seems that the RadSpreadsheet must be visible to the user to be printable.

    Is there a better way to print an workbook object to the default printer?



  4. Dan Ove
    Dan Ove avatar
    9 posts
    Member since:
    Feb 2012

    Posted 20 May 2015 in reply to Dan Ove Link to this post


    The workaround is add this to your xaml <telerik:RadSpreadsheet x:Name="RadSpreadsheet" Width="1" Height="1" />

    But you can't use this to do an silent print form an command line or windows service application

  5. Tanya
    Tanya avatar
    583 posts

    Posted 21 May 2015 Link to this post

    Hello Dan Ove,

    In order to print a RadSpreadsheet, the control must be present in the visual tree. You could place the document in a panel with sizes 0x0 to prevent showing it to the user and measure it in the desired size:
    RadSpreadsheet sheet = new RadSpreadsheet();
    ExportWhat exportSettings = new ExportWhat();
    PrintWhatSettings settings = new PrintWhatSettings(exportSettings, false);
    sheet.Measure(new Size(sheet.MinWidth,sheet.MinHeight));

    Hope this helps.

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top