读书人

水晶报表打印和动态数据绑定有关问题

发布时间: 2012-01-16 23:36:51 作者: rapoo

水晶报表打印和动态数据绑定问题,急啊!
Vs2005下设计好了水晶报表,并动态赋予SQL语句并能
正常显示,可当点击工具栏上的导出按扭时,就恢复了设计时的数据(为了方便设计建立一个空表,当查询时生成一个DataSet),如何解决,代码如下,另外水晶10.2如何实现客户端打印,解决一个就可以,主要是为了打印问题。
odb是定义连接ORACLE的一个类.
初始:
private void ConfigureCrystalReports()
{
ReportDocument rd = new ReportDocument();
string strFilePath = this.Server.MapPath( "PstRep.rpt ");
rd.Load(strFilePath);
// DataTable dt = DataSetConfiguration.CustomerDataSet;
ds = odb.getDataSet( "select * from temp_pst ", "temp_pst ");
rd.SetDataSource(ds);
CrystalReportViewer1.ReportSource = rd;
CrystalReportViewer1.RefreshReport();

}
动态绑定数据:
ds = odb.getDataSet(hideSQL.Text, "TEMP_PST ");
// dt = db.GetDataTable(strSQL);
rd.SetDataSource(ds);

CrystalReportViewer1.ReportSource = rd;
CrystalReportViewer1.DataBind();
CrystalReportViewer1.RefreshReport();

[解决办法]
打印:
首先下载printcontrol.cab从:http://
support.businessobjects.com/CRforVS2005/
PrintControl.cab#

然后在web.config中插入:

<configSections>
<sectionGroup name= "businessObjects ">
<sectionGroup name= "crystalReports ">
<section name= "printControl " type= "System.Configuration.NameValueSectionHandler, System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, Custom=null " />
</sectionGroup>
</sectionGroup>
</configSections>

<businessObjects>
<crystalReports>
<printControl>
<add key= "url " value= "http://localhost/PrintControl.cab " />
</printControl>
</crystalReports>
</businessObjects>

------解决方案--------------------


官方的答案:
Crystal Reports for Visual Studio 2005
列印
您可以藉由方式使用 Crystal Reports for Visual Studio 2005 以列印表:

藉由 GUI:在 Web 或 Windows Form 上使用 CrystalReportViewer 控制提供的工具列 [列印] 按。
藉由 SDK:使用 ReportDocument 物件。
GUI 中列印

在 Windows 用程式中,CrystalReportViewer 控制工具列上的 [列印] 按可以的列印方。

在 Web 用程式中,CrystalReportViewer 控制工具列上的 [列印] 按模列印方的第二。Web 伺服器上生 PDF,下之後便示在上。(其工作方式非常像「列印」)。

SDK 中列印

使用者通常使用 CrystalReportViewer 控制工具列中的 [列印] 按,自己的中列印表。但如果要在 Web 伺服器上列印表的 Web 用程式,可能就要使用 ReportDocument 物件模型撰程式,表伺服器直接列印到特定印表。

使用 ActiveX 控制列印

在 Crystal Reports 的更新版本中,您可以使用新的 CrystalReportViewer.PrintMode 性指定列印模式。其中包含列型:ActiveX 和 PDF。

性定 PrintMode.PDF ,表在 Web 伺服器上出 PDF,然後以料流送到器。使用者可以利用,直接列印至印表。是跨平台相容的。
性定 PrintMode.ActiveX ,ActiveX 列印控制允使用者表直接列印至本印表。
注意 在 Crystal Reports for Visual Studio 2005 中,符合 Microsoft 安全性需求起,有 ActiveX 列印控制安在本上。而是必成 .cab 案,人外部 URL 存取。PrintControl.cab 案可以 Business Objects 技支援站下取得,就可以 cab 案放在 Web 伺服器目中,以供 URL 存取之用。
若要在 Crystal Reports for Visual Studio 2005 站示 cab 案,下列 xml 加入站的 web.config 案:
<configSections>
<sectionGroup name= "businessObjects ">
<sectionGroup name= "crystalReports ">
<section name= "printControl " type= "System.Configuration.NameValueSectionHandler, System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, Custom=null " />
</sectionGroup>
</sectionGroup>
</configSections>

<businessObjects>
<crystalReports>
<printControl>
<add key= "url " value= "http://myserver/PrintControl.cab " />
</printControl>
</crystalReports>
</businessObjects>
注意 只有 Internet Explorer 才支援 ActiveX 控制。若非 Internet Explorer 的用端 (FireFox、Safari、Mozilla 等) 列印,回到 PDF 出方。

读书人网 >asp.net

热点推荐