web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
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 1,288

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

    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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

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

#1
Martin Dráb Profile Picture

Martin Dráb 539 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 431 Super User 2026 Season 2

#3
CU-1234529-002 Profile Picture

CU-1234529-002 184

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans