サーバ上にあるExcelファイルをダウンロードするサンプルです。
サンプル
例)サーバ上にあるExcel「C:¥hoge.xlsx」をダウンロードする
Imports System.IO
Private Sub DownloadExcel()
'Contentをクリア
Response.ClearContent()
'Contentを設定
Response.ContentEncoding = System.Text.Encoding.GetEncoding("shift-jis")
Response.ContentType = "application/vnd.ms-excel"
'表示ファイル名を指定
Dim fn As String = HttpUtility.UrlEncode("サンプル.xlsx")
Response.AddHeader("Content-Disposition", "attachment;filename=" + fn)
'ダウンロード対象ファイルを指定
Response.WriteFile("C:¥hoge.xlsx")
'ダウンロード実行
Response.Flush()
Response.End()
End Sub