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

Print Aggregate=sum in footer

4 Answers 110 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Lloyd Johnson
Top achievements
Rank 1
Lloyd Johnson asked on 18 Feb 2017, 02:04 PM

In viewing the RadGridView, my columns are totaling into the footer as expected.  When I Print, though, the footer appears but all columns are blank. I am using ToPrintFriendlyGrid.

I've found old posts that addressed this issue but nothing lately.

Can you help?

Thanks!

4 Answers, 1 is accepted

Sort by
0
Stefan Nenchev
Telerik team
answered on 21 Feb 2017, 10:48 AM
Hello Lloyd,

I believe the approach of printing the RadGridView that you are using is quite old and it is not using any of the Telerik Document Library classes. I suggest you consider the newer approaches available - Print Preview with RadSpreadSheet(the demo can be found in the SDK Samples Browser or on Github) or the GridView Print and Print Preview(available in the WPF Demos Application).

I hope the information will be helpful.

Regards,
Stefan Nenchev
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
0
Lloyd Johnson
Top achievements
Rank 1
answered on 10 Apr 2017, 03:55 AM

As suggested, I have changed my code so that I am using 'Print Preview with RadSpreadSheet'.  This is now working correctly, but I cannot find sample code to show me how to change the Print Settings.  I need to print in Landscape and on Letter instead of A4 paper and adjust the margins.

Can you point me to documentation that shows how to do this?

Thanks!

0
Accepted
Stefan Nenchev
Telerik team
answered on 12 Apr 2017, 10:33 AM
Hello Lloyd,

The Orientation and Margins can be controlled by setting the WorksheetPageSetup settings of each individual Worksheet within the Workbook that the RadSpreadSheet contains. I suggest you have a look at the RadSpreadProcessing documentation for more information. As a certain Workbook can contain multiple Worksheets, you can iterate over them and set their settings:

private static RadSpreadsheet CreateSpreadsheet(RadGridView grid)
        {
            var workbook = CreateWorkBook(grid);
            
            return new RadSpreadsheet()
            {
                Workbook = CreateWorkBook(grid)
            };
        }
 
        private static Workbook CreateWorkBook(RadGridView grid)
        {
            Workbook book = null;
 
            using (var stream = new MemoryStream())
            {
                if (grid != null)
                {
                    grid.ExportToXlsx(stream, new GridViewDocumentExportOptions()
                    {
                        ShowColumnFooters = grid.ShowColumnFooters,
                        ShowColumnHeaders = grid.ShowColumnHeaders,
                        ShowGroupFooters = grid.ShowGroupFooters,
                        ExportDefaultStyles = true
                    });
                }
 
                stream.Position = 0;
 
                book = new XlsxFormatProvider().Import(stream);
            }
 
            foreach (var item in book.Worksheets)
            {
                (item as Worksheet).WorksheetPageSetup.PageOrientation = Telerik.Windows.Documents.Model.PageOrientation.Landscape;
                (item as Worksheet).WorksheetPageSetup.Margins = PageMargins.WideMargins;
            }
 
            return book;
        }

I have modified the SDK sample for your reference. Please have a look at the attached project.

Regards,
Stefan Nenchev
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
0
Lloyd Johnson
Top achievements
Rank 1
answered on 12 Apr 2017, 12:15 PM

Just what I needed, Stefan.

Thanks!

 

Tags
GridView
Asked by
Lloyd Johnson
Top achievements
Rank 1
Answers by
Stefan Nenchev
Telerik team
Lloyd Johnson
Top achievements
Rank 1
Share this question
or