我正在使用下面的代码将数据表中的记录导出到使用 EPPlus 的 excel 文件中。
Dim excelPackage = New ExcelPackage
Dim excelWorksheet = excelPackage.Workbook.Worksheets.Add("DemoPage")
excelWorksheet.Cells("A1").LoadFromDataTable(dt, True)
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
Response.AddHeader("content-disposition", "attachment; filename=ExcelDemo.xlsx")
Response.BinaryWrite(excelPackage.GetAsByteArray())
Response.End()
但是,在遍历代码块之后,在 Response.End(),我得到一个异常{Property evaluation failed.}
更新:
错误日志是:
ERROR: System.Threading.ThreadAbortException: Thread was being aborted.
at System.Threading.Thread.AbortInternal()
at System.Threading.Thread.Abort(Object stateInfo)
at System.Web.HttpResponse.End()
at Reporting.Page_Load(Object sender, EventArgs e) in C:\Reporting.aspx.vb:line 38
知道是什么原因造成的吗?