FastReport icon indicating copy to clipboard operation
FastReport copied to clipboard

FastReport Designer and adding datasource

Open yiwan74 opened this issue 7 years ago • 9 comments

Is it possible to add custom datasource (e.g. business object) using FastReport Community designer so I can first design report template and later in code register and use data? Is there any example how it can be achieved? Thank you

yiwan74 avatar Oct 05 '19 18:10 yiwan74

Same problem here

danilobreda avatar Oct 18 '19 13:10 danilobreda

It depends on which data source you're using. E.g., for SQL Server, you can add an MS SQL Connection in the community designer, design and test your report. Then, in your code, load the template and modify the connection

report.Report.Load(template);
report.Dictionary.Connections[0].ConnectionString = connectionString;
report.Prepare();

If you're using in memory DataSet then the quickest way is to create a simple app - a custom designer - which prepares the data set, sets it using report.RegisterData(dataSet, "ds"); and calls report.Design(). After you have saved the report template it will be compatible with your main code which will register the same data set.

Also, if you don't mind typing you can write the template manually. Something similar to the following

<Report>
<!-- other content-->
<Dictionary>
  <TableDataSource Name="invoice" ReferenceName="ds.invoice" DataType="System.Int32" Enabled="true">
      <Column Name="id" DataType="System.Int32"/>
      <!-- other columns-->
 </TableDataSource>
 <TableDataSource Name="invoiceLine" ReferenceName="ds.invoiceLine" DataType="System.Int32" Enabled="true">
      <Column Name="id" DataType="System.Int32"/>
      <Column Name="invoiceId" DataType="System.Int32"/>
      <Column Name="description" DataType="System.String"/>
      <!-- other columns-->
 </TableDataSource>
 <Relation Name="invoice_invoiceLine" ReferenceName="ds.invoice_invoiceLine" ParentDataSource="invoice" ChildDataSource="invoiceLine" ParentColumns="id" ChildColumns="invoiceId" Enabled="true"/>
</Dictionary>
<!-- other content-->
</Report>

MaximBalaganskiy avatar Nov 20 '19 03:11 MaximBalaganskiy

Did you know if I can edit this data set templates (add columns or remove columns) by the open source or demo designer? Or just manually by the code or xml as you comment?

vitorquezada avatar Dec 26 '19 12:12 vitorquezada

@vitorquezada It is best to re-register a modified data set.

Des1re7 avatar Dec 26 '19 12:12 Des1re7

I just tried to register an object by doing as you suggested:

registered the Data by

report.registerData(dataset);

but the method Design() is not known?

Any suggestions on how to import this function?

Thanks

haraldkofler avatar Apr 11 '20 19:04 haraldkofler

Hi,

FastReport OpenSource does not include Designer. It's available in FastReport .NET.

Best Regards, Oleg.

0legK avatar Nov 11 '21 12:11 0legK

Hi! U can add a dictionary with a BusinessObjectDataSource in the xml of the .frx file and will appear in the designer

ChristianRazvan avatar Jun 06 '25 08:06 ChristianRazvan

I'm sending you a test example of using the BusinessObject connection and using it in the report designer below

Application: https://drive.google.com/file/d/1qekxtTnNYi3elh_snKjY9rFOBXGYoSVJ/view?usp=sharing

Best regards, Bogdan

BogdanStg avatar Jun 06 '25 08:06 BogdanStg

I'm sending you a test example of using the BusinessObject connection and using it in the report designer below

Application: https://drive.google.com/file/d/1qekxtTnNYi3elh_snKjY9rFOBXGYoSVJ/view?usp=sharing

Best regards, Bogdan

Thanks! I will check it out

Have a nice day!

ChristianRazvan avatar Jun 06 '25 09:06 ChristianRazvan