› Dynamics NAV › Export data to Excel in Dynamics NAV with Column captions using XML port
Export data to Excel in Dynamics NAV with Column captions using XML port
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.
Microsoft Dynamics NAV 2017
- Enter a node name. I have entered my node name as ‘Root’ with Node Type as ‘Element’ and Source Type as ‘Text’.
- 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.
- 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’.
- 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.
- 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.
- 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.
After exporting data to an Excel sheet, the column captions appear in it along with the values of the column.
Liked it? Share it.