Notifications
Announcements
No record found.
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 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
consider using SysExcelWorksheetHelper class
find more information over here
msdn.microsoft.com/.../sysexcelworksheethelper.aspx
Please verify and update us with your findings
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.
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
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.
I try to do more ways but i din't get any solution..If u know any idea ..please share me ..
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);
borderType.int(#xlEdgeLeft);
this the solution for set borders and lines in excel sheet using x++ code
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 4 Most Valuable Professional
Priya_K 4
MyDynamicsNAV 2