How tos
How To export column headings in a dataport?
- Author
- Luc Van Dyck
- Date
- 02/09/2004
- Size
- 2,96 KB
- Downloads
-
3153
Detailed statistics
- Downloads today 0
- 30 day downloads 12
- Total downloads 3153
- Overall download rank #231 / 2083
- Today page views 0
- 30 days page views 9
- Total views 20343
- Rating
- Popularity
- Downloaded 6 times in the last two weeks
When exporting some data to a text-file using a dataport, it is good practice to include a line with the column headings. When the
textfile is imported in Excel, the user can easily use the AutoFilter feature of Excel to inspect the data.
In this How To, we are going to export the Item table with following fields: No., Description, Base Unit of Measure, Unit Price.
Steps to create the dataport
Running this dataport will result in a text file, with following layout:
Importing this text file into Excel, and using AutoFilter, results in this view:
- Create a new dataport using the Object Designer.
We are creating a CSV-file, so the default properties of the dataport can be used. The only property that needs modification is the DataItemSeparator: to prevent a blank line being created between our heading and the first item, we set this property to: <NewLine>. - Insert DataItem Item.
Add the required fields in the dataport Field list. - Insert a DataItem Integer before the Item DataItem.
Make sure that this DataItem is run only once, by setting the property DataTableView to:
SORTING(Number) WHERE(Number=CONST(1)).
We select a Sort Order to prevent the DataItem from being displayed when the users starts the dataport. - In the dataport Field list for the DataItem Integer, we are going to add the names of our fields. You could use
constants for this; eg. 'No.', 'Description', 'Base Unit of Measure', 'Unit Price'. But if you are using MBS-Navision 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 are going to add
the field names like this: Item.FIELDCAPTION("No."), Item.FIELDCAPTION("Description"), etc.
If you prefer to use constants for the column heading, the screen looks like this:
Running this dataport will result in a text file, with following layout:

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