This is the first way I would do it:
0) Send a request to the server to generate the file.
1) As mention by
F-ES Sitecore[
^], have the server generate the Excel file using the Excel ODBC driver, and save the file using a GUID for the name, such as
EE430293-3460-4251-AD14-84E4E99B6E8E.xlsx
(un-guessable and always unique).
2) Contact the client when the file is ready (providing the filename in the message)
3) The client can then transfer the file using some secure means, such as SFTP.
4) After a certain amount of time (24 hours?), the server can automatically delete the file in the interest of self-maintenance.
This way, your the server does all the work creating the file, and simply allows the client to know the filename, at which point, an actual transfer can be requested (by the client).
Another option instead of using an actual Excel file is to have the database return the result set as XML, with is an Excel-compatible format as well. That way, there's no need for ODBC at all (and it might even be faster).