Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FastReport open source object data source

Tags:

fastreport

I try to use FastReport open source to build reports from data I'll provide to the report.

I've found what I want in the demos (https://github.com/FastReports/FastReport/tree/master/Demos/OpenSource/DataFromBusinessObject/DataFromBusinessObject)

In this demo, I see in the report file that a BusinessObjectDataSourceis used, which seems to be what I want to use.

However, I don't see a way to add this kind of source in the community designer. Do I need to add all of this manually ? Or is there a way to generate the needed markup ? I can't find the solution on their site.

like image 540
Shimrod Avatar asked Sep 12 '26 08:09

Shimrod


2 Answers

I found a way to generate an empty report with the fields generated from a business object. You only have to create an empty report object, call "RegisterBusinessObject()" on its Dictionary property, and then save the report itself:

var report = new Report();
report.Dictionary.RegisterBusinessObject(
              new List<Invoice>(), // a (empty) list of objects
              "Invoices",          // name of dataset
              2,                   // depth of navigation into properties
              true                 // enable data source
       );
report.save(@"invoiceReport.frx");

You still need to update the report description if your object changes, but at least you don't have to code it by hand!

like image 104
Pierangelo Dal Maso Avatar answered Sep 18 '26 00:09

Pierangelo Dal Maso


I found a way by making the needed xml by hand like this:

<BusinessObjectDataSource Name="Invoices" ReferenceName="Invoices" Enabled="true">
  <Column Name="Reference" DataType="System.String"/>
  <Column Name="Date" DataType="System.String"/>
  <Column Name="CompanyName" DataType="System.String"/>
  <Column Name="InvoiceEmail" DataType="System.String"/>
  <Column Name="VAT" DataType="System.String"/>
  <Column Name="Street" DataType="System.String"/>
  <Column Name="Number" DataType="System.String"/>
  <Column Name="City" DataType="System.String"/>
  <Column Name="ZipCode" DataType="System.String"/>
  <Column Name="Country" DataType="System.String"/>
  <Column Name="TotalPrice" DataType="System.Decimal"/>
  <Column Name="VATValue" DataType="System.Decimal"/>
  <Column Name="VATPercentage" DataType="System.Decimal"/>
  <Column Name="VATComment" DataType="System.String"/>
</BusinessObjectDataSource>

The only drawback is that I need to update this if my object changes (but at least is is working !)

like image 40
Shimrod Avatar answered Sep 18 '26 00:09

Shimrod



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!