Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

adding columns dynamically to the excel template

(0) ShareShare
ReportReport
Posted on by 795

Hello everyone,

I'm trying to develop a report based on the excel template. I use standard class XMLExcelReport_RU. I need to do one unusual thing I didn't before. I have created a temporary table with the info I'll need in my report. It contains records with the date field. Some records will contain the same value for the date field. I need somehow add columns with unique dates from the temporary table.

this is the code where I fill up my temporary table:

protected void createReport()
{
    int i = 1;
    this.initSectionMap();

    this.execute(#HEADER);
    
    while(qr.next())
    {
        smmActivityParentLinkTable = qr.get(tableNum(SMMActivityParentLinkTable));
        smmActivities              = qr.get(tableNum(smmActivities));
        tsTimeSheetLine            = qr.get(tableNum(tsTimeSheetLine));
        tsTimesheetLineWeek        = qr.get(tableNum(tsTimesheetLineWeek));
        
        
        for (i=1; i<=7; i =1)
        {
            if(tsTimesheetLineWeek.Hours[i])
            {
                taskDaysFactTmp_ICL.ActivityType        = smmActivities.ICLPRJDevTaskActivityType;
                taskDaysFactTmp_ICL.ResponsibleWorker   = HcmWorker::worker2Name(smmActivities.ResponsibleWorker);
                taskDaysFactTmp_ICL.ActivityDate = tsTimesheetLineWeek.DayFrom   (i-1);    
                taskDaysFactTmp_ICL.Hours = tsTimesheetLineWeek.Hours[i]; 
            }
        }
        
        taskDaysFactTmp_ICL.insert();
    }
        
    this.execute(#PageHeader);
    this.execute(#Body);
}

#PageHeader section in my template  will contain dynamic columns with unique dates from temporary table.

To do this I need to go through all records from my temporary table and somehow add columns to template:

protected void fillPageHeader()
{
    while select activitydate from taskDaysFactTmp_ICL
        group by taskDaysFactTmp_ICL.ActivityDate
        order by taskDaysFactTmp_ICL.ActivityDate
    {
        
    }
}

How to add columns to template with unique date fields from temporary table?

Thank you.

  • Suggested answer
    Ludwig Reinhard Profile Picture
    Microsoft Employee on at
    RE: adding columns dynamically to the excel template

    Hi,

    I wonder if Excel is the right tool for this kind of report.

    To me it looks as if a power bi based report / cube would be better suited for this purpose.

    Have you checked out the standard cubes for AX2012?

    Best regards,

    Ludwig

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 456 Most Valuable Professional

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 310

#3
Saalim Ansari Profile Picture

Saalim Ansari 261

Overall leaderboard

Product updates

Dynamics 365 release plans