Hi Candy,
if it has to be dynamic then you might want to look at the demonstration report "Order Report" and look at the "Generic List" example.
This report prompts the user with a dynamic dialog showing all fields in the report and lets him choose fields that should appear in the report.
Internally the template mechanism is used to create a list report containing these fields.
The Excel output of this report should suit your needs.
The relevant code snippet from OrderReport.4gl is this:
IF filename == "Generic List.4rp" THEN
IF NOT fgl_report_loadCurrentSettings(NULL) THEN #note that no .4rp design file is needed
EXIT PROGRAM
END IF
CALL promptForFieldsToPrint("OrderReport.rdd","report_all_orders") RETURNING retval,fieldNames
IF NOT retval THEN
RETURN NULL
END IF
CALL fgl_report_setAutoformatType("FLAT LIST") #enables generic reports
CALL fgl_report_configureAutoformatOutput(NULL,8,NULL,"Order List",fieldNames,NULL)
CALL fgl_report_configurePageSize("a4length","a4width")
CALL fgl_report_configureXLSDevice(NULL,NULL,FALSE,NULL,NULL,NULL,TRUE) #preserve spaces and merge pages in XLS output
CALL fgl_report_setTitle("Order List")
Note that the only requirement is an .rdd file compiled from your report source. You don't need a .4rp design file.
You can use GenerateReport but this is simpler (it uses the template mechanism internally and discards the .4rp after the run)
Best regards,
Alex