繁体   English   中英

在单独的表单上预览Crystal Report

[英]Preview Crystal Report on a separate form

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

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"
            }
        }

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM