basic dataport

i have set up a dataport, that just exports the data to a csv file. this works fine, however, i would like to have the headings also - so that this is also in the csv file. i have looked but cant see how to export the headings to! thanks

I would do macro in Excel

What I have done previously (it isn’t pretty by any stretch) is to write out a string containing the formatted Column names to the Currdataport.filename in the OnBeforeExport Trigger. The column names are usually hardcoded, but that way I can call them what I want. Since most of my dataport extracts are delimited, I just concatenate my column names with a tab and write them out, followed by a CRLF. There probably is a better way, but this works in a pinch and will at least get the discussion started:)

I’ve done this once or twice and what I did was (feel free to disagree [:)]) a little more flexible. Let’s suppose you are exporting data from the Customer table. More precisely, the fields “No.”,“Name” and “Phone No.”. Create a new DataItem - Integer - above your already existing Customer DataItem. Integer is a “special” virtual table that lists all the possible integer numbers from -1.000.000.000 to 1.000.000.000. Since we wouldn’t want the Dataport to run through all these numbers [xx(], set the DataItemTableView property Integer to SORTING(Number) WHERE(Number=CONST(1)). That will make sure you only loop once. Now we can use this newly created DataItem to output our headings. On the “Dataport Fields” for Integer, insert the following SourceExpr’s: Customer.FIELDCAPTION(“No.”) Customer.FIELDCAPTION(Name) Customer.FIELDCAPTION(“Phone No.”) Granted, it is also not that pretty… you have to carefully check if the field order is the same as your main DataItem. If you need to change the fields for the Customer table, make sure you change the header in Integer, etc. But since there is no simple option to include headers, I believe this to be the least painful way of doing it.

Just a short remark. Next time post topics similar to this one in the Developer forum. You will get a much better audience for these type of questions.

quote:


Originally posted by nelson
Just a short remark. Next time post topics similar to this one in the Developer forum. You will get a much better audience for these type of questions.


ok will do!! thought it would be an easy thing to do :wink: i think the excel macro version seems easier!! thanks all