【问题标题】:Preview Crystal Report on a separate form在单独的表单上预览 Crystal Report
【发布时间】:2012-10-15 14:06:17
【问题描述】:

我有一个表单,允许用户选择他们想要生成的报告。他们还可以选择条件,选择打印、预览、导出等。在用户做出选择并单击“生成”按钮后,我有一个类可以创建报表对象、加载报表、数据集,然后打印或导出那个报告。我创建了一个单独的表单来预览报告。当我将报表对象传递给预览表单时,我收到“无效的报表源”。报告打印和导出都很好,我只是无法预览报告。我不想在预览表单中复制代码,我希望我可以传递报告对象。我的代码片段如下。有什么建议吗?

public static class CrystalReportUtilities
{
    private static ReportDocument goReport {get; set;}
    private static string gsReportName { get; set; }
    private static string gsSqlString { get; set; }
    private static object[,] goParameters { get; set; }

    public static void generateReport(parameters...)
    {
      goReport = loadReport();
...
      goReport.SetDataSource(DataTable);
...
      previewReport();


    private static void previewReport()
    {
        CrystalReportPrintPreviewForm loReportPreview = new CrystalReportPrintPreviewForm(goReport);
        loReportPreview.ShowDialog();
    }


public partial class CrystalReportPrintPreviewForm : Form
{
    private ReportDocument goReport;

    public CrystalReportPrintPreviewForm(ReportDocument poReport)
    {
        InitializeComponent();

        goReport = poReport;
    }

    private void crystalReportViewer1_Load(object sender, EventArgs e)
    {
        try
        {
            if (goReport != null)
            {
                crystalReportViewer1.ReportSource = goReport;  // Receive "Invalid Report Source"
            }
        }

【问题讨论】:

  • 所以我更改了预览表单,以便不再将报告传递到表单中,形成类。我更改了类中的方法以在加载报表后返回一个 ReportDocument。在我的表单中,我调用该加载方法并设置 DataSource。现在表单加载,但我收到错误消息:找不到方法“'Void CrystalDecisions.Shared.PageRender.set_ExceptionWIndowTitle(System.String)'。我现在正在尝试追踪它。

标签: c# winforms crystal-reports-xi


【解决方案1】:

问题已解决。我在 Windows 7 64 位操作系统上运行。我最初为 64 位 Visual Studio 2010 安装了 Crystal Reports。看来您需要使用 SP4 的 64 位和 32 位版本的运行时。

【讨论】:

    猜你喜欢
    • 2023-03-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多