Report generation using custom templates

428
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
1 Solution

Accepted Solutions
RITASHKOUL
New Contributor III

@UmaHarano  What is the plan for supporting this? And any workaround since in our use case besides attribute list like structure we needed different formats as well? Also default templates have problem of not wrapping the content if it is too long and also list of fields gets truncated if added too many fields. Please let me know.

View solution in original post

10 Replies
RITASHKOUL
New Contributor III

Is there anyone that can help on this since this is a priority issue we are facing? @Wolf @UmaHarano @GKmieliauskas  @NarelleChedzey @CharlesMacleod 

0 Kudos
UmaHarano
Esri Regular Contributor

@RITASHKOUL 

I am trying to repro your issue with the custom template - and to create a report view from this template that uses a standalone table.  

Can you please give me some info on what data you are adding to the Report Header?

Some code snippet and images to explain would be good too so I can repro the issue.

 

Thanks!

Uma

0 Kudos
RITASHKOUL
New Contributor III

@UmaHarano I have created a report that contains some fields in the PageHeader and Details section from my source which is a standalone table. I have also added some dynamic text in the ReportHeader like ExportedDate, Page Number and also some static text. From share tab I then created a ReportTemplate an rptt file out of that report and saved in some folder. 

Now using the sdk code present in the actual question I created ReportDataSource using the standalone table and list of fields. Then created the Report using the same data source and the custom report template.

But the report that is being generated doesn't have the ReportHeader section and list of fields that are present in the custom template. ReportHeader element that is present in that new report is just one element which is the report name. But if I will use the same custom template using the Pro’s report creation tool it is working perfectly fine.

Let me know if you need anything. I think just some fields(in Details section) and some dynamic and static text in ReportHeader section and then through the Share tab save that report as a report template will be enough. We can then use the sdk code and the custom report template to check the new report.

This is my data:

RITASHKOUL_0-1720111860695.png

This is my report structure:

RITASHKOUL_1-1720112015668.png

I saved this as report template:

RITASHKOUL_2-1720112074774.png

I fetched the correct custom report template but after creating the new report, the ReportHeader section is gone and its just one element. But it should be three: DateExported, PageNumber(Dynamic texts) and Welcome(static text)

RITASHKOUL_3-1720112579051.png

RITASHKOUL_1-1720113078301.png

This is the new report that is being generated. As you can see, now only one element in the ReportHeader is present named same as the Report name and all the ReportHeader elements defined in the custom template are gone. If you will closely see the fields as well they are same but the structure (spacing) is different. Since in custom template I defined my own spacing but when report was created from sdk it took some default spacing between fields.

Code snippet is same as in the original question or what is provided in the sdk’s code snippet in the git repo. 

0 Kudos
UmaHarano
Esri Regular Contributor

Thanks for the detailed explanation. I see the same behavior. Thanks for reporting this one.

I will post back if I can provide a workaround.

RITASHKOUL
New Contributor III

@UmaHarano Thanks. Any workaround for this will be hugely appreciated.

0 Kudos
UmaHarano
Esri Regular Contributor

@RITASHKOUL After speaking with the Reports dev team, CreateReport method does not currently support "Custom Report Templates". 

0 Kudos
RITASHKOUL
New Contributor III

@UmaHarano  What is the plan for supporting this? And any workaround since in our use case besides attribute list like structure we needed different formats as well? Also default templates have problem of not wrapping the content if it is too long and also list of fields gets truncated if added too many fields. Please let me know.

RITASHKOUL
New Contributor III

Hey @UmaHarano let me know if we can do something around it. So that we can support different formats with no wrapping issues.

0 Kudos
UmaHarano
Esri Regular Contributor

Hi @RITASHKOUL 

I afraid there is no easy workaround for this at this time. I will follow-up as soon as I have a timeline when this will be supported.

Thanks!

Uma

0 Kudos