This is a migrated thread and some comments may be shown as answers.

Print File With Spreadsheet

4 Answers 221 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
José Mauro
Top achievements
Rank 1
José Mauro asked on 23 Oct 2014, 10:56 AM
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: http://www.telerik.com/help/wpf/radspreadsheet-overview.html. Basicly, I do:

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

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).

Thanks.

4 Answers, 1 is accepted

Sort by
0
Deyan
Telerik team
answered on 27 Oct 2014, 01:47 PM
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.

Regards,
Deyan
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.

 
0
Dan Ove
Top achievements
Rank 1
answered on 20 May 2015, 12:00 PM

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?

 

Thanks

0
Dan Ove
Top achievements
Rank 1
answered on 20 May 2015, 12:09 PM

BTW:

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

0
Tanya
Telerik team
answered on 21 May 2015, 03:42 PM
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();
this.grid.Children.Add(sheet);
 
ExportWhat exportSettings = new ExportWhat();
PrintWhatSettings settings = new PrintWhatSettings(exportSettings, false);
 
sheet.Measure(new Size(sheet.MinWidth,sheet.MinHeight));
sheet.Print(settings);

Hope this helps.

Regards,
Tanya
Telerik
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
Tags
Spreadsheet
Asked by
José Mauro
Top achievements
Rank 1
Answers by
Deyan
Telerik team
Dan Ove
Top achievements
Rank 1
Tanya
Telerik team
Share this question
or