OK了,上述代码正确,现在是把流传到客户端后 如何打印预览?我是用的是winform,不是web,用remoting方式.请高手指教?不要生成文件!

解决方案 »

  1.   

    /// <summary>
    /// 打印一份crystal Report
    /// </summary>
    /// <param name="reportPath">报表路径</param>
    /// <param name="reportSet">报表数据源的DataSet</param>
    public void printReport(string reportPath,string PrinterPath,string passWrd)
    {
    ReportDocument  crystalReportObject=new ReportDocument();
    crystalReportObject.Load(reportPath);//"e://temp//crt.rpt"
    crystalReportObject.Refresh();
    this.SetConnectionInfo(crystalReportObject,passWrd);
    //crystalReportObject.PrintOptions.PrinterName =@"\\office1\HP1000";
    crystalReportObject.PrintOptions.PrinterName =PrinterPath ;
    try
    {
    crystalReportObject.PrintToPrinter(1,false, 0, 0);
    }
    catch
    {
    ;
    }
    finally
    {
    crystalReportObject.Close();
    }

    }
    public void printReport(string PrinterPath,ReportDocument crystalReportObject)
    { crystalReportObject.PrintOptions.PrinterName =PrinterPath ;
    try
    {
    crystalReportObject.PrintToPrinter(1,false, 0, 0);
    }
    catch
    {
    ;
    }
    finally
    {
    crystalReportObject.Close();
    }
    // CrystalDecisions.Web.CrystalReportViewer myView=new CrystalDecisions.Web.CrystalReportViewer();
    // myView.LogOnInfo
    }