問題
匯出檔案時,檔名為亂碼的問題
解決方法
string saveName = “myExcel.xls”; var savePath = AppDomain.CurrentDomain.BaseDirectory + "ExportExcel\\"; Byte[] binaryData = File.ReadAllBytes(savePath + saveName); Response.Clear(); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Expires = 0; Response.Buffer = true; Response.HeaderEncoding = System.Text.Encoding.Default;Response.ContentType = "application/octet-stream"; Response.ContentType = "application/vnd.xls"; Response.AddHeader("content-disposition", "attachment;filename=" + saveName); Response.AddHeader("Content-length", binaryData.Length.ToString()); Response.BinaryWrite(binaryData); Response.End();
沒有留言:
張貼留言