Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Unanswered

How to use "Group" and COM objects using X++ in D365 FO ?

(0) ShareShare
ReportReport
Posted on by 5

HI All, 

I am retrieving a BOM Designer in Tree structure form, in to excel using X++ In D365, 

I want to Group the Cell using COM objects as we used in AX: 

Sample code of AX 4.0 

Code 1 : 

comRange = worksheetBOM.range(strfmt("%3%1:%4%2", rowLocal,row,'@SYS30306', '@SYS75441')).comObject();
comRange.select();
comSelection = comApplication.selection();
comRows = comSelection.rows();
comRows.group();

Code 2: 

comRange = worksheetBOM.range(strfmt("%3%1:%4%2", 1,1,'@SYS30306', '@SYS30306')).comObject();
comRange.select();
worksheetBOM.columns().autoFit();

How I can re-write above lines for D365 FO. 

Desired Output 

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,965 Super User 2025 Season 1 on at
    RE: How to use "Group" and COM objects using X++ in D365 FO ?

    Hi Pravin,

    Thanks for the clarification. I would then suggest searching for the commands and examples on the internet. When you need to call specific Excel features, you can also consider using the Office forum.

    With a quick search, I was able to find a post related to grouping: [Solved] How to Group the Rows n a Excel using OpenXML SDK - CodeProject

  • Pravin Profile Picture
    Pravin 5 on at
    RE: How to use "Group" and COM objects using X++ in D365 FO ?

    Hi Andre,

    Thank you for your reply,

    As I already Used same link to create the Export Excel using OfficeOpenXML Library.

    which gives me a expected output that I am looking for, But 

    I am looking for the solution for "Group", "Range" and "Selection" of the cell in Excel file using X++ which give me output of Tree node  in Excel file as screenshot attached Above.

    Regards,

    Pravin

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,965 Super User 2025 Season 1 on at
    RE: How to use "Group" and COM objects using X++ in D365 FO ?

    Hi Pravin,

    You can't use the COM objects anymore as we now have a cloud based solution which is not aware of any installed Office product. You can use OfficeOpenXML to create and work with Excel files. An example can be found here:  How to Create and Export Excel Files using X++ in D365 FO (d365snippets.com)

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 Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,965 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,817 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans