Report generation using custom templates

432
10
Jump to solution
2 weeks ago
RITASHKOUL
New Contributor III

 

Hi,

I am working on report generation from custom templates using ArcGIS Pro SDK. I have created a custom template .rptt file and added that template in some path. I have added attributes table data in the Page Header and Details section of the custom template. Also I have added some data in the Report Header. Now using below code I am trying to generate the report:

var reportTemplates = await ReportTemplateManager.GetCustomTemplatesAsync(templatePath);
var reportTemplate = reportTemplates.First(r => r.Name == templateName);
var reportFields = new List<CIMReportField>(); // added all the fields in this list.

var reportDataSource = new ReportDataSource(mapMember, "", false, reportFields);
var report = ReportFactory.Instance.CreateReport(reportName, reportDataSource, null, null, reportTemplate, "");

var mainReportSection = report.Elements.OfType<ReportSection>().FirstOrDefault();
var reportHeader = mainReportSection.Elements.OfType<ReportHeader>().FirstOrDefault();
reportHeader.Elements // data is removed here, not able to see data that was defined or added in the ReportHeader of custom template.
 

Now the problem is ReportHeader section defined in my custom template is getting removed.

But if I am using ArcGIS Pro report tool to generate the report from that custom template, it is retaining the ReportHeader content of the custom template.

It seems that Pro’s report API is not even using the custom template but creating a report from scratch.

My MapMember is a standalone table.

Any problem in the above SDK code?

@GKmieliauskas @Wolf @UmaHarano @NarelleChedzey @CharlesMacleod 

Tags (1)
0 Kudos
10 Replies
RITASHKOUL
New Contributor III

@UmaHarano One workaround that worked is adding our custom templates in the default templates path. 

For attribute type templates it is working but problem that is coming is when custom template is like Pro’s page per feature template. What I am seeing whenever I am creating report from default page per feature template first field will always be in top in the details section. But when I am creating my own template like page per feature template and adding the field, first field always gets added at the bottom in the details section in the reports content pane. And when report is generated from that template first field value goes into the last field and last goes to the first field. What is the way to bind to the exact field when creating our own report? I tried field order but didn’t  worked.

0 Kudos