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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Set Borders and outline borders in Excel

(0) ShareShare
ReportReport
Posted on by

Hi all,

How to set the borders in excel sheet using x++ code,please help me

Thanks,

Arun joseph A

*This post is locked for comments

I have the same question (0)
  • Muhammad Afsar Khan Profile Picture
    2,676 on at

    I wanted the same in my past tasks but based on my research at that time there is no method available in AX API to do the same, instead you may use COM class object to do it.

    The other workaround of your issue is to create excel template having all your decorations like border cell and etc and place it on shared location, at the time of excel export, you can simply read that excel template, fill your desired data and excel.saveAs() with new name.

    -Afsar

  • Suggested answer
    Community Member Profile Picture
    on at

    consider using SysExcelWorksheetHelper class

    find more information over here

    msdn.microsoft.com/.../sysexcelworksheethelper.aspx

    Please verify and update us with your findings

  • Suggested answer
    André Arnaud de Calavon Profile Picture
    300,904 Super User 2025 Season 2 on at

    HI Arun,

    The methods to perform this task are not standard imlemented in AX. All Excel implementations in AX is all based on a ComObject. It is possible to create your own Excel methods and classes in AX to expand the current Excel features.

    In the past I used the object explorer in Excel VBA. If the method is not supported in AX out of the box, you can record a macro in excel. perform this steps manually and in VBA you can see which objects are used. Then you can use the common comobject or write your own methods/classes.

    In AX2012 You can see how a border is used when running a financial statement and save it as excel file.

    The class which is being used here (LedgerBalanceSheetDimPrintExcelEngine) contains some logic to use borders.

  • Community Member Profile Picture
    on at

    Hi André Arnaud de Calavon,

    I had export the ventor transaction details in excel sheet with button click but need to arrage line borders in that excel.

    please send the code

    Thanks ,

    Arun

  • André Arnaud de Calavon Profile Picture
    300,904 Super User 2025 Season 2 on at

    Hi Arun,

    I don't have coding available. You can look at the example as mentioned iin my previous reply. Otherwise you can add the SysExcel framework. I did this in the past in an AX 4.0 version.

  • Community Member Profile Picture
    on at

    Hi André Arnaud de Calavon,

    I try to do more ways but i din't get any solution..If u know any idea ..please share me ..

    Thanks ,

    Arun

  • Verified answer
    Community Member Profile Picture
    on at

    Hi all ,

    I found the solution for to set excel borders and lines , we are using COM class to design the borders and lines in excel sheet :

    sample code :

    COM                         cellCOM;

       COM                         borders, border;

       ComVariant                  borderType = new COMVariant();

       ComVariant                  lineType =   new COMVariant();

       #define.xlEdgeBottom(8) // Line alignment

       #define.xlContinuous(7) // FOR DARKNESS

       #define.xlEdgeLeft(2)

       #define.xlEdgeRight(4)

       cell = cells.item(4, 1);

       cellCOM = cell.comObject();

       borderType.int(#xlEdgeBottom);

       borders = cellCOM.borders();

       border = borders.item(borderType);

       lineType.int(#xlContinuous);

       border.lineStyle(lineType);

       cell = cells.item(2, 10);

       cellCOM = cell.comObject();

       borderType.int(#xlEdgeLeft);

       borders = cellCOM.borders();

       border = borders.item(borderType);

       lineType.int(#xlContinuous);

       border.lineStyle(lineType);

    this the solution for set borders and lines in excel sheet using x++ code

  • André Arnaud de Calavon Profile Picture
    300,904 Super User 2025 Season 2 on at

    Hi Arun,

    Congratulations! Well done. I did similar in the past, but implemented these COM objects in new Excel classes and then used these.

    If you update one or more replies as answer, this this thread will be marked as answered. Other persons with the same question then knows they can find the solution in this thread.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans