Telerik.Reporting report generation using RadGridView for WinForms

Thread is closed for posting
39 posts, 0 answers
  1. Telerik Admin
    Telerik Admin avatar
    1527 posts
    Member since:
    Oct 2004

    Posted 10 Jun 2008 Link to this post

    Requirements

    RadControls and Reporting versions

     

    Q1 2008 SP1
    .NET version

     

    2.0
    Visual Studio version

     

    VS 2005
    Programming Language

     

    C#
    To convert code Telerik online converter

     
    PROJECT DESCRIPTION

    UPDATE (07/22/2010): RadGridView Q2 2010 natively supports Export to PDF, so this code library project is closed for further comments, because it becomes obsolete. Please, consider upgrading to Q2 2010+ instead.
    In case you are using older versions of our tools and this library, and have further questions, please open a new support ticket from your account and we will help you out.

    This article presents an example application, which exports data from the RadGridView into Telerik Reporting using a custom class library called RadGridReportingLite. The report can then be printed or exported in a variety of formats.

    You can directly reference it in your project. Keep in mind that you need to have both products installed: RadControls for WinForms and Telerik Reporting. You can find additional information on how to generate and setup a report based on data in RadGridView in the following KB article.

    To export RadGridView data to Telerik Reporting:

    1. Add a reference to RadGridReportingLite.dll in your project
    2. Create an instance of RadGridReport: 
      RadGridReportingLite.RadGridReport report = new RadGridReportingLite.RadGridReport("MyGridReport");
    3. Set properties controlling format and appearance:
      report.AllMargins = 1;
      report.FitToPageSize = true;  
      report.RepeatTableHeader = true;
    4. Generate and show the report using the code below:
      report.ReportFormShow(this, this.radGridView1);
    5. Use the following properties to control the appearance of the report:
    • Int AllMargins – Set all paper margins in millimeters
    • Int BottomMargin – Set bottom margin in millimeters
    • Int TopMargin – Set top margin in millimeters
    • Int LeftMargin – Set left margin in millimeters
    • Int RightMargin – Set right margin in millimeters
    • bool FitToPageSize – Controls whether report table is fit to page size
    • bool PageLandScape – Controls orientation of the report on the page
    • PaperKind PaperKind – Set paper type (A4, A3 etc.)\
    • bool RepeatTableHeader – Controls whether the table header is repeated on each page
    • string ReportName – Set report name
    • Size ReportSize – Set report size
    • FormWindowState ReportWindowState – Set report form window state
    • bool UseGridColors – Controls whether the report uses the header colors from RadGridView
    • RadGridReport(string reportName) – Create a new instance of the class
    • ReportFormShow(IWin32Window owner, RadGridView radGridView) - generate and show the report.

  2. michelle
    michelle avatar
    16 posts
    Member since:
    Jul 2008

    Posted 30 Jul 2008 Link to this post

    Is the same type of functionality available for the RadGrid used in WebForms?  We are in need of a tool that will export grid formatting to RTF.

    Thanks!

  3. Steve
    Admin
    Steve avatar
    10942 posts
    Member since:
    May 2014

    Posted 31 Jul 2008 Link to this post

    Hi Michelle,

    You can directly use the Web RadGrid export options for your needs. RadGrid for WinForms does not have any export options yet, and that is why we've created this code library.

    All the best,
    Steve
    the Telerik team


    Check out Telerik Trainer, the state of the art learning tool for Telerik products.

  4. Jacob
    Jacob avatar
    10 posts
    Member since:
    Sep 2008

    Posted 10 Feb 2009 Link to this post

    Can I have vb version of this project?

    Thank you.

  5. Steve
    Admin
    Steve avatar
    10942 posts
    Member since:
    May 2014

    Posted 10 Feb 2009 Link to this post

    Hello Jacob,

    Please use the code converter as suggested in the code library info table. If you hit specific problems with the conversion, let us know and we would gladly help.

    Kind regards,
    Steve
    the Telerik team


    Check out Telerik Trainer, the state of the art learning tool for Telerik products.

  6. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts
    Member since:
    Sep 2012

    Posted 08 Jul 2009 Link to this post

    Hello folks.

    I just want to make a follow-up to this topic with latest build of RadGridReportingLite class that works with latest version of the Winforms Controls and Telerik Reporting - Q1 2009 SP1. Please, find the projects as attachment to this message.

    Best wishes,
    Martin Vasilev
    the Telerik team


    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.

  7. Rodney Foley
    Rodney Foley avatar
    51 posts
    Member since:
    Oct 2009

    Posted 01 Dec 2009 Link to this post

    Is there plans to update this (or create a new one) to support WPF 2009.3 and .NET 3.5?

  8. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2018 posts
    Member since:
    Sep 2012

    Posted 04 Dec 2009 Link to this post

    Hi Rodney Foley,

    RadGridView for WPF and Silverlight has its own  integrated exporting logic. For more information you may have a look at the following help topic.

    In case you need any assistance adapting this to your project , please open a thread (or a support ticket)  in the RadGridView for WPF section and we will be glad to help.

    Sincerely yours,
    Pavel Pavlov
    the Telerik team


    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

  9. Rodney Foley
    Rodney Foley avatar
    51 posts
    Member since:
    Oct 2009

    Posted 04 Dec 2009 Link to this post

    Greetings Pavel,


    Feel free to review my support tickets and you will see that I am fully aware of those export methods which are for lack of a better word "crap". Exporting thousands of records and especially tens of thousands of records via a STRING is insane.  That method of export should at least a stream, if not also provide template abilities if they wish to have it be direct from the control itself.

    Why wouldn't Telerik want to make it as easy as possible to get the current "VIEW" of data in a RadGridView into one of their Reporting framework?  I thought that was one of the reasons for this code library item.  It seems to me that it would help to increase the use of your Reporting framework, while also making an easy way for developers to provide nice formated views of the data for users to Print or Export to PDF or XLSX formats.

    I ended up using the OpenXML SDK to export the raw data that was used to populate the Grid to get a formated table view into an XLSX format.  However to keep it simple and easy to implement I had to stick with the raw data used, it would become more complex to export the data as the user has organized it via grouping, sorting and filtering.  Which I would assume a bridge object of some type could manage nicely and could be best implemented by the company who wrote both the control and the reporting framework.

    With that said, all I was asking for is if Telerik had plans to update this item in the code library so that it would support the latest release (which it currently does not).  That was all. Most companies I assume are not using almost 2 year old libraries in their code base and if they are they may already be making plans to migrate to a new version over the next 12 months.  

    Being told in not so many words "No" and then to be directed to a horrible solution as its replacement is not really the answer I was looking for. I was either expecting a simple "No", a "No" with an alternative solution that had the same basic outcome that still used the Reporting framework, or a "Yes" with a time frame of when to expect an update.

  10. Vassil Petev
    Admin
    Vassil Petev avatar
    1766 posts
    Member since:
    Sep 2012

    Posted 08 Dec 2009 Link to this post

    Hello Rodney Foley,

    I will forward your request for such an example using RadGridView for WPF to our WPF team.

    The current project is for RadControls for WinForms, and not for WPF. Since we update these projects upon request (but not with each new release), please let us know whether you need a new version with our WinForms controls and we will do our best to have it uploaded tomorrow.
     
    Best wishes,
    Vassil
    the Telerik team


    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

  11. Nikolay
    Admin
    Nikolay avatar
    3996 posts
    Member since:
    May 2014

    Posted 17 Dec 2009 Link to this post

    Hello Rodney Foley,

    We actually do not plan to work on a WPF Report Viewer this quarter. This is indeed a great suggestion and we will definitely consider it, however, this Q we will be mainly focused on VS 2010 support and improvements in our existing controls, as well as working on our native controls for Silverlight 4 that are in a CTP stage right now.

    Greetings,
    Nick
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

  12. Benjie Ward
    Benjie Ward avatar
    1 posts
    Member since:
    Feb 2010

    Posted 22 Feb 2010 Link to this post

    Hi Martin,

    In cases where Grid columns may have an empty string for the HeaderText, the report viewer generated an error rendering the column. By referencing FieldName rather than HeaderText in RadGridReport.cs it seemed to resolve this issue.

    I updated the line in CreateTableFromTemplate() to:

    table.Columns.Add(gridViewTemplate.Columns[col].FieldName, gridViewTemplate.Columns[col].DataType); 

    And the following lines under the REPORT TABLE ROWS region in AddReportData():

    dataTextBox.Name = grid.Columns[i].FieldName + "FieldTextBox";
    dataTextBox.Value = "=Fields.[" + grid.Columns[i].FieldName + "]";


    Thanks again for this code.

    Benjie

  13. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts
    Member since:
    Sep 2012

    Posted 24 Feb 2010 Link to this post

    Hello Benjie Ward,

    Thank you very much for sharing your code with us. Apparently, your approach is definitely better than used in the sample application. We will update our code in near feature. I have add 500 Telerik points to your account. Do not hesitate to contact us again if you have other questions.

    Regards,
    Martin Vasilev
    the Telerik team


    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 Public Issue Tracking system and vote to affect the priority of the items.

  14. Ken
    Ken avatar
    9 posts
    Member since:
    Jan 2008

    Posted 30 Mar 2010 Link to this post

    I had modified RadGridReportingLite for improved features and named the RadGridReportingLite2.

    To improve the function, as follows:

    1. Implementat summary:SUM, COUNT function...
    2. For entire report, customize the font
    3. To increase TITLE item(maximum 5 items) per page

    The project should reference to RadGridreportingLite2, RadGridreportingLite2Utility

    The following are examples (at the FormMain.cs of ExampleApplication.sln)

    // Group
    report.GroupCaption = new string[] { "ManagerID Caption:" };

     

    // Summary Column:EmployeeID, ContactID
    report.SummaryItems = new List<RadGridReportingLite2.Summary_Item>()
    {
      new Summary_Item("EmployeeID", "EmployeeID", string.Empty, " records", string.Empty, GridAggregateFunction.Count),
      new Summary_Item("ContactID", "ContactID", string.Empty, string.Empty, "###,###,##0",GridAggregateFunction.Sum)
    };

    report.CellFont = new Font("Arias", 9f, FontStyle.Regular);
    report.RepeatTableHeader = form.RepeatHeaderRow;

    RadLabel lblTitle1 = new RadLabel();
    lblTitle1.BackColor = System.Drawing.Color.White;
    lblTitle1.Text = "Title1";
    lblTitle1.Font = new Font("Arias", 14f, FontStyle.Bold);
    lblTitle1.TextAlignment = ContentAlignment.MiddleCenter;
    report.TitleText1 = lblTitle1;

     

    RadLabel lblTitle2 = new RadLabel();
    lblTitle2.BackColor = System.Drawing.Color.White;
    lblTitle2.Text = "Title2";
    lblTitle2.Font = new Font("Arias", 12f, FontStyle.Bold);
    lblTitle2.TextAlignment = ContentAlignment.MiddleCenter;
    report.TitleText1 = lblTitle2;
    ....

    Source code in the attachment, and want to help you.

    RadControls and Reporting versions: Q1 2008 SP1

    Ken

  15. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts
    Member since:
    Sep 2012

    Posted 02 Apr 2010 Link to this post

    Hello SIN YI,

    Thank you very much for posting your code and detailed description in our code library section. I have added additional Telerik points to your account. Let me know if you have any other questions.

    Greetings,
    Martin Vasilev
    the Telerik team


    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 Public Issue Tracking system and vote to affect the priority of the items.

  16. Ken
    Ken avatar
    9 posts
    Member since:
    Jan 2008

    Posted 04 Apr 2010 Link to this post

    It was my pleasure If any of the benefit.
    The Telerik's products to help me design better software quality, and I am pleased to have chosen the Telerik.

  17. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts
    Member since:
    Sep 2012

    Posted 26 Apr 2010 Link to this post

    Hi all,

    Please find the latest build of RadGridReportingLite library as an attachment. It contains some minor fixes and changes which allow for using it with the latest WinForms Q1 2010 SP1 and Reporting Q1 2010 SP1 versions.

    Kind regards,
    Martin Vasilev
    the Telerik team

    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 Public Issue Tracking system and vote to affect the priority of the items.

  18. Nick Conder
    Nick Conder avatar
    6 posts
    Member since:
    Feb 2010

    Posted 01 Jun 2010 Link to this post

    Do you have an updated version of your ReportingLite2?

    The version you had up for download uses older telerik reporting and generates an error that it cant find telerik reporting version .828.

    I tried adding the references to the new and missing assemblies and recompile but it also had many errors. like telerik.reporting.processing, there is no processing or interfaces assemblies in the current version of the telerik reporting but they are required references in your source code.

    Any help would be greatly appreciated.

  19. Ken
    Ken avatar
    9 posts
    Member since:
    Jan 2008

    Posted 02 Jun 2010 Link to this post

    Hi,
    I run the attachment-radgridreportinglite.zip and without any errors, 
    If you use the ReportingLite2, Can give the wrong snapshot?

    Ken

  20. Nick Conder
    Nick Conder avatar
    6 posts
    Member since:
    Feb 2010

    Posted 02 Jun 2010 Link to this post

    Attached are a couple screen shots of the issues. All I did was unzip the files and open them in VS 2008. There are two assemblies that I can not find in the current Telerik Reporting and that is the INTERFACES and PROCESSING. I am using the latest version.


    I can compile and use the original reporting light with out a problem. 

  21. Ken
    Ken avatar
    9 posts
    Member since:
    Jan 2008

    Posted 02 Jun 2010 Link to this post

    I combined the necessary assemblies as the attached based on the screen shots.
    Please join your project, and reference them.

    Hope to solve your problem.

    Ken

  22. Nick Conder
    Nick Conder avatar
    6 posts
    Member since:
    Feb 2010

    Posted 02 Jun 2010 Link to this post

    What version of Telerik Reporting and Telerik Win controls are you using.


    The assemblies you provided are from a different version than the most current version of reporting and controls.

    I added the references to the assemblies you provided in your zip file and it just made it worse.

    Attached are new screen shots of the errors now and also screen shots of the properties for the Telerik Reporting properties showing the current version info and a screen shot of one of the assemblies you sent.

    If you look at the errors screen shot you will see that processing and interfaces are part of the telerik reporting main assembly now compared to you version which looks like maybe an older version or something.

    Even though processing and interfaces appear to be part of the main reporting assembly now there are still errors through out the source due to that it can not find the references in the telerik reporting assembly for the current version.

  23. Ken
    Ken avatar
    9 posts
    Member since:
    Jan 2008

    Posted 02 Jun 2010 Link to this post

    ReportingLite2 used the RadControls and Reporting versions is Q1 2008 SP1.

    Ken

  24. Nick Conder
    Nick Conder avatar
    6 posts
    Member since:
    Feb 2010

    Posted 02 Jun 2010 Link to this post

    wow thats is pretty dated. Any chance you are going to update your version using the latest version of the controls? I am going to work on that myself to help contribute, but right now my only issue is my project schedule really has me limited on any free time to work on side projects.

  25. Ken
    Ken avatar
    9 posts
    Member since:
    Jan 2008

    Posted 02 Jun 2010 Link to this post

    I am sorry about that.
    If the separation of the functions of print as a separate dll file
    that uses different version and the main function to call it, can it?

    Ken

  26. Nick Conder
    Nick Conder avatar
    6 posts
    Member since:
    Feb 2010

    Posted 02 Jun 2010 Link to this post

    thats what you would think but apparently that is not the case.

  27. Allan D. Jensen
    Allan D. Jensen avatar
    5 posts
    Member since:
    Sep 2009

    Posted 25 Jun 2010 Link to this post

    Dear Steve
    Nice project, but I cannot report only RadGridView.SelectedRows to the report viewer. How would you do that?
    Thanks

  28. rohini ashok
    rohini ashok avatar
    1 posts
    Member since:
    Aug 2009

    Posted 28 Jun 2010 Link to this post

    Hi,
    Please help me how to add the Radgridreportinglite.dll reference into my VB project..
    if i add that reference and give Imports Radgridreportinglite..its not workig..
    Pls help urgent

  29. Jack
    Jack avatar
    1 posts
    Member since:
    Apr 2010

    Posted 29 Jun 2010 Link to this post

    Hi,

    I tried to used RadGridReportingLite.dll to export my RadGridView into Reports, it's seems to work perfectly execpted for the GridViewSummaryItem and GridViewSummaryRowItem. Those rows are visible in the Grid but not in the report.

    What can I do ?

    Thanks

    Jack

  30. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts
    Member since:
    Sep 2012

    Posted 01 Jul 2010 Link to this post

    Hello guys,

    As to the question about references I am afraid that I do not have enough information to point the issue. Rohini, please open a new support ticket and send me more details what exactly are you experiencing in your scenario, where report does not generated.

    Jack, report generation class does not support including grid's summary rows. Probably, you would find useful other support methods: ExportToExcelML, ExportToCSV, ExportToHTML and ExportToPDF. All of them supports summary rows. Please note that the export to csv, html and pdf are only available in our Q2 2010 beta release and are scheduled for the official release as well.

    All the best,
    Martin Vasilev
    the Telerik team

    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 Public Issue Tracking system and vote to affect the priority of the items

Back to Top