Page 1 of 1
mrt generated file different than designer view
Posted: Fri Dec 16, 2022 11:56 am
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
Re: mrt generated file different than designer view
Posted: Fri Dec 16, 2022 12:17 pm
by Max Shamanov
Hello,
We need some additional time to investigate the issue, we will let you know about the result.
Thank you.
Re: mrt generated file different than designer view
Posted: Wed Dec 21, 2022 9:44 am
by custodian
Any news about this?
Re: mrt generated file different than designer view
Posted: Wed Dec 21, 2022 10:20 am
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.
Re: mrt generated file different than designer view
Posted: Wed Dec 21, 2022 1:46 pm
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
Re: mrt generated file different than designer view
Posted: Thu Dec 22, 2022 1:54 pm
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.