|
請問如何下載ExcelPlate產生出虛擬目錄之Excel檔案? |
|
|
可以在Button_Click事件中添加如下代碼: FileInfo DownloadFile = new FileInfo("C:\\1.xls");//這裏換成excel檔的完整路徑,可以用Page.Server.MapPath(WebExcelPlate.FilePath)來取得 Response.Clear(); Response.ClearHeaders(); Response.Buffer = false; Response.ContentType = "application/octet-stream";//attachment/online Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(DownloadFile.FullName, System.Text.Encoding.UTF8).Replace('+', ' ')); Response.AppendHeader("Content-Length", DownloadFile.Length.ToString()); Response.WriteFile(DownloadFile.FullName); Response.Flush(); Response.End();
|
|
|