The downloadHandler() output function is what you need. Its help page has an example. To create the Excel file, you could use the xlsx or openxlsx package. Alternatively, you could save the data in a .csv file; the default program for that extension on Windows is Excel.