Exporting Microsoft Dynamics NAV Column Headings in a Dataport

Updated: November 10, 2004

Luc Van Dyck

Microsoft Dynamics NAV Most Valuable Professional Luc Van Dyck is webmaster of the Microsoft Business Solutions online community Mibuso.com. In addition to providing helpful discussion forums and downloads, mibuso.com features a collection of tips for Microsoft Dynamics NAV developers. This page is reprinted with permission from mibuso.com.

When exporting Microsoft Dynamics NAV data to a text file using a dataport, it is good practice to include a line with the column headings. When the text file is imported in Microsoft Excel, the user can easily use the AutoFilter feature to inspect the data.

These are the steps to create the dataport:

1.

Create a new dataport using the Object Designer. Because we are creating a CSV file, the default properties of the dataport can be used. The only property that needs modification is the DataItemSeparator. To prevent a blank line from being created between our heading and the first item, we set this property to <NewLine>.

2.

Insert the Item DataItem, as shown below. Then add the required fields in the dataport Field list.

3.

Insert an Integer DataItem before the Item DataItem, as shown next. Make sure that this DataItem is run only once, by setting the DataTableView property to SORTING(Number) WHERE(Number=CONST(1)). Select a Sort Order to prevent the DataItem from being displayed when the user starts the dataport.


See full-sized image

4.

In the dataport field list for the Integer DataItem, add the names of your fields. You could use constants for this, such as No., Description, Base Unit of Measure, and Unit Price. But if you are using Microsoft Dynamics NAV 3.01 or higher, you can use the FIELDCAPTION function to retrieve the caption of the field in the language of the user. Therefore, we will add the field names like this: Item.FIELDCAPTION("No."), Item.FIELDCAPTION("Description"), and so on. The following screen shots illustrate this: 


See full-sized image

If you prefer to use constants for the column heading, the screen will look like this:


See full-sized image

Running this dataport will result in a text file, with the following layout:

Importing this text file into Microsoft Excel and using AutoFilter results in this view:


See full-sized image

Luc Van Dyck is a Microsoft Dynamics NAV Most Valuable Professional (MVP). He works as a Software Consultant for Mindstone NV in Belgium. He is also the webmaster of Mibuso.com, which provides a platform for users and developers of products from the Microsoft Dynamics family to exchange ideas, tools, and how-to's, and to find business partners and products.

© mibuso.com. All rights reserved. October 2004



Was this information useful?