Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.Net creating reports from objects

I wish to create reports (mainly PDF) from my business entity objects. The features I would like are:

  1. Be able to define the report template in a designer
  2. Be able to bind the report to a collection of business objects at run-time.
  3. Export the report as PDF, Excel, (other formats such as XML, etc would be a bonus).

One such product is the ReportViewer that comes as part of Visual Studio. But I was wondering what other products were out there and the reasons you decided to use them instead of the bundled ReportViewer.

like image 625
Raj Rao Avatar asked Dec 07 '25 09:12

Raj Rao


2 Answers

we are useing stimulsoft in our project,

DevExpress XtraReports is a famous reporting tool too

Also I like this open source lib for wpf reporting

like image 119
Arsen Mkrtchyan Avatar answered Dec 10 '25 14:12

Arsen Mkrtchyan


With XtraReports from DevExpress you can do this task easily:

public static XtraReport CreateReport(object data, string dataMember)
{
    XtraReport result = new XtraReport();
    result.Name "the_report_name";
    result.LoadLayout(@"c:\the_path\the_repx_template.repx");
    result.DataSource = data;
    if ( !string.IsNullOrEmpty(dataMember) ) { result.DataMember = dataMember; }
    return result;
}

Then you can use one of the following methods for exporting your report to the desired format (apply to XtraReport class):

public void ExportToPdf(string path);
public void ExportToRtf(string path);
public void ExportToText(string path);
public void ExportToXls(string path);
public void ExportToXlsx(string path);
public void ExportToHtml(string path);
public void ExportToCsv(string path);
public void ExportToImage(string path, ImageFormat format);

I have commented about this at: Alternative to Excel as ASP.Net Report Generator

like image 39
ArBR Avatar answered Dec 10 '25 13:12

ArBR



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!