您的位置:首页 > 其它

web下vs2008+crystal report 不预览直接打印

2009-12-03 09:27 288 查看
下载了一个PrintControl.cab(vs2008用的)

然后在webconfig中设置:

代码

protected void Page_Load(object sender, EventArgs e)
{

//if (!IsPostBack)
//{
//}
//本来是想写在IsPostBack里面的,但这样写就提示您请求的报表需要更多信息... 所以只好写在外面 ,原因是打印的时候还要重新绑定水晶报表。
BindCRV();

}
void BindCRV
{
CrystalDecisions.Web.CrystalReportSource crs = new CrystalDecisions.Web.CrystalReportSource();
PrintDocument prtdoc = new PrintDocument();
string strDefaultPrinter = prtdoc.PrinterSettings.PrinterName;
try
{
crs.ReportDocument.Load(reportpath);
crs.ReportDocument.SetDataSource(ds.Tables[0]);
crs.DataBind();
CrystalReportViewer1.ReportSource = crs;
CrystalReportViewer1.DataBind();
}
catch (Exception ex)
{
//UnCommon.ShoMessage(ex.Message, false, this);
// WSBG.UnCommon.ExecuteScript("alert('" + ex.Message + "')", this);

}
finally
{
crs.Dispose();
GC.Collect();
}
}

终于大功公成,不预览直接打印
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: