>Thank, Antonio, looks like what I may need. Also, the column names seem to be with spaces in them - I'm guessing can we just convert to Excel with memos and pre-defined headers?
Naomi,
You can set the name of the columns and also filter out which fields from the source table / data are to be exported.
Here it is a revised example. The CSV columns now have names of their own that do not have to be related to the cursor fields names, and if any of these is not mapped then it won't appear in the output.
The result is attached, also.
DO LOCFILE("csv.prg")
CREATE CURSOR SourceWithMemos (Identifier Integer, NotUsedField Integer, NameField Varchar(32), MemoField Memo)
INSERT INTO SourceWithMemos VALUES (1, 0, "Joseph", "Some data." + CHR(13) + CHR(10) + "In many lines.")
INSERT INTO SourceWithMemos VALUES (2, 255, "Mary", "Will it be inserted into Excel?" + CHR(13) + CHR(10) + "We're about to see!")
LOCAL CSV AS CSVProcessor
m.CSV = CREATEOBJECT("CSVProcessor")
m.CSV.Workarea = "SourceWithMemos"
m.CSV.ValueSeparator = ";"
m.CSV.FieldMapping.Add("Identifier", "Identifier")
m.CSV.FieldMapping.Add("MemoField", "Memo column")
m.CSV.FieldMapping.Add("NameField", "Name column")
m.CSV.Export("SourceWithMemos.csv", .T.)
>
>The other complication is the extraction of the data itself - I will need to figure the DB out as well as how to get all the needed info properly. I was hoping it would not be too complicated, but looks like it's going to be :(
A final note: the order of the CSV columns does not have to follow the source (in the example, "NameField" and "MemoField" swapped their positions). If you have a target specification, this may be helpful to your case.
----------------------------------
António Tavares Lopes