mrt generated file different than designer view

Stimulsoft Reports.NET discussion
Post Reply
User avatar
custodian
Posts: 12
Joined: Wed Nov 23, 2022 11:34 am

mrt generated file different than designer view

Post by custodian »

Hello,

When I generate the report using .NET Engine (v 2022.4.5) the pdf is not ok, when I check with designer it is. I think that it doesnt take relation created in databand of subreport.

var report = new StiReport();
report.Load("e:\\MonthlyPreventive.mrt")
var dataSet = StiJsonToDataSetConverterV2.GetDataSetFromFile("C:\\newdata.json")
report.RegData("dataSet", dataSet);
report.Dictionary.DataSources.Clear();
report.Dictionary.Synchronize();
report.Dictionary.Connect();
report.Render(false);
report.ExportDocument(StiExportFormat.Pdf, "C:\\report.pdf")

I have attached files
Attachments
newdata.json
(872.24 KiB) Downloaded 87 times
MonthlyPreventive.mrt
(2.95 MiB) Downloaded 92 times
generatemrt.jpg
generatemrt.jpg (292.36 KiB) Viewed 866 times
designer.jpg
designer.jpg (168.5 KiB) Viewed 866 times
Max Shamanov
Posts: 786
Joined: Tue Sep 07, 2021 10:11 am

Re: mrt generated file different than designer view

Post by Max Shamanov »

Hello,

We need some additional time to investigate the issue, we will let you know about the result.

Thank you.
User avatar
custodian
Posts: 12
Joined: Wed Nov 23, 2022 11:34 am

Re: mrt generated file different than designer view

Post by custodian »

Any news about this?
Max Shamanov
Posts: 786
Joined: Tue Sep 07, 2021 10:11 am

Re: mrt generated file different than designer view

Post by Max Shamanov »

Hello,

Please use the following code :

Code: Select all

var report = new StiReport();
report.Load("e:\\MonthlyPreventive.mrt")
var dataSet = StiJsonToDataSetConverterV2.GetDataSetFromFile("C:\\newdata.json")
report.RegData("dataSet", dataSet);
//report.Dictionary.DataSources.Clear();
report.Dictionary.Synchronize();
report.Dictionary.Connect();
report.Render(false);
report.ExportDocument(StiExportFormat.Pdf, "C:\\report.pdf")
Thank you.
User avatar
custodian
Posts: 12
Joined: Wed Nov 23, 2022 11:34 am

Re: mrt generated file different than designer view

Post by custodian »

Dear support,

If this line is commented
report.Dictionary.DataSources.Clear();
the format is ok but the report is created using data stored in the template "MonthlyPreventive.mrt", but not with data saved in "newdata.json" which is the objective.
Could you please provide other solution?

Thank you
Max Shamanov
Posts: 786
Joined: Tue Sep 07, 2021 10:11 am

Re: mrt generated file different than designer view

Post by Max Shamanov »

Hello,

If you want to use new data from "newdata.json" you also need to create a new relation between two tabels,
which was created separately and used in the databand. Please check the attached images.

You can use the following code:

Code: Select all

var report = new StiReport();
            report.Load("..\\Reports\\MonthlyPreventive.mrt");
            var dataSet = StiJsonToDataSetConverterV2.GetDataSetFromFile("D:\\newdata.json");
            report.Dictionary.DataSources.Clear();
            report.RegData("dataSet", dataSet);
            report.Dictionary.Synchronize();
            var relation = new Stimulsoft.Report.Dictionary.StiDataRelation("Relation", "Name", "Name", report.Dictionary.DataSources["actSummary_PerActivity_OverviewPeriod"], report.Dictionary.DataSources["actSummary_PerActivity_ReportPeriod"], new string[] {
                        "ActivityId"}, new string[] {
                        "ActivityId"}); 
            report.Dictionary.Relations.Add(relation);

            //report.Dictionary.Connect();
            report.Render(false);
            report.ExportDocument(StiExportFormat.Pdf, "D:\\report.pdf");
Thank you.
Attachments
Designer_m9uFeY7t51.png
Designer_m9uFeY7t51.png (44.96 KiB) Viewed 807 times
Post Reply