當我嘗試打開下面的代碼創建的test.xlsx時,我得到「test.xlsx無法下載」。也就是說,如果我選擇保存文件,我可以保存並打開文件。test.xlsx無法下載 - EPPlus
請讓我知道我做錯了什麼。
謝謝!
Dim pack As New ExcelPackage
Dim ws As ExcelWorksheet = pack.Workbook.Worksheets.Add("Sheet1")
Dim ms As New MemoryStream
Dim dt As New DataTable
ws.Cells(1, 1).Value = "Test"
pack.SaveAs(ms)
ms.WriteTo(Context.Response.OutputStream)
Context.Response.Clear()
Context.Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
Context.Response.AddHeader("Content-Disposition", "attachment;filename=test.xlsx")
Context.Response.StatusCode = 200
Context.Response.End()
什麼節目,你已經默認設置爲打開的.xlsx文件? – sacredfaith
MS Excel和Internet Explorer – chaltahai