Monsieur Winner

MS D365FO || Monsieur D365FO

Technical

Using Microsoft.Office.Interop.Excel x++ (D365FO)

Dynamics 365 Finance & Operations fully integrates with Office 365, thus we can easily export data to Excel. However, there are financial computations that can be done using excel function such as calculating the coupon receivable of an Investment, or getting the yield value of a Bond investment.  Such can be achieved after data has been exported from D365FO.

As a developer, we can write X++ function to export data to excel Using Microsoft.Office.Interop.Excel

using System.IO;
using System.IO.FileMode;
using System.IO.File;
using OfficeOpenXml;
using OfficeOpenXml.Style;
using OfficeOpenXml.Table;
using Microsoft.Office.Interop.Excel;
using OfficeOpenXml.ExcelPackage;
using Microsoft.Office.Tools;
using Microsoft.Office.Tools.Excel;

class IOInvestmentBONDPostingDateDelete extends RunBaseBatch
{
    QueryRun            queryRun;
    DialogField         dialogReportDate,dialogvoucher, dialogOrderId ;
    DatePhysical        reportDate;
    IOInvestmentFund    _fund;
    IOInvestmentOrderId OrderId;
    Voucher voucher;


    #DEFINE.CurrentVersion(1)
....................................................
....................................................

}

The Microsoft.Office.Interop.Excel  needs to be added as reference. 

Right click on the X++ Project and add reference; in the .NET section, select Microsoft.Office.Interop.Excel; else, you might end up with the error :

The type or namespace name ‘Microsoft.Office.Interop.Excel’ could not be found (are you missing a using directive or an assembly reference?)

Add the reference

In the .NET tab, select the reference. If you could not find the reference download it microsoft.office.interop.excel.dll free download | DLL‑files.com (dll-files.com) and copy the DLL to C:\Windows\Microsoft.NET\Framework\v2.0.xxxxx

 

Komi Siabi

Komi Siabi is a Bilingual D365FO Solution architect who loves sharing his knowledge as he works on Both Francophone and Anglophone projects around the globe. He enjoys doing some tiktok videos in his leisure time.

0 thoughts on “Using Microsoft.Office.Interop.Excel x++ (D365FO)

  • Your comment is awaiting moderation.

    Thanks for your help and for writing this post. It’s been great.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *