Crystal Reports - 导出报告导致“参数值缺失”

发布于 2025-01-05 05:07:55 字数 1374 浏览 1 评论 0原文

我正在尝试导出报告,但每次运行代码以在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

你不是我要的菜∠ 2025-01-12 05:07:55

这是由两个原因造成的。
或者,您没有(从程序)传递您在报告中创建的必需参数。
或者,您正在向报表传递参数,但尚未在报表中创建它。

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.

小霸王臭丫头 2025-01-12 05:07:55

为了解决我自己的问题,我发现代码实际上导出了水晶报表的实例,而我在提供源之后将参数放入水晶报表查看器中。相反,我直接将参数提供到实例中,该实例作为数据源推送到 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.

:)

痴情 2025-01-12 05:07:55

就我而言,有一个子报告未与主报告正确链接。

检查子报表的所有参数是否与主报表链接。

干杯;

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;

万劫不复 2025-01-12 05:07:55
  1. 必须设置所需参数

  2. Set rpt.SetDataSource(dt)即使DataTable记录数为0:

     DataTable dt = new DataTable();
         dt.Load(数据);
         if (dt?.Rows!= null)
         {
           rpt.SetDataSource(dt);
           返回真;
         }
    
  1. Have to set required parameters

  2. Set rpt.SetDataSource(dt) even DataTable records count is 0:

         DataTable dt = new DataTable();
         dt.Load(data);
         if (dt?.Rows != null)
         {
           rpt.SetDataSource(dt);
           return true;
         }
    
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文