Crystal Reports - 导出报告导致“参数值缺失”
我正在尝试导出报告,但每次运行代码以在 crystalreportviewer 中导出水晶报告时,我都会收到一条错误消息,提示“缺少参数值”。我查看了很多来源但没有找到解决方案。我确实知道所有参数都已填写,因为没有导出代码,该网站运行得很好。
导出代码
Try
Dim CrExportOptions As CrystalDecisions.Shared.ExportOptions
Dim CrDiskFileDestinationOptions As New _
CrystalDecisions.Shared.DiskFileDestinationOptions()
Dim CrFormatTypeOptions As New CrystalDecisions.Shared.PdfRtfWordFormatOptions()
CrDiskFileDestinationOptions.DiskFileName = _
"c:\crystalExport.pdf"
CrExportOptions = oRpt.ExportOptions
With CrExportOptions
.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile
.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat
.DestinationOptions = CrDiskFileDestinationOptions
.FormatOptions = CrFormatTypeOptions
End With
oRpt.Export()
Catch ex As Exception
Response.Write(ex.ToString)
End Try
另外:
'Try
' oRpt.ExportToHttpResponse([Shared].ExportFormatType.PortableDocFormat, Response, True, "ExportedReport")
'Catch ex As Exception
' Response.Write(ex.ToString)
'End Try
任何帮助都会很棒。
I am trying to export a report but everytime it runs the code to export the crystal report in the crystalreportviewer I get an error message saying "Missing Parameter Values". I've looked through many sources but havent found a solution. I do know that all parameters are filled in because without the export code, the site runs perfectly fine.
Export code
Try
Dim CrExportOptions As CrystalDecisions.Shared.ExportOptions
Dim CrDiskFileDestinationOptions As New _
CrystalDecisions.Shared.DiskFileDestinationOptions()
Dim CrFormatTypeOptions As New CrystalDecisions.Shared.PdfRtfWordFormatOptions()
CrDiskFileDestinationOptions.DiskFileName = _
"c:\crystalExport.pdf"
CrExportOptions = oRpt.ExportOptions
With CrExportOptions
.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile
.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat
.DestinationOptions = CrDiskFileDestinationOptions
.FormatOptions = CrFormatTypeOptions
End With
oRpt.Export()
Catch ex As Exception
Response.Write(ex.ToString)
End Try
Also:
'Try
' oRpt.ExportToHttpResponse([Shared].ExportFormatType.PortableDocFormat, Response, True, "ExportedReport")
'Catch ex As Exception
' Response.Write(ex.ToString)
'End Try
Any help would be great.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这是由两个原因造成的。
或者,您没有(从程序)传递您在报告中创建的必需参数。
或者,您正在向报表传递参数,但尚未在报表中创建它。
This is caused under 2 reasons.
Either, you're not passing(from the program) a required parameter which you have created in the report.
Or, you're passing a parameter to the report but you haven't created it in the report.
为了解决我自己的问题,我发现代码实际上导出了水晶报表的实例,而我在提供源之后将参数放入水晶报表查看器中。相反,我直接将参数提供到实例中,该实例作为数据源推送到 crystalreportviewer 中。
:)
To solve my own problem I found that the code actually exports the instance of the crystal report, whereas I was putting the parameters into the crystalreportviewer after providing the source. Instead I provided the parameters directly into the instance which gets pushed into the crystalreportviewer as a datasource.
:)
就我而言,有一个子报告未与主报告正确链接。
检查子报表的所有参数是否与主报表链接。
干杯;
In my case, there was a subreport that was not correctly linked with the main report.
Check if all the parameters of the subreport is linked with the main report.
Cheers;
必须设置所需参数
Set rpt.SetDataSource(dt)即使DataTable记录数为0:
Have to set required parameters
Set rpt.SetDataSource(dt) even DataTable records count is 0: