web下水晶报表的使用!

在web水晶报表的使用。
首先
需要在.aspx.cs文件中引入:using CrystalDecisions.CrystalReports.Engine;
创建.xsd文件和.rpt文件,.xsd文件其实是在.aspx.cs中创建的DataSet中的字段的映射。(可以添加,修改)。
然后
在.aspx.cs文件中操作,
ReportDocument oCR =null;
DataSet ds = data.GetDataSet();
oCR = new R_StandardAuditPrint();
oCR.SetDataSource(ds);
crvMainView.ReportSource=oCR; //CrystalDecisions.Web.CrystalReportViewer crvMainView 报表浏览器

其次
需要注意是,在 .aspx文将中,设置CRYSTALREPORTVIEWER的一些属性,

1<table cellpadding="2" cellspacing="2" height="100%" id="Tab4le1" width="100%">
2<tr>
3<td id="m_printpage" valign="top"><font face="宋体"><cr:crystalreportviewer displaygrouptree="False" displaytoolbar="False" enabledrilldown="False" height="50px" id="crvMainView" runat="server" width="350px"></cr:crystalreportviewer></font>
4</td>
5</tr>
6</table>

| | | 最后
在.aspx的btnprint.onclick事件中调用(javascript)
function printpage(m_printpage)
{
var newstr = document.all.item(m_printpage).innerHTML;
var oldstr = document.body.innerHTML;
document.body.innerHTML = newstr; window.print();
document.body.innerHTML = oldstr;
return true;
}
完成打印!

|

Published At
Categories with Web编程
Tagged with
comments powered by Disqus