【问题标题】:Crystal Reports XI PrintToPrinter "Missing parameter values"Crystal Reports XI PrintToPrinter“缺少参数值”
【发布时间】:2012-07-05 21:13:57
【问题描述】:

我正在处理 Crystal 报表(在 VB 应用程序中运行的 Crystal XI)的问题,在尝试直接打印报表时收到零星的“缺少参数值”错误。以下是问题的摘要:

  1. 用户通过报告菜单运行报告(一切正常)
  2. 用户点击“打印预览”(一切正常)
  3. 用户点击“打印”(本应将文档直接发送到打印机,但有时会出现缺少参数错误)

这是我要开始的代码:

    crystalReportViewer.MdiParent = parent
    crystalReportViewer.Show()

    Dim report As ReportDocument = CType(crystalReportViewer.ReportSource, ReportDocument)

    report.PrintToPrinter(1, False, 0, 0)
    crystalReportViewer.Close()
    crystalReportViewer.Dispose()

根据我一直在谷歌搜索的内容,我想出了以下代码:

    crystalReportViewer.MdiParent = parent
    crystalReportViewer.Show()

    Dim report As ReportDocument = CType(crystalReportViewer.ReportSource, ReportDocument)

    'here are my attempts to get it to work
    Dim pf As ParameterFields = report.ParameterFields
    report.PrintOptions.PrinterName = "Microsoft XPS Document Writer"

    report.PrintToPrinter(1, False, 0, 0)
    crystalReportViewer.Close()
    crystalReportViewer.Dispose()

我对如何解决这个问题一无所知。有没有其他人遇到过这个?

【问题讨论】:

标签: printing parameters crystal-reports reporting


【解决方案1】:

起始代码:您的报告中可能有一些空参数。

搜索代码后:你有这行:

Dim pf As ParameterFields = report.ParameterFields

您有一个参数,但您没有设置任何值。

两者都使用:

//[C#]
report.setParameterValue(parameterName, parameterValue);

【讨论】:

    【解决方案2】:

    这很简单。在使用“printtoprinter”之前,请确保报表中的所有参数都已填充并抛出数据。我已经解决了。

    【讨论】:

      【解决方案3】:

      据我所知,这似乎是 Crystal 中的一个问题。我找不到修复程序,所以我只是使用一种解决方法,直到修复程序可用(生成报告然后手动打印)。

      【讨论】:

        【解决方案4】:

        首先你需要从 toolBox 添加 PrintDialog 然后添加以下代码 button_click_event

                ReportName.PrintOptions.PrinterName = PrintDialog1.PrinterSettings.PrinterName
        
                ReportName.PrintOptions.PaperOrientation = CrystalDecisions.[Shared].PaperOrientation.Landscape
        
                ReportName.PrintOptions.PrinterName = "Microsoft XPS Document Writer"
        
                ReportName.PrintToPrinter(PrintDialog1.PrinterSettings.Copies, True, 1, 99)
        

        这会将打印直接发送到“Microsoft XPS Document Writer”。如果您觉得这有帮助,请投票

        【讨论】:

          猜你喜欢
          • 2016-02-14
          • 1970-01-01
          • 1970-01-01
          • 2019-07-19
          • 1970-01-01
          • 2011-02-12
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多