The following in tcl should do what you want:
} - on_submit {
ReturnHeadersNoCache "application/vnd.ms-excel" $filename
db_foreach .... {
ns_write $first_column\t$second_column\n
}
ad_script_abort
}
ReturnHeadersNoCache is deprecated, but gives you the content_type and filename support.
Having the Excel sheet show up in the browser automatically, or having the option to save to file is a user-specific option.