Export data to Excel in Dynamics NAV with Column captions using XML port

Introduction:

With the help of XML port, it is possible to import and export data in Dynamics NAV. While exporting data to an Excel sheet, we always have a requirement to export data along with the column captions to an excel sheet.

In this blog article, I will be explaining the procedure to achieve the same.

Pre-requisite:

Microsoft Dynamics NAV 2017

Procedure:

  1. Enter a node name. I have entered my node name as ‘Root’ with Node Type as ‘Element’ and Source Type as ‘Text’.

  1. For the caption names, first create a node with Node Type as ‘Element’ and Source Type as ‘Table’. Enter the Data Source as ‘Integer’ which is a virtual table in Dynamics NAV.

  1. Now enter a node name for your first caption name. In this example, I have entered ‘VINTitle’ as my first column caption name with Node Type as ‘Element’ and Source Type as ‘Text’.

  1. Go to C/AL code of ‘VINTitle’ which is my first node name and in ‘OnBeforePassVariable()’ write the code for the caption name that should appear in the Excel sheet when data is exported.This will display the name of the field which is entered in the table or you can also manually assign the name of the caption that should appear in the Excel sheet after exporting data as shown below.

  2. After the caption name is mentioned, now you have to enter the value which should be fetched from the table and appear in the Excel sheet.
  3. Enter the node name for your table with ‘Node Type’ as ‘Element’ and Source Type as ‘Table’. Enter your Data source. In this I have taken ‘Item’ as my Data source and the field ‘No.’ of Item table.

Conclusion:

After exporting data to an Excel sheet, the column captions appear in it along with the values of the column.

 


Share Story :

SEARCH BLOGS :

FOLLOW CLOUDFRONTS BLOG :


Secured By miniOrange