我很难将 XML 流发送到客户端浏览器。我对此进行了大量研究,一切看起来都正确 - 此外,类似的代码适用于该应用程序的早期版本。有什么想法我可能做错了吗?
以下代码不会引发错误,但不会在客户端计算机上下载文件。
Public Shared Sub Export(ByVal source As DataTable)
Try
With Current.Response
Dim xml As String = CreateExcelXMLFromDataTable(source.DefaultView)
.Clear()
.Buffer = True
.ContentType = "application/vnd.ms-excel"
.AddHeader("Content-Disposition", String.Concat("attachment;filename=", "export.xlsx", ";"))
.AddHeader("Content-Length", xml.Length.ToString)
.Charset = ""
.Write(xml)
.Flush()
.Close()
End With
Catch ex As Exception
Console.WriteLine(ex.Message.ToString)
End Try
End Sub
谢谢!