错误显示pdf CrystalReport vb.net
发布时间:2020-12-17 00:22:43 所属栏目:大数据 来源:网络整理
导读:我有下面的代码 它的功能是使用CrystalReports从屏幕上的报表加载数据. Dim strExportFile As String strExportFile = "ReportReajustesAplicados.pdf" Dim s As System.IO.MemoryStream = relat.ExportToStream(ExportFormatType.PortableDocFormat) With H
我有下面的代码
它的功能是使用CrystalReports从屏幕上的报表加载数据. Dim strExportFile As String strExportFile = "ReportReajustesAplicados.pdf" Dim s As System.IO.MemoryStream = relat.ExportToStream(ExportFormatType.PortableDocFormat) With HttpContext.Current.Response .ClearContent() .ClearHeaders() .ContentType = "application/pdf" .AddHeader("Content-Disposition","inline; filename=" & strExportFile) .BinaryWrite(s.ToArray) .End() End With 当我提取数据时. 我有以下错误 无法将类型为“FileStreamDeleteOnClose”的对象强制转换为“System.IO.MemoryStream”. 我尝试使用System.IO.Stream,提取工作,但不显示屏幕上的数据,因为“.BinaryWrite(s.ToArray)”不接受方法ToArray. 注意:我放的时候 #if DEBUG Then CrystalReportViewer1.ReportSource = relat CrystalReportViewer1.DataBind () Exit Sub If #End 作品 我需要这个工作,但在发布模式下. 帮我
我找到了解决方案:
https://archive.sap.com/discussions/thread/3322762 正如SAP回答的那样: 所以解决方案是用Stream替换MemoryStream并将其发送到Byte数组中,如下所示: Dim strExportFile As String strExportFile = "ReportReajustesAplicados.pdf" Dim s As System.IO.Stream = relat.ExportToStream(ExportFormatType.PortableDocFormat) Dim b(s.Length) As Byte s.Read(b,CInt(s.Length)) With HttpContext.Current.Response .ClearContent() .ClearHeaders() .ContentType = "application/pdf" .AddHeader("Content-Disposition","inline; filename=" & strExportFile) .BinaryWrite(b) .Flush() .SuppressContent = True HttpContext.Current.ApplicationInstance.CompleteRequest() End With (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |